This commit is contained in:
Zachary Levy
2026-04-21 16:16:51 -07:00
parent 7650b90d91
commit ea19b83ba4
5 changed files with 211 additions and 271 deletions

View File

@@ -2,7 +2,6 @@ package examples
import "../../draw"
import "../../draw/draw_qr"
import "core:math"
import "core:os"
import sdl "vendor:sdl3"
@@ -17,9 +16,8 @@ textures :: proc() {
FONT_SIZE :: u16(14)
LABEL_OFFSET :: f32(8) // gap between item and its label
// -------------------------------------------------------------------------
// Procedural checkerboard texture (8x8, RGBA8)
// -------------------------------------------------------------------------
//----- Texture registration ----------------------------------
checker_size :: 8
checker_pixels: [checker_size * checker_size * 4]u8
for y in 0 ..< checker_size {
@@ -47,9 +45,6 @@ textures :: proc() {
)
defer draw.unregister_texture(checker_texture)
// -------------------------------------------------------------------------
// Non-square gradient stripe texture (16x8, RGBA8) for fit mode demos
// -------------------------------------------------------------------------
stripe_w :: 16
stripe_h :: 8
stripe_pixels: [stripe_w * stripe_h * 4]u8
@@ -76,14 +71,13 @@ textures :: proc() {
)
defer draw.unregister_texture(stripe_texture)
// -------------------------------------------------------------------------
// QR code texture (R8_UNORM — see rendering note below)
// -------------------------------------------------------------------------
qr_texture, _ := draw_qr.register_texture_from_text("https://x.com/miiilato/status/1880241066471051443")
qr_texture, _ := draw_qr.register_texture_from("https://x.com/miiilato/status/1880241066471051443")
defer draw.unregister_texture(qr_texture)
spin_angle: f32 = 0
//----- Draw loop ----------------------------------
for {
defer free_all(context.temp_allocator)
ev: sdl.Event
@@ -97,9 +91,8 @@ textures :: proc() {
// Background
draw.rectangle(base_layer, {0, 0, 800, 600}, {30, 30, 30, 255})
// =====================================================================
// Row 1: Sampler presets (y=30)
// =====================================================================
//----- Row 1: Sampler presets (y=30) ----------------------------------
ROW1_Y :: f32(30)
ITEM_SIZE :: f32(120)
COL1 :: f32(30)
@@ -156,9 +149,8 @@ textures :: proc() {
color = draw.WHITE,
)
// =====================================================================
// Row 2: QR code, Rounded, Rotating (y=190)
// =====================================================================
//----- Row 2: Sampler presets (y=190) ----------------------------------
ROW2_Y :: f32(190)
// QR code (RGBA texture with baked colors, nearest sampling)
@@ -214,9 +206,8 @@ textures :: proc() {
color = draw.WHITE,
)
// =====================================================================
// Row 3: Fit modes + Per-corner radii (y=360)
// =====================================================================
//----- Row 3: Fit modes + Per-corner radii (y=360) ----------------------------------
ROW3_Y :: f32(360)
FIT_SIZE :: f32(120) // square target rect