Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
module main
import math
import gg
gg.start(
window_title: 'Arcs'
width: 200
height: 200
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
ctx.draw_arc_filled(100, 100, 35, 45, 0, f32(math.radians(290)), 30, gg.red)
ctx.draw_arc_empty(100, 100, 30, 50, 0, f32(math.radians(290)), 30, gg.white)
ctx.end()
}
)
+18
View File
@@ -0,0 +1,18 @@
module main
import gg
gg.start(
width: 300
height: 300
window_title: 'Circles'
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
ctx.draw_circle_empty(150, 150, 80, gg.blue)
ctx.draw_circle_filled(150, 150, 40, gg.yellow)
ctx.draw_circle_line(150, 150, 80, 6, gg.red)
ctx.draw_circle_line(150, 150, 120, 6, gg.green)
ctx.draw_circle_line(150, 150, 150, 8, gg.white)
ctx.end()
}
)
+23
View File
@@ -0,0 +1,23 @@
import gg
const thickness = f32(5)
gg.start(
window_title: 'Ellipses'
width: 600
height: 400
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
drot := f32(ctx.frame) / 60
ctx.draw_ellipse_filled(100, 100, 100, 50, gg.red)
ctx.draw_ellipse_empty(100, 100, 50, 25, gg.black)
ctx.draw_ellipse_filled_rotate(300, 100, 100, 50, -drot, gg.blue)
ctx.draw_ellipse_empty_rotate(300, 100, 50, 25, -drot, gg.black)
ctx.draw_ellipse_filled_rotate(500, 100, 100, 50, drot, gg.yellow)
ctx.draw_ellipse_empty_rotate(500, 100, 50, 25, drot, gg.black)
ctx.draw_ellipse_thick(100, 300, 100, 50, thickness, gg.green)
ctx.draw_ellipse_thick_rotate(300, 300, 100, 50, thickness, drot, gg.purple)
ctx.draw_ellipse_thick_rotate(500, 300, 100, 50, thickness, -drot, gg.indigo)
ctx.end()
}
)
+18
View File
@@ -0,0 +1,18 @@
module main
import gg
gg.start(
bg_color: gg.rgb(174, 198, 255)
width: 600
height: 400
window_title: 'Polygons'
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
ctx.draw_convex_poly([f32(100.0), 100.0, 200.0, 100.0, 300.0, 200.0, 200.0, 300.0, 100.0,
300.0], gg.blue)
ctx.draw_poly_empty([f32(50.0), 50.0, 70.0, 60.0, 90.0, 80.0, 70.0, 110.0], gg.black)
ctx.draw_triangle_filled(450, 142, 530, 280, 370, 280, gg.red)
ctx.end()
}
)
+23
View File
@@ -0,0 +1,23 @@
module main
import gg
gg.start(
bg_color: gg.white
window_title: 'Rectangles'
width: 250
height: 100
frame_fn: fn (ctx &gg.Context) {
ctx.begin()
ctx.draw_rect_filled(10, 10, 10, 10, gg.blue)
ctx.draw_rect_empty(30, 10, 10, 10, gg.red)
ctx.draw_rect_filled(50, 10, 30, 10, gg.green)
ctx.draw_rect_empty(100, 10, 30, 10, gg.black)
ctx.draw_rect_empty(10, 50, 10, 10, gg.blue)
ctx.draw_rect_filled(30, 50, 10, 10, gg.red)
ctx.draw_rect_empty(50, 50, 30, 10, gg.green)
ctx.draw_rect_filled(100, 50, 30, 10, gg.black)
ctx.end()
}
)
+28
View File
@@ -0,0 +1,28 @@
module main
import gg
gg.start(
width: 325
height: 275
window_title: 'Rounded Rectangles'
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
// these should be rounded rectangles
ctx.draw_rounded_rect_empty(10, 10, 50, 100, 5, gg.blue)
ctx.draw_rounded_rect_empty(25, 25, 50, 100, 15, gg.yellow)
ctx.draw_rounded_rect_empty(50, 50, 50, 100, 50, gg.red)
ctx.draw_rounded_rect_empty(75, 75, 50, 100, 100, gg.green)
ctx.draw_rounded_rect_empty(100, 100, 50, 100, 1000, gg.white)
ctx.draw_rounded_rect_empty(110, 10, 100, 50, 5, gg.blue)
ctx.draw_rounded_rect_empty(125, 25, 100, 50, 15, gg.yellow)
ctx.draw_rounded_rect_empty(150, 50, 100, 50, 50, gg.red)
ctx.draw_rounded_rect_empty(175, 75, 100, 50, 100, gg.green)
ctx.draw_rounded_rect_empty(200, 100, 100, 50, 1000, gg.white)
// this should be a perfect circle
ctx.draw_rounded_rect_empty(10, 200, 50, 50, 1000, gg.magenta)
// this should be a perfect square
ctx.draw_rounded_rect_empty(250, 200, 50, 50, 0, gg.cyan)
ctx.end()
}
)
+28
View File
@@ -0,0 +1,28 @@
module main
import gg
gg.start(
width: 325
height: 275
window_title: 'Rounded Rectangles'
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
// these should be rounded rectangles
ctx.draw_rounded_rect_filled(10, 10, 50, 100, 5, gg.blue)
ctx.draw_rounded_rect_filled(25, 25, 50, 100, 15, gg.yellow)
ctx.draw_rounded_rect_filled(50, 50, 50, 100, 50, gg.red)
ctx.draw_rounded_rect_filled(75, 75, 50, 100, 100, gg.green)
ctx.draw_rounded_rect_filled(100, 100, 50, 100, 1000, gg.white)
ctx.draw_rounded_rect_filled(110, 10, 100, 50, 5, gg.blue)
ctx.draw_rounded_rect_filled(125, 25, 100, 50, 15, gg.yellow)
ctx.draw_rounded_rect_filled(150, 50, 100, 50, 50, gg.red)
ctx.draw_rounded_rect_filled(175, 75, 100, 50, 100, gg.green)
ctx.draw_rounded_rect_filled(200, 100, 100, 50, 1000, gg.white)
// this should be a perfect circle
ctx.draw_rounded_rect_filled(10, 200, 50, 50, 1000, gg.magenta)
// this should be a perfect square
ctx.draw_rounded_rect_filled(250, 200, 50, 50, 0, gg.cyan)
ctx.end()
}
)
+82
View File
@@ -0,0 +1,82 @@
module main
import gg
struct App {
mut:
gg &gg.Context = unsafe { nil }
rotation f32 = f32(0)
edge int = 3
}
fn main() {
println('rotation: left arrow key, right arrow key')
println('center polygon edge: up arrow key, down arrow key')
mut app := &App{}
app.gg = gg.new_context(
window_title: 'Simple Polygons'
width: 500
height: 500
bg_color: gg.black
event_fn: event
frame_fn: render
user_data: app
)
app.gg.run()
}
fn render(app &App) {
app.gg.begin()
color := gg.Color{
r: 175
g: 0
b: 0
a: 200
}
mut edge := 3
for i := 0; i <= 5; i++ {
for j := 0; j <= 5; j++ {
if i == 0 || j == 0 || i == 5 || j == 5 {
app.gg.draw_polygon_filled(50 + 80 * i, 50 + 80 * j, 30, edge, app.rotation,
color)
edge++
}
}
}
app.gg.draw_polygon_filled(250, 250, 150, app.edge, app.rotation, color)
app.gg.end()
}
fn event(e &gg.Event, mut app App) {
match e.typ {
.key_down {
match e.key_code {
.up {
app.edge++
}
.down {
if app.edge > 3 {
app.edge--
}
}
.right {
app.rotation++
}
.left {
app.rotation--
}
.escape {
app.gg.quit()
}
else {}
}
}
else {}
}
}
+45
View File
@@ -0,0 +1,45 @@
module main
import gg
gg.start(
width: 640
height: 300
window_title: 'Circles'
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
ctx.draw_text(10, 10, 'This text is at x: 10, y: 10', gg.TextCfg{ color: gg.white, size: 20 })
ctx.draw_text(10, 40, 'This text is at x: 10, y: 40 and bold', gg.TextCfg{
color: gg.white
bold: true
size: 20
})
ctx.draw_text(10, 70, 'This text is at x: 10, y: 70 and italic', gg.TextCfg{
color: gg.white
size: 20
italic: true
})
ctx.draw_text(10, 100, 'This text is at x: 10, y: 110 and mono', gg.TextCfg{
color: gg.white
size: 20
mono: true
})
ctx.draw_text(10, 130, 'This text is at x: 10, y: 130 and twice as big', gg.TextCfg{
color: gg.white
size: 40
})
ctx.draw_text(10, 180, 'This text is at x: 10, y: 180 and red', gg.TextCfg{
color: gg.red
size: 20
})
ctx.draw_text(10, 210, 'This text is at x: 10, y: 210 and blue', gg.TextCfg{
color: gg.blue
size: 20
})
ctx.draw_text(10, 240, 'This text is at x: 10, y: 240 and green', gg.TextCfg{
color: gg.green
size: 20
})
ctx.end()
}
)
+40
View File
@@ -0,0 +1,40 @@
module main
import gg
import sokol.gfx
fn main() {
mut context := gg.new_context(
frame_fn: frame
width: 500
height: 500
)
context.run()
}
fn frame(mut ctx gg.Context) {
ctx.begin()
id := ctx.new_streaming_image(ctx.width, ctx.height, 4, pixel_format: .rgba8)
mut img := ctx.get_cached_image_by_idx(id)
mut bytes := []u8{len: img.width * img.height * 4, cap: img.width * img.height * 4}
for y in 0 .. img.height {
for x in 0 .. img.width {
unsafe {
bytes[(x + img.width * y) * 4] = 100
bytes[(x + img.width * y) * 4 + 1] = 100
bytes[(x + img.width * y) * 4 + 2] = 100
bytes[(x + img.width * y) * 4 + 3] = 255
}
}
}
unsafe {
img.update_pixel_data(&bytes[0])
}
ctx.draw_image(0, 0, ctx.width, ctx.height, img)
ctx.remove_cached_image_by_idx(id)
ctx.end()
gfx.destroy_image(img.simg)
unsafe {
free(&bytes[0])
}
}
@@ -0,0 +1,37 @@
module main
import gg
const win_width = 100
const win_height = 100
struct App {
mut:
gg &gg.Context = unsafe { nil }
image int
}
fn main() {
mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
window_title: 'issue 10989'
frame_fn: frame
user_data: app
init_fn: initialize
)
app.gg.run()
}
fn initialize(mut app App) {
buffer := []u8{len: 10 * 10}
app.image = app.gg.new_streaming_image(10, 10, 1, pixel_format: .r8)
app.gg.update_pixel_data(app.image, buffer.data)
}
fn frame(mut app App) {
app.gg.begin()
app.gg.draw_image_by_id(0, 0, 10, 10, app.image)
app.gg.end()
}
+48
View File
@@ -0,0 +1,48 @@
module main
import gg
struct App {
mut:
gg &gg.Context = unsafe { nil }
radius f64 = 10.0
}
fn main() {
mut app := &App{}
app.gg = gg.new_context(
bg_color: gg.white
width: 300
height: 300
window_title: 'Circles'
frame_fn: frame
event_fn: on_event
user_data: app
)
app.gg.run()
}
fn on_event(e &gg.Event, mut app App) {
match e.typ {
.key_down {
match e.key_code {
.up {
app.radius += 1
}
.down {
app.radius -= 1
}
else {}
}
}
else {}
}
}
fn frame(mut app App) {
app.gg.begin()
app.gg.draw_circle_empty(150, 150, f32(app.radius), gg.blue)
app.gg.draw_text(20, 20, 'radius: ${app.radius}')
// app.gg.draw_text(20, 50, 'circle_segment_size: ${circle_segment_size}')
app.gg.end()
}