← ziglang.inraylib-zigGitHub

input gestures testbed

★★★☆by ubkp (@ubkp)

There is no browser build of this example yet.

Is it the same as C?

//! raylib [core] example - input gestures testbed
//!
//! Zig-API translation of examples/core/core_input_gestures_testbed.c (raylib 6.2).
//! Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
//! Example licensed under an unmodified zlib/libpng license.
//! Copyright (c) 2023-2025 ubkp (@ubkp)

const rl = @import("raylib");

const gesture_log_size = 20;
const max_touch_count = 32;

/// Gesture log filter, toggled by the two log buttons
const LogMode = struct {
    hide_repeat: bool = true, // Hide repeated events
    hide_hold: bool = false, // Hide hold events

    /// Whether `gesture` passes the filter, given the last logged gesture.
    fn accepts(mode: LogMode, gesture: rl.Gesture, previous: rl.Gesture) bool {
        if (gesture == .none) return false;
        const repeated = gesture == previous;
        if (mode.hide_repeat and mode.hide_hold) return (gesture != .hold and !repeated) or @backingInt(gesture) < 3;
        if (mode.hide_hold) return gesture != .hold;
        if (mode.hide_repeat) return !repeated;
        return true;
    }
};

pub fn main() void {
    // Initialization
    const screen_width = 800;
    const screen_height = 450;

    rl.initWindow(screen_width, screen_height, "raylib [core] example - input gestures testbed");
    defer rl.closeWindow(); // Close window and OpenGL context

    const message_position: rl.Vector2 = .{ .x = 160, .y = 7 };

    // Last gesture variables definitions
    var last_gesture: rl.Gesture = .none;
    const last_gesture_position: rl.Vector2 = .{ .x = 165, .y = 130 };

    // Gesture log variables definitions
    // NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
    var gesture_log: [gesture_log_size][:0]const u8 = @splat("");
    // NOTE: The index for the inverted circular queue (moving from last to first direction, then looping around)
    var gesture_log_index: usize = 0;
    var previous_gesture: rl.Gesture = .none;

    var log_mode: LogMode = .{};

    var gesture_color: rl.Color = .{ .r = 0, .g = 0, .b = 0, .a = 255 };
    const log_button1: rl.Rectangle = .{ .x = 53, .y = 7, .width = 48, .height = 26 };
    const log_button2: rl.Rectangle = .{ .x = 108, .y = 7, .width = 36, .height = 26 };
    const gesture_log_position: rl.Vector2 = .{ .x = 10, .y = 10 };

    // Protractor variables definitions
    const angle_length: f32 = 90.0;
    var current_angle_degrees: f32 = 0.0;
    const protractor_position: rl.Vector2 = .{ .x = 266.0, .y = 315.0 };

    rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second

    // Main game loop
    while (!rl.windowShouldClose()) { // Detect window close button or ESC key
        // Update
        // Handle common gestures data
        const current_gesture = rl.getGestureDetected();
        const current_drag_degrees = rl.getGestureDragAngle();
        const current_pitch_degrees = rl.getGesturePinchAngle();
        const touch_count: usize = @intCast(rl.getTouchPointCount());

        // Handle last gesture
        if (current_gesture != .none and current_gesture != .hold and current_gesture != previous_gesture)
            last_gesture = current_gesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display

        // Handle gesture log
        if (rl.isMouseButtonReleased(.left)) {
            if (rl.checkCollisionPointRec(rl.getMousePosition(), log_button1)) {
                log_mode.hide_repeat = !log_mode.hide_repeat;
            } else if (rl.checkCollisionPointRec(rl.getMousePosition(), log_button2)) {
                log_mode.hide_hold = !log_mode.hide_hold;
            }
        }

        // If the gesture passes the log mode filter, fill the gesture log
        if (log_mode.accepts(current_gesture, previous_gesture)) {
            previous_gesture = current_gesture;
            gesture_color = gestureColor(current_gesture);
            if (gesture_log_index == 0) gesture_log_index = gesture_log_size;
            gesture_log_index -= 1;

            gesture_log[gesture_log_index] = gestureName(current_gesture);
        }

        // Handle protractor
        const gesture_value = @backingInt(current_gesture);
        if (gesture_value > 255) {
            current_angle_degrees = current_pitch_degrees; // Pinch In and Pinch Out
        } else if (gesture_value > 15) {
            current_angle_degrees = current_drag_degrees; // Swipe Right, Swipe Left, Swipe Up and Swipe Down
        } else if (gesture_value > 0) {
            current_angle_degrees = 0.0; // Tap, Doubletap, Hold and Grab
        }

        const current_angle_radians = ((current_angle_degrees + 90.0) * rl.pi / 180); // Convert the current angle to Radians
        // Calculate the final vector for display
        const final_vector: rl.Vector2 = .{
            .x = (angle_length * @sin(current_angle_radians)) + protractor_position.x,
            .y = (angle_length * @cos(current_angle_radians)) + protractor_position.y,
        };

        // Handle touch and mouse pointer points
        var touch_position: [max_touch_count]rl.Vector2 = @splat(.{ .x = 0, .y = 0 });
        var mouse_position: rl.Vector2 = .{ .x = 0, .y = 0 };
        if (current_gesture != .none) {
            if (touch_count != 0) {
                for (touch_position[0..touch_count], 0..) |*position, i| position.* = rl.getTouchPosition(@intCast(i)); // Fill the touch positions
            } else mouse_position = rl.getMousePosition();
        }

        // Draw
        rl.beginDrawing();
        defer rl.endDrawing();

        rl.clearBackground(.ray_white);

        // Draw common elements
        const mx: i32 = @intFromFloat(message_position.x);
        const my: i32 = @intFromFloat(message_position.y);
        rl.drawText("*", mx + 5, my + 5, 10, .black);
        rl.drawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", mx + 15, my + 5, 10, .black);
        rl.drawText("*", mx + 5, my + 35, 10, .black);
        rl.drawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", mx + 15, my + 35, 10, .black);

        // Draw last gesture
        const lg = last_gesture_position;
        const lx: i32 = @intFromFloat(lg.x);
        const ly: i32 = @intFromFloat(lg.y);
        rl.drawText("Last gesture", lx + 33, ly - 47, 20, .black);
        rl.drawText("Swipe         Tap       Pinch  Touch", lx + 17, ly - 18, 10, .black);
        rl.drawRectangle(lx + 20, ly, 20, 20, if (last_gesture == .swipe_up) .red else .light_gray);
        rl.drawRectangle(lx, ly + 20, 20, 20, if (last_gesture == .swipe_left) .red else .light_gray);
        rl.drawRectangle(lx + 40, ly + 20, 20, 20, if (last_gesture == .swipe_right) .red else .light_gray);
        rl.drawRectangle(lx + 20, ly + 40, 20, 20, if (last_gesture == .swipe_down) .red else .light_gray);
        rl.drawCircle(lx + 80, ly + 16, 10, if (last_gesture == .tap) .blue else .light_gray);
        rl.drawRing(.{ .x = lg.x + 103, .y = lg.y + 16 }, 6.0, 11.0, 0.0, 360.0, 0, if (last_gesture == .drag) .lime else .light_gray);
        rl.drawCircle(lx + 80, ly + 43, 10, if (last_gesture == .doubletap) .sky_blue else .light_gray);
        rl.drawCircle(lx + 103, ly + 43, 10, if (last_gesture == .doubletap) .sky_blue else .light_gray);
        const pinch_out_color: rl.Color = if (last_gesture == .pinch_out) .orange else .light_gray;
        rl.drawTriangle(.{ .x = lg.x + 122, .y = lg.y + 16 }, .{ .x = lg.x + 137, .y = lg.y + 26 }, .{ .x = lg.x + 137, .y = lg.y + 6 }, pinch_out_color);
        rl.drawTriangle(.{ .x = lg.x + 147, .y = lg.y + 6 }, .{ .x = lg.x + 147, .y = lg.y + 26 }, .{ .x = lg.x + 162, .y = lg.y + 16 }, pinch_out_color);
        const pinch_in_color: rl.Color = if (last_gesture == .pinch_in) .violet else .light_gray;
        rl.drawTriangle(.{ .x = lg.x + 125, .y = lg.y + 33 }, .{ .x = lg.x + 125, .y = lg.y + 53 }, .{ .x = lg.x + 140, .y = lg.y + 43 }, pinch_in_color);
        rl.drawTriangle(.{ .x = lg.x + 144, .y = lg.y + 43 }, .{ .x = lg.x + 159, .y = lg.y + 53 }, .{ .x = lg.x + 159, .y = lg.y + 33 }, pinch_in_color);
        for (0..4) |i| {
            const touch_y = ly + 7 + @as(i32, @intCast(i)) * 15;
            rl.drawCircle(lx + 180, touch_y, 5, if (touch_count <= i) .light_gray else gesture_color);
        }

        // Draw gesture log
        const gx: i32 = @intFromFloat(gesture_log_position.x);
        const gy: i32 = @intFromFloat(gesture_log_position.y);
        rl.drawText("Log", gx, gy, 20, .black);

        // Print the gesture log array in the inverted order (looping around if the index started somewhere in the middle)
        for (0..gesture_log_size) |i| {
            const entry = gesture_log[(gesture_log_index + i) % gesture_log_size];
            rl.drawText(entry, gx, gy + 410 - @as(i32, @intCast(i)) * 20, 20, if (i == 0) gesture_color else .light_gray);
        }
        const log_button1_color: rl.Color = if (log_mode.hide_repeat) .maroon else .gray;
        const log_button2_color: rl.Color = if (log_mode.hide_hold) .maroon else .gray;
        const bx: i32 = @intFromFloat(log_button1.x);
        const by: i32 = @intFromFloat(log_button1.y);
        rl.drawRectangleRec(log_button1, log_button1_color);
        rl.drawText("Hide", bx + 7, by + 3, 10, .white);
        rl.drawText("Repeat", bx + 7, by + 13, 10, .white);
        rl.drawRectangleRec(log_button2, log_button2_color);
        rl.drawText("Hide", bx + 62, by + 3, 10, .white);
        rl.drawText("Hold", bx + 62, by + 13, 10, .white);

        // Draw protractor
        const p = protractor_position;
        const px: i32 = @intFromFloat(p.x);
        const py: i32 = @intFromFloat(p.y);
        rl.drawText("Angle", px + 55, py + 76, 10, .black);
        const angle_string = rl.textFormat("{d:.6}", .{current_angle_degrees});
        const angle_string_dot = rl.textFindIndex(angle_string, ".");
        const angle_string_trim = rl.textSubtext(angle_string, 0, angle_string_dot + 3);
        rl.drawText(angle_string_trim, px + 55, py + 92, 20, gesture_color);
        rl.drawCircleV(p, 80.0, .white);
        rl.drawLineEx(.{ .x = p.x - 90, .y = p.y }, .{ .x = p.x + 90, .y = p.y }, 3.0, .light_gray);
        rl.drawLineEx(.{ .x = p.x, .y = p.y - 90 }, .{ .x = p.x, .y = p.y + 90 }, 3.0, .light_gray);
        rl.drawLineEx(.{ .x = p.x - 80, .y = p.y - 45 }, .{ .x = p.x + 80, .y = p.y + 45 }, 3.0, .green);
        rl.drawLineEx(.{ .x = p.x - 80, .y = p.y + 45 }, .{ .x = p.x + 80, .y = p.y - 45 }, 3.0, .green);
        rl.drawText("0", px + 96, py - 9, 20, .black);
        rl.drawText("30", px + 74, py - 68, 20, .black);
        rl.drawText("90", px - 11, py - 110, 20, .black);
        rl.drawText("150", px - 100, py - 68, 20, .black);
        rl.drawText("180", px - 124, py - 9, 20, .black);
        rl.drawText("210", px - 100, py + 50, 20, .black);
        rl.drawText("270", px - 18, py + 92, 20, .black);
        rl.drawText("330", px + 72, py + 50, 20, .black);
        if (current_angle_degrees != 0.0) rl.drawLineEx(p, final_vector, 3.0, gesture_color);

        // Draw touch and mouse pointer points
        if (current_gesture != .none) {
            if (touch_count != 0) {
                for (touch_position[0..touch_count]) |position| {
                    rl.drawCircleV(position, 50.0, rl.fade(gesture_color, 0.5));
                    rl.drawCircleV(position, 5.0, gesture_color);
                }

                if (touch_count == 2) rl.drawLineEx(touch_position[0], touch_position[1], if (current_gesture == .pinch_out) 8.0 else 12.0, gesture_color);
            } else {
                rl.drawCircleV(mouse_position, 35.0, rl.fade(gesture_color, 0.5));
                rl.drawCircleV(mouse_position, 5.0, gesture_color);
            }
        }
    }
}

/// Get text string for gesture value
fn gestureName(gesture: rl.Gesture) [:0]const u8 {
    return switch (gesture) {
        .none => "None",
        .tap => "Tap",
        .doubletap => "Double Tap",
        .hold => "Hold",
        .drag => "Drag",
        .swipe_right => "Swipe Right",
        .swipe_left => "Swipe Left",
        .swipe_up => "Swipe Up",
        .swipe_down => "Swipe Down",
        .pinch_in => "Pinch In",
        .pinch_out => "Pinch Out",
        _ => "Unknown",
    };
}

/// Get color for gesture value
fn gestureColor(gesture: rl.Gesture) rl.Color {
    return switch (gesture) {
        .tap => .blue,
        .doubletap => .sky_blue,
        .drag => .lime,
        .swipe_right, .swipe_left, .swipe_up, .swipe_down => .red,
        .pinch_in => .violet,
        .pinch_out => .orange,
        .none, .hold, _ => .black,
    };
}
/*******************************************************************************************
*
*   raylib [core] example - input gestures testbed
*
*   Example complexity rating: [★★★☆] 3/4
*
*   Example originally created with raylib 5.0, last time updated with raylib 6.0
*
*   Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
*
*   Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
*   BSD-like license that allows static linking with closed source software
*
*   Copyright (c) 2023-2025 ubkp (@ubkp)
*
********************************************************************************************/

#include "raylib.h"

#include <math.h>       // Required for the protractor angle graphic drawing

#define GESTURE_LOG_SIZE    20
#define MAX_TOUCH_COUNT     32

//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static char const *GetGestureName(int gesture); // Get text string for gesture value
static Color GetGestureColor(int gesture); // Get color for gesture value

//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
    // Initialization
    //--------------------------------------------------------------------------------------
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed");

    Vector2 messagePosition = { 160, 7 };

    // Last gesture variables definitions
    int lastGesture = 0;
    Vector2 lastGesturePosition = { 165, 130 };

    // Gesture log variables definitions
    // NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
    char gestureLog[GESTURE_LOG_SIZE][12] = { "" };
    // NOTE: The index for the inverted circular queue (moving from last to first direction, then looping around)
    int gestureLogIndex = 0;
    int previousGesture = 0;

    // Log mode values:
    // - 0 shows repeated events
    // - 1 hides repeated events
    // - 2 shows repeated events but hide hold events
    // - 3 hides repeated events and hide hold events
    int logMode = 1;

    Color gestureColor = { 0, 0, 0, 255 };
    Rectangle logButton1 = { 53, 7, 48, 26 };
    Rectangle logButton2 = { 108, 7, 36, 26 };
    Vector2 gestureLogPosition = { 10, 10 };

    // Protractor variables definitions
    float angleLength = 90.0f;
    float currentAngleDegrees = 0.0f;
    Vector2 finalVector = { 0.0f, 0.0f };
    Vector2 protractorPosition = { 266.0f, 315.0f };

    SetTargetFPS(60);   // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //--------------------------------------------------------------------------------------
        // Handle common gestures data
        int i, ii; // Iterators that will be reused by all for loops
        const int currentGesture = GetGestureDetected();
        const float currentDragDegrees = GetGestureDragAngle();
        const float currentPitchDegrees = GetGesturePinchAngle();
        const int touchCount = GetTouchPointCount();

        // Handle last gesture
        if ((currentGesture != 0) && (currentGesture != 4) && (currentGesture != previousGesture))
            lastGesture = currentGesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display

        // Handle gesture log
        if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
        {
            if (CheckCollisionPointRec(GetMousePosition(), logButton1))
            {
                switch (logMode)
                {
                    case 3: logMode = 2; break;
                    case 2: logMode = 3; break;
                    case 1: logMode = 0; break;
                    default: logMode = 1; break;
                }
            }
            else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
            {
                switch (logMode)
                {
                    case 3: logMode = 1; break;
                    case 2: logMode = 0; break;
                    case 1: logMode = 3; break;
                    default: logMode = 2; break;
                }
            }
        }

        int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
        if (currentGesture !=0)
        {
            if (logMode == 3) // 3 hides repeated events and hide hold events
            {
                if (((currentGesture != 4) && (currentGesture != previousGesture)) || (currentGesture < 3)) fillLog = 1;
            }
            else if (logMode == 2) // 2 shows repeated events but hide hold events
            {
                if (currentGesture != 4) fillLog = 1;
            }
            else if (logMode == 1) // 1 hides repeated events
            {
                if (currentGesture != previousGesture) fillLog = 1;
            }
            else  // 0 shows repeated events
            {
                fillLog = 1;
            }
        }

        if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
        {
            previousGesture = currentGesture;
            gestureColor = GetGestureColor(currentGesture);
            if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
            gestureLogIndex--;

            // Copy the gesture respective name to the gesture log array
            TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
        }

        // Handle protractor
        if (currentGesture > 255) currentAngleDegrees = currentPitchDegrees; // Pinch In and Pinch Out
        else if (currentGesture > 15) currentAngleDegrees = currentDragDegrees; // Swipe Right, Swipe Left, Swipe Up and Swipe Down
        else if (currentGesture > 0) currentAngleDegrees = 0.0f; // Tap, Doubletap, Hold and Grab

        float currentAngleRadians = ((currentAngleDegrees + 90.0f)*PI/180); // Convert the current angle to Radians
        // Calculate the final vector for display
        finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x,
            (angleLength*cosf(currentAngleRadians)) + protractorPosition.y };

        // Handle touch and mouse pointer points
        Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
        Vector2 mousePosition = { 0 };
        if (currentGesture != GESTURE_NONE)
        {
            if (touchCount != 0)
            {
                for (i = 0; i < touchCount; i++) touchPosition[i] = GetTouchPosition(i); // Fill the touch positions
            }
            else mousePosition = GetMousePosition();
        }
        //--------------------------------------------------------------------------------------

        // Draw
        //--------------------------------------------------------------------------------------
        BeginDrawing();
            ClearBackground(RAYWHITE);

            // Draw common elements
            DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 5, 10, BLACK);
            DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", (int)messagePosition.x + 15, (int)messagePosition.y + 5, 10, BLACK);
            DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 35, 10, BLACK);
            DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", (int)messagePosition.x + 15, (int)messagePosition.y + 35, 10, BLACK);

            // Draw last gesture
            DrawText("Last gesture", (int)lastGesturePosition.x + 33, (int)lastGesturePosition.y - 47, 20, BLACK);
            DrawText("Swipe         Tap       Pinch  Touch", (int)lastGesturePosition.x + 17, (int)lastGesturePosition.y - 18, 10, BLACK);
            DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
            DrawRectangle((int)lastGesturePosition.x, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
            DrawRectangle((int)lastGesturePosition.x + 40, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
            DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
            DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
            DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
            DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
            DrawCircle((int)lastGesturePosition.x + 103, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
            DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
            DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
            DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
            DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
            for (i = 0; i < 4; i++) DrawCircle((int)lastGesturePosition.x + 180, (int)lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);

            // Draw gesture log
            DrawText("Log", (int)gestureLogPosition.x, (int)gestureLogPosition.y, 20, BLACK);

            // Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
            for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1)%GESTURE_LOG_SIZE) DrawText(gestureLog[ii], (int)gestureLogPosition.x, (int)gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
            Color logButton1Color, logButton2Color;
            switch (logMode)
            {
                case 3:  logButton1Color=MAROON; logButton2Color=MAROON; break;
                case 2:  logButton1Color=GRAY;   logButton2Color=MAROON; break;
                case 1:  logButton1Color=MAROON; logButton2Color=GRAY;   break;
                default: logButton1Color=GRAY;   logButton2Color=GRAY;   break;
            }
            DrawRectangleRec(logButton1, logButton1Color);
            DrawText("Hide", (int)logButton1.x + 7, (int)logButton1.y + 3, 10, WHITE);
            DrawText("Repeat", (int)logButton1.x + 7, (int)logButton1.y + 13, 10, WHITE);
            DrawRectangleRec(logButton2, logButton2Color);
            DrawText("Hide", (int)logButton1.x + 62, (int)logButton1.y + 3, 10, WHITE);
            DrawText("Hold", (int)logButton1.x + 62, (int)logButton1.y + 13, 10, WHITE);

            // Draw protractor
            DrawText("Angle", (int)protractorPosition.x + 55, (int)protractorPosition.y + 76, 10, BLACK);
            const char *angleString = TextFormat("%f", currentAngleDegrees);
            const int angleStringDot = TextFindIndex(angleString, ".");
            const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
            DrawText( angleStringTrim, (int)protractorPosition.x + 55, (int)protractorPosition.y + 92, 20, gestureColor);
            DrawCircleV(protractorPosition, 80.0f, WHITE);
            DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
            DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
            DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
            DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
            DrawText("0", (int)protractorPosition.x + 96, (int)protractorPosition.y - 9, 20, BLACK);
            DrawText("30", (int)protractorPosition.x + 74, (int)protractorPosition.y - 68, 20, BLACK);
            DrawText("90", (int)protractorPosition.x - 11, (int)protractorPosition.y - 110, 20, BLACK);
            DrawText("150", (int)protractorPosition.x - 100, (int)protractorPosition.y - 68, 20, BLACK);
            DrawText("180", (int)protractorPosition.x - 124, (int)protractorPosition.y - 9, 20, BLACK);
            DrawText("210", (int)protractorPosition.x - 100, (int)protractorPosition.y + 50, 20, BLACK);
            DrawText("270", (int)protractorPosition.x - 18, (int)protractorPosition.y + 92, 20, BLACK);
            DrawText("330", (int)protractorPosition.x + 72, (int)protractorPosition.y + 50, 20, BLACK);
            if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);

            // Draw touch and mouse pointer points
            if (currentGesture != GESTURE_NONE)
            {
                if ( touchCount != 0 )
                {
                    for (i = 0; i < touchCount; i++)
                    {
                        DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
                        DrawCircleV(touchPosition[i], 5.0f, gestureColor);
                    }

                    if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8.0f : 12.0f), gestureColor);
                }
                else
                {
                    DrawCircleV(mousePosition, 35.0f, Fade(gestureColor, 0.5f));
                    DrawCircleV(mousePosition, 5.0f, gestureColor);
                }
            }

        EndDrawing();
        //--------------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}

//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Get text string for gesture value
static char const *GetGestureName(int gesture)
{
    switch (gesture)
    {
        case 0: return "None"; break;
        case 1: return "Tap"; break;
        case 2: return "Double Tap"; break;
        case 4: return "Hold"; break;
        case 8: return "Drag"; break;
        case 16: return "Swipe Right"; break;
        case 32: return "Swipe Left"; break;
        case 64: return "Swipe Up"; break;
        case 128: return "Swipe Down"; break;
        case 256: return "Pinch In"; break;
        case 512: return "Pinch Out"; break;
        default:  return "Unknown"; break;
    }
}

// Get color for gesture value
static Color GetGestureColor(int gesture)
{
    switch (gesture)
    {
        case 0: return BLACK; break;
        case 1: return BLUE; break;
        case 2: return SKYBLUE; break;
        case 4: return BLACK; break;
        case 8: return LIME; break;
        case 16: return RED; break;
        case 32: return RED; break;
        case 64: return RED; break;
        case 128: return RED; break;
        case 256: return VIOLET; break;
        case 512: return ORANGE; break;
        default: return BLACK; break;
    }
}

From raylib 6.2. The original on GitHub.