From bbb61ab3687afe512a1fa12492c876d011626107 Mon Sep 17 00:00:00 2001 From: "Eliyaan (Nopana)" <103932369+Eliyaan@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:53:56 +0200 Subject: [PATCH] gg, gx: deprecate `gx` and replace all occurences with `gg` (which now contains all the functionality of `gx`) (#24966) --- examples/2048/2048.v | 157 ++++--- examples/asteroids/asteroids.v | 29 +- examples/breakout/breakout.v | 19 +- examples/clock/clock.v | 11 +- examples/fireworks/fireworks.v | 3 +- examples/fireworks/modules/objects/color.v | 6 +- examples/fireworks/modules/objects/particle.v | 3 +- examples/fireworks/modules/objects/rocket.v | 3 +- examples/game_of_life/life_gg.v | 7 +- examples/gg/additive.v | 15 +- examples/gg/arcs_and_slices.v | 5 +- examples/gg/bezier.v | 7 +- examples/gg/bezier_anim.v | 5 +- examples/gg/cursor.v | 3 +- examples/gg/digital_rain.v | 11 +- examples/gg/drag_n_drop.v | 7 +- examples/gg/draw_pixels.v | 13 +- examples/gg/easing_animation.v | 9 +- examples/gg/fire.v | 75 ++-- examples/gg/mandelbrot.v | 5 +- examples/gg/many_thousands_of_circles.v | 5 +- examples/gg/memory.v | 11 +- examples/gg/minesweeper.v | 23 +- .../path_finding_algorithm_visualizer/aStar.v | 25 +- examples/gg/polygons.v | 9 +- examples/gg/raven_text_rendering.v | 5 +- examples/gg/raycaster.v | 17 +- examples/gg/rectangles.v | 7 +- examples/gg/rotating_textured_quad.v | 3 +- examples/gg/sample_count.v | 11 +- examples/gg/stars.v | 3 +- examples/gg/worker_thread.v | 7 +- examples/hot_reload/bounce.v | 9 +- examples/hot_reload/graph.v | 11 +- .../modules/sim/anim/app.v | 5 +- .../pendulum-simulation/modules/sim/img/ppm.v | 4 +- .../modules/sim/img/writer.v | 12 +- examples/quadtree_demo/quadtree_demo.v | 19 +- examples/snek/snek.js.v | 13 +- examples/snek/snek.v | 21 +- examples/sokoban/sokoban.v | 21 +- examples/sokol/01_cubes/cube.v | 3 +- examples/sokol/02_cubes_glsl/cube_glsl.v | 3 +- .../sokol/03_march_tracing_glsl/rt_glsl.v | 3 +- examples/sokol/05_instancing_glsl/rt_glsl.v | 3 +- examples/sokol/06_obj_viewer/show_obj.v | 3 +- examples/tetris/tetris.js.v | 41 +- examples/tetris/tetris.v | 41 +- examples/ttf_font/draw_static_text.v | 3 +- examples/ttf_font/example_ttf.v | 3 +- examples/viewer/view.v | 11 +- vlib/gg/README.md | 9 +- vlib/gg/color.v | 310 ++++++++++++++ vlib/gg/color_test.v | 102 +++++ vlib/gg/draw.c.v | 57 ++- vlib/gg/gg.c.v | 15 +- vlib/gg/gg.js.v | 7 +- vlib/gg/gg.v | 4 +- vlib/gg/gg_darwin.c.v | 2 - vlib/gg/gg_darwin.m | 10 +- vlib/gg/gg_ui.c.v | 5 +- vlib/gg/image.v | 4 +- vlib/gg/import_gx.v | 5 - vlib/gg/testdata/draw_arcs.vv | 5 +- vlib/gg/testdata/draw_circles.vv | 11 +- vlib/gg/testdata/draw_elipses.vv | 5 +- vlib/gg/testdata/draw_polygons.vv | 9 +- vlib/gg/testdata/draw_rectangles.vv | 19 +- vlib/gg/testdata/draw_rounded_rect_empty.vv | 25 +- vlib/gg/testdata/draw_simple_polygons.vv | 5 +- vlib/gg/testdata/tweak_circles.vv | 5 +- vlib/gg/text_rendering.c.v | 30 +- vlib/gg/text_rendering.js.v | 15 +- vlib/gg/text_rendering.v | 35 +- vlib/gx/color.v | 392 +++++------------- vlib/gx/color_test.v | 1 + vlib/gx/image.v | 4 + vlib/gx/text.c.v | 16 +- vlib/gx/text.js.v | 6 + vlib/gx/text.v | 34 +- .../consts_with_embedded_comments_expected.vv | 4 +- .../consts_with_embedded_comments_input.vv | 6 +- vlib/v/fmt/tests/fntype_alias_keep.vv | 5 +- .../c_struct_with_reserved_field_name_test.v | 3 +- vlib/v/tests/consts/const_resolution_test.v | 9 +- vlib/v/tests/skip_unused/gg_code.vv | 3 +- vlib/x/ttf/README.md | 5 +- 87 files changed, 1055 insertions(+), 875 deletions(-) create mode 100644 vlib/gg/color.v create mode 100644 vlib/gg/color_test.v delete mode 100644 vlib/gg/import_gx.v diff --git a/examples/2048/2048.v b/examples/2048/2048.v index 3c75c46b0..c61e3569c 100644 --- a/examples/2048/2048.v +++ b/examples/2048/2048.v @@ -1,5 +1,4 @@ import gg -import gx import math import math.easing import os.asset @@ -52,76 +51,76 @@ mut: } struct Theme { - bg_color gx.Color - padding_color gx.Color - text_color gx.Color - game_over_color gx.Color - victory_color gx.Color - tile_colors []gx.Color + bg_color gg.Color + padding_color gg.Color + text_color gg.Color + game_over_color gg.Color + victory_color gg.Color + tile_colors []gg.Color } const themes = [ &Theme{ - bg_color: gx.rgb(250, 248, 239) - padding_color: gx.rgb(143, 130, 119) - victory_color: gx.rgb(100, 160, 100) - game_over_color: gx.rgb(190, 50, 50) - text_color: gx.black + bg_color: gg.rgb(250, 248, 239) + padding_color: gg.rgb(143, 130, 119) + victory_color: gg.rgb(100, 160, 100) + game_over_color: gg.rgb(190, 50, 50) + text_color: gg.black tile_colors: [ - gx.rgb(205, 193, 180), // Empty / 0 tile - gx.rgb(238, 228, 218), // 2 - gx.rgb(237, 224, 200), // 4 - gx.rgb(242, 177, 121), // 8 - gx.rgb(245, 149, 99), // 16 - gx.rgb(246, 124, 95), // 32 - gx.rgb(246, 94, 59), // 64 - gx.rgb(237, 207, 114), // 128 - gx.rgb(237, 204, 97), // 256 - gx.rgb(237, 200, 80), // 512 - gx.rgb(237, 197, 63), // 1024 - gx.rgb(237, 194, 46), + gg.rgb(205, 193, 180), // Empty / 0 tile + gg.rgb(238, 228, 218), // 2 + gg.rgb(237, 224, 200), // 4 + gg.rgb(242, 177, 121), // 8 + gg.rgb(245, 149, 99), // 16 + gg.rgb(246, 124, 95), // 32 + gg.rgb(246, 94, 59), // 64 + gg.rgb(237, 207, 114), // 128 + gg.rgb(237, 204, 97), // 256 + gg.rgb(237, 200, 80), // 512 + gg.rgb(237, 197, 63), // 1024 + gg.rgb(237, 194, 46), ] }, &Theme{ - bg_color: gx.rgb(55, 55, 55) - padding_color: gx.rgb(68, 60, 59) - victory_color: gx.rgb(100, 160, 100) - game_over_color: gx.rgb(190, 50, 50) - text_color: gx.white + bg_color: gg.rgb(55, 55, 55) + padding_color: gg.rgb(68, 60, 59) + victory_color: gg.rgb(100, 160, 100) + game_over_color: gg.rgb(190, 50, 50) + text_color: gg.white tile_colors: [ - gx.rgb(123, 115, 108), - gx.rgb(142, 136, 130), - gx.rgb(142, 134, 120), - gx.rgb(145, 106, 72), - gx.rgb(147, 89, 59), - gx.rgb(147, 74, 57), - gx.rgb(147, 56, 35), - gx.rgb(142, 124, 68), - gx.rgb(142, 122, 58), - gx.rgb(142, 120, 48), - gx.rgb(142, 118, 37), - gx.rgb(142, 116, 27), + gg.rgb(123, 115, 108), + gg.rgb(142, 136, 130), + gg.rgb(142, 134, 120), + gg.rgb(145, 106, 72), + gg.rgb(147, 89, 59), + gg.rgb(147, 74, 57), + gg.rgb(147, 56, 35), + gg.rgb(142, 124, 68), + gg.rgb(142, 122, 58), + gg.rgb(142, 120, 48), + gg.rgb(142, 118, 37), + gg.rgb(142, 116, 27), ] }, &Theme{ - bg_color: gx.rgb(38, 38, 66) - padding_color: gx.rgb(58, 50, 74) - victory_color: gx.rgb(100, 160, 100) - game_over_color: gx.rgb(190, 50, 50) - text_color: gx.white + bg_color: gg.rgb(38, 38, 66) + padding_color: gg.rgb(58, 50, 74) + victory_color: gg.rgb(100, 160, 100) + game_over_color: gg.rgb(190, 50, 50) + text_color: gg.white tile_colors: [ - gx.rgb(92, 86, 140), - gx.rgb(106, 99, 169), - gx.rgb(106, 97, 156), - gx.rgb(108, 79, 93), - gx.rgb(110, 66, 76), - gx.rgb(110, 55, 74), - gx.rgb(110, 42, 45), - gx.rgb(106, 93, 88), - gx.rgb(106, 91, 75), - gx.rgb(106, 90, 62), - gx.rgb(106, 88, 48), - gx.rgb(106, 87, 35), + gg.rgb(92, 86, 140), + gg.rgb(106, 99, 169), + gg.rgb(106, 97, 156), + gg.rgb(108, 79, 93), + gg.rgb(110, 66, 76), + gg.rgb(110, 55, 74), + gg.rgb(110, 42, 45), + gg.rgb(106, 93, 88), + gg.rgb(106, 91, 75), + gg.rgb(106, 90, 62), + gg.rgb(106, 88, 48), + gg.rgb(106, 87, 35), ] }, ] @@ -518,32 +517,32 @@ fn (mut app App) ai_move() { app.move(bestprediction.move) } -fn (app &App) label_format(kind LabelKind) gx.TextCfg { +fn (app &App) label_format(kind LabelKind) gg.TextCfg { match kind { .keys { - return gx.TextCfg{ - color: gx.Color{150, 150, 255, 200} + return gg.TextCfg{ + color: gg.Color{150, 150, 255, 200} align: .center vertical_align: .bottom size: app.ui.font_size / 4 } } .points { - return gx.TextCfg{ - color: if app.state in [.over, .victory] { gx.white } else { app.theme.text_color } + return gg.TextCfg{ + color: if app.state in [.over, .victory] { gg.white } else { app.theme.text_color } align: .left size: app.ui.font_size / 2 } } .moves { - return gx.TextCfg{ - color: if app.state in [.over, .victory] { gx.white } else { app.theme.text_color } + return gg.TextCfg{ + color: if app.state in [.over, .victory] { gg.white } else { app.theme.text_color } align: .right size: app.ui.font_size / 2 } } .tile { - return gx.TextCfg{ + return gg.TextCfg{ color: app.theme.text_color align: .center vertical_align: .middle @@ -551,7 +550,7 @@ fn (app &App) label_format(kind LabelKind) gx.TextCfg { } } .victory { - return gx.TextCfg{ + return gg.TextCfg{ color: app.theme.victory_color align: .center vertical_align: .middle @@ -559,7 +558,7 @@ fn (app &App) label_format(kind LabelKind) gx.TextCfg { } } .game_over { - return gx.TextCfg{ + return gg.TextCfg{ color: app.theme.game_over_color align: .center vertical_align: .middle @@ -567,8 +566,8 @@ fn (app &App) label_format(kind LabelKind) gx.TextCfg { } } .score_end { - return gx.TextCfg{ - color: gx.white + return gg.TextCfg{ + color: gg.white align: .center vertical_align: .middle size: app.ui.font_size * 3 / 4 @@ -623,18 +622,18 @@ fn (app &App) draw() { app.draw_tiles() // TODO: Make transparency work in `gg` if app.state == .over { - app.gg.draw_rect_filled(0, 0, ww, wh, gx.rgba(10, 0, 0, 180)) + app.gg.draw_rect_filled(0, 0, ww, wh, gg.rgba(10, 0, 0, 180)) app.gg.draw_text(ww / 2, (m * 4 / 10) + ypad, 'Game Over', app.label_format(.game_over)) f := app.label_format(.tile) msg := $if android { 'Tap to restart' } $else { 'Press `r` to restart' } - app.gg.draw_text(ww / 2, (m * 6 / 10) + ypad, msg, gx.TextCfg{ + app.gg.draw_text(ww / 2, (m * 6 / 10) + ypad, msg, gg.TextCfg{ ...f - color: gx.white + color: gg.white size: f.size * 3 / 4 }) } if app.state == .victory { - app.gg.draw_rect_filled(0, 0, ww, wh, gx.rgba(0, 10, 0, 180)) + app.gg.draw_rect_filled(0, 0, ww, wh, gg.rgba(0, 10, 0, 180)) app.gg.draw_text(ww / 2, (m * 4 / 10) + ypad, 'Victory!', app.label_format(.victory)) // f := app.label_format(.tile) msg1 := $if android { 'Tap to continue' } $else { 'Press `space` to continue' } @@ -726,7 +725,7 @@ fn (app &App) draw_one_tile(x int, y int, tidx int) { xpos := xoffset + tw / 2 ypos := yoffset + th / 2 mut fmt := app.label_format(.tile) - fmt = gx.TextCfg{ + fmt = gg.TextCfg{ ...fmt size: int(anim_size * (fmt.size - 1)) } @@ -741,15 +740,15 @@ fn (app &App) draw_one_tile(x int, y int, tidx int) { app.gg.draw_text(xpos, ypos, '2', fmt) fs2 := int(f32(fmt.size) * 0.67) app.gg.draw_text(xpos + app.ui.tile_size / 10, ypos - app.ui.tile_size / 8, - '${tidx}', gx.TextCfg{ + '${tidx}', gg.TextCfg{ ...fmt size: fs2 - align: gx.HorizontalAlign.left + align: gg.HorizontalAlign.left }) } .shifts { fs2 := int(f32(fmt.size) * 0.6) - app.gg.draw_text(xpos, ypos, '2<<${tidx - 1}', gx.TextCfg{ + app.gg.draw_text(xpos, ypos, '2<<${tidx - 1}', gg.TextCfg{ ...fmt size: fs2 }) @@ -757,7 +756,7 @@ fn (app &App) draw_one_tile(x int, y int, tidx int) { .none {} // Don't draw any text here, colors only .end {} // Should never get here } - // oidx_fmt := gx.TextCfg{...fmt,size: 14} + // oidx_fmt := gg.TextCfg{...fmt,size: 14} // app.gg.draw_text(xoffset + 50, yoffset + 15, 'y:${oidx >> 16}|x:${oidx & 0xFFFF}|m:${app.mtickers[y][x]:5.3f}', oidx_fmt) // app.gg.draw_text(xoffset + 52, yoffset + 30, 'ox:${ox}|oy:${oy}', oidx_fmt) // app.gg.draw_text(xoffset + 52, yoffset + 85, 'dx:${dx}|dy:${dy}', oidx_fmt) diff --git a/examples/asteroids/asteroids.v b/examples/asteroids/asteroids.v index fe35736af..7a463fbcc 100644 --- a/examples/asteroids/asteroids.v +++ b/examples/asteroids/asteroids.v @@ -4,7 +4,6 @@ module main import gg -import gx import math import rand import os.asset @@ -86,8 +85,8 @@ mut: frames int text string size int = 40 - color gx.Color - align gx.HorizontalAlign = .center + color gg.Color + align gg.HorizontalAlign = .center } fn (mut a Asteroid) setup() { @@ -172,7 +171,7 @@ fn (mut game Game) update() { game.split_asteroid(a, p.vel.mul_scalar(0.5)) game.player.reset(game.screen) game.score += 50 - game.show_message(text: 'Your ship was destroyed.', color: gx.red, frames: 90) + game.show_message(text: 'Your ship was destroyed.', color: gg.red, frames: 90) game.ships-- if game.ships <= 0 { game.ships = 5 @@ -210,7 +209,7 @@ fn (mut game Game) update() { game.ships++ game.player.reset(game.screen) game.add_asteroids(10) - game.show_message(text: 'YOU WIN', color: gx.green, frames: 90) + game.show_message(text: 'YOU WIN', color: gg.green, frames: 90) } game.highscore = int_max(game.score, game.highscore) } @@ -247,21 +246,21 @@ fn (mut game Game) split_asteroid(a &Asteroid, vel V2) { fn (mut game Game) draw() { ws := gg.window_size() game.screen = V2{ws.width, ws.height} - game.gg.draw_rect_filled(0, 0, game.screen.x, game.screen.y, gx.rgba(20, 20, 20, 255)) + game.gg.draw_rect_filled(0, 0, game.screen.x, game.screen.y, gg.rgba(20, 20, 20, 255)) game.draw_ship() for b in game.bullets { - game.gg.draw_circle_filled(b.pos.x, b.pos.y, 3, gx.yellow) + game.gg.draw_circle_filled(b.pos.x, b.pos.y, 3, gg.yellow) } for mut a in game.asteroids { game.draw_asteroid(mut a) } scenter := game.screen.div_scalar(2) label1 := 'Level: ${game.level} Ships: ${game.ships}' - game.gg.draw_text(5, 10, label1, size: 20, color: gx.white, align: .left) + game.gg.draw_text(5, 10, label1, size: 20, color: gg.white, align: .left) label2 := 'B: ${game.player.bullets:02} F: ${game.player.fuel:04}' - game.gg.draw_text(int(scenter.x), 10, label2, size: 20, color: gx.green, align: .center) + game.gg.draw_text(int(scenter.x), 10, label2, size: 20, color: gg.green, align: .center) label3 := 'Score: ${game.score} Highscore: ${game.highscore}' - game.gg.draw_text(int(game.screen.x) - 5, 10, label3, size: 20, color: gx.white, align: .right) + game.gg.draw_text(int(game.screen.x) - 5, 10, label3, size: 20, color: gg.white, align: .right) if game.msg.frames > 0 { game.gg.draw_text(int(scenter.x), int(scenter.y / 2), game.msg.text, size: game.msg.size @@ -272,7 +271,7 @@ fn (mut game Game) draw() { label4 := 'Use arrows + space to control your ship. Use Escape to end the game.' game.gg.draw_text(int(game.screen.x - 5), int(game.screen.y - 20), label4, size: 16 - color: gx.gray + color: gg.gray align: .right ) } @@ -295,10 +294,10 @@ fn (game &Game) draw_ship() { p.points[5] = p3.y p.points[6] = p4.x p.points[7] = p4.y - game.gg.draw_convex_poly(p.points, gx.white) + game.gg.draw_convex_poly(p.points, gg.white) if p.is_engine_on { engine := p.pos.offset(angle + math.pi, 0.7 * p.radius) - game.gg.draw_circle_filled(engine.x, engine.y, 6, gx.yellow) + game.gg.draw_circle_filled(engine.x, engine.y, 6, gg.yellow) } } @@ -306,13 +305,13 @@ fn (mut game Game) draw_asteroid(mut a Asteroid) { if !a.active { return } - game.gg.draw_circle_filled(a.pos.x, a.pos.y, a.radius, gx.rgba(235, 235, 255, 215)) + game.gg.draw_circle_filled(a.pos.x, a.pos.y, a.radius, gg.rgba(235, 235, 255, 215)) for i in 0 .. a.segments { angle := rads(a.rotation + f32(i) * 360 / a.segments) p := a.pos.offset(angle, a.offsets[i]) a.points[i * 2], a.points[i * 2 + 1] = p.x, p.y } - game.gg.draw_convex_poly(a.points, gx.rgba(155, 155, 148, 245)) + game.gg.draw_convex_poly(a.points, gg.rgba(155, 155, 148, 245)) } fn (mut game Game) add_bullet() { diff --git a/examples/breakout/breakout.v b/examples/breakout/breakout.v index fab8375e6..3b484d1ae 100644 --- a/examples/breakout/breakout.v +++ b/examples/breakout/breakout.v @@ -1,5 +1,4 @@ import gg -import gx import math import rand import sokol.audio @@ -11,8 +10,8 @@ const designed_height = 800 const brick_width = 53 const brick_height = 20 const bevel_size = int(brick_height * 0.18) -const highlight_color = gx.rgba(255, 255, 255, 65) -const shade_color = gx.rgba(0, 0, 0, 65) +const highlight_color = gg.rgba(255, 255, 255, 65) +const shade_color = gg.rgba(0, 0, 0, 65) struct Brick { mut: @@ -108,7 +107,7 @@ fn (mut g Game) init_bricks() { g.bricks << Brick{ x: col * (brick_width + 1) + xoffset y: row * (brick_height + 1) + yoffset - c: gx.rgb(0x40 | rand.u8(), 0x40 | rand.u8(), 0x40 | rand.u8()) + c: gg.rgb(0x40 | rand.u8(), 0x40 | rand.u8(), 0x40 | rand.u8()) value: 10 - row } g.nbricks++ @@ -139,15 +138,15 @@ fn (mut g Game) draw() { } label1 := 'Level: ${g.nlevels:02} Points: ${g.npoints:06}' label2 := 'Bricks: ${g.nbricks:03} Paddles: ${g.npaddles:02}' - g.ctx.draw_text(5, 3, label1, size: 24, color: gx.rgb(255, 255, 255)) - g.ctx.draw_text(320, 3, label2, size: 24, color: gx.rgb(255, 255, 255)) + g.ctx.draw_text(5, 3, label1, size: 24, color: gg.rgb(255, 255, 255)) + g.ctx.draw_text(320, 3, label2, size: 24, color: gg.rgb(255, 255, 255)) sgl.pop_matrix() g.ctx.end() } fn (g &Game) draw_ball() { - g.ctx.draw_circle_filled(g.ball_x, g.ball_y, g.ball_r, gx.red) + g.ctx.draw_circle_filled(g.ball_x, g.ball_y, g.ball_r, gg.red) mut ball_r_less := g.ball_r for _ in 0 .. 3 { ball_r_less *= 0.8 @@ -158,10 +157,10 @@ fn (g &Game) draw_ball() { fn (g &Game) draw_paddle() { roffset, rradius := -5, 18 - g.ctx.draw_circle_filled(g.paddle_x - roffset, g.height, rradius, gx.blue) - g.ctx.draw_circle_filled(g.paddle_x + g.paddle_w + roffset, g.height, rradius, gx.blue) + g.ctx.draw_circle_filled(g.paddle_x - roffset, g.height, rradius, gg.blue) + g.ctx.draw_circle_filled(g.paddle_x + g.paddle_w + roffset, g.height, rradius, gg.blue) g.ctx.draw_rect_filled(g.paddle_x, g.height - g.paddle_h + 2, g.paddle_w, g.paddle_h, - gx.blue) + gg.blue) g.ctx.draw_rect_filled(g.paddle_x, g.height - g.paddle_h + 2, g.paddle_w, bevel_size, highlight_color) } diff --git a/examples/clock/clock.v b/examples/clock/clock.v index 2b568519d..59a106d02 100644 --- a/examples/clock/clock.v +++ b/examples/clock/clock.v @@ -3,7 +3,6 @@ // Written by Stefan Schroeder in 2021 for the v project examples. // See LICENSE for license information. import gg -import gx import math import time @@ -19,13 +18,13 @@ const th = 25 // Padding of tic-mark to window border const tp = 10 -const tic_color = gx.Color{ +const tic_color = gg.Color{ r: 50 g: 50 b: 50 } -const hand_color = gx.black -const second_hand_color = gx.red +const hand_color = gg.black +const second_hand_color = gg.red struct App { minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, @@ -85,7 +84,7 @@ fn on_frame(mut app App) { // Rotate a polygon round the centerpoint @[manualfree] -fn draw_convex_poly_rotate(mut ctx gg.Context, dpi_scale f32, points []f32, c gx.Color, angle f32) { +fn draw_convex_poly_rotate(mut ctx gg.Context, dpi_scale f32, points []f32, c gg.Color, angle f32) { sa := math.sin(math.pi * angle / 180.0) ca := math.cos(math.pi * angle / 180.0) @@ -151,7 +150,7 @@ fn main() { width: design_size height: design_size window_title: 'Clock!' - bg_color: gx.white + bg_color: gg.white user_data: app frame_fn: on_frame event_fn: on_event diff --git a/examples/fireworks/fireworks.v b/examples/fireworks/fireworks.v index 54a20f296..2f98cbd33 100644 --- a/examples/fireworks/fireworks.v +++ b/examples/fireworks/fireworks.v @@ -1,6 +1,5 @@ import objects import gg -import gx import rand struct App { @@ -99,7 +98,7 @@ fn main() { width: app.ui.width height: app.ui.height window_title: 'Fireworks!' - bg_color: gx.black + bg_color: gg.black user_data: app frame_fn: on_frame event_fn: on_event diff --git a/examples/fireworks/modules/objects/color.v b/examples/fireworks/modules/objects/color.v index 710f35636..db340f5e8 100644 --- a/examples/fireworks/modules/objects/color.v +++ b/examples/fireworks/modules/objects/color.v @@ -1,10 +1,10 @@ module objects -import gx +import gg import rand -pub fn random_color() gx.Color { - return gx.Color{ +pub fn random_color() gg.Color { + return gg.Color{ r: rand.u8() g: rand.u8() b: rand.u8() diff --git a/examples/fireworks/modules/objects/particle.v b/examples/fireworks/modules/objects/particle.v index 8370e54ae..8b2b46276 100644 --- a/examples/fireworks/modules/objects/particle.v +++ b/examples/fireworks/modules/objects/particle.v @@ -1,11 +1,10 @@ module objects import gg -import gx pub struct Particle { pub mut: - color gx.Color + color gg.Color pos Vector vel Vector accel Vector diff --git a/examples/fireworks/modules/objects/rocket.v b/examples/fireworks/modules/objects/rocket.v index 566b116a0..46e47c231 100644 --- a/examples/fireworks/modules/objects/rocket.v +++ b/examples/fireworks/modules/objects/rocket.v @@ -1,12 +1,11 @@ module objects import gg -import gx import rand pub struct Rocket { pub mut: - color gx.Color + color gg.Color pos Vector vel Vector accel Vector diff --git a/examples/game_of_life/life_gg.v b/examples/game_of_life/life_gg.v index cb416b31b..757e715f9 100644 --- a/examples/game_of_life/life_gg.v +++ b/examples/game_of_life/life_gg.v @@ -1,12 +1,11 @@ module main import gg -import gx import automaton const screen_width = 800 const screen_height = 600 -const filled_color = gx.blue +const filled_color = gg.blue @[live] fn print_automaton(app &App) { @@ -40,14 +39,14 @@ fn main() { a: automaton.gun() } app.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white frame_fn: frame user_data: &app width: screen_width height: screen_height create_window: true resizable: false - window_title: 'v life (with gg, gx)' + window_title: 'v life (with gg)' ) app.gg.run() } diff --git a/examples/gg/additive.v b/examples/gg/additive.v index 7e78bf758..5c79842d7 100644 --- a/examples/gg/additive.v +++ b/examples/gg/additive.v @@ -2,7 +2,6 @@ module main import os import gg -import gx import math @[heap] @@ -42,7 +41,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 60) y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 60) } - color: gx.Color{255, 0, 0, 255} + color: gg.Color{255, 0, 0, 255} effect: .add }) @@ -54,7 +53,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 80) y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 80) } - color: gx.Color{0, 255, 0, 255} + color: gg.Color{0, 255, 0, 255} effect: .add }) @@ -66,7 +65,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 100) y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 100) } - color: gx.Color{0, 0, 255, 255} + color: gg.Color{0, 0, 255, 255} effect: .add }) @@ -78,7 +77,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: 50 y: 0 } - color: gx.Color{255, 0, 0, 255} + color: gg.Color{255, 0, 0, 255} effect: .add }) @@ -89,7 +88,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: 50 y: 50 } - color: gx.Color{0, 255, 0, 255} + color: gg.Color{0, 255, 0, 255} effect: .add }) @@ -100,7 +99,7 @@ pub fn (mut window Window) draw(_ voidptr) { x: 50 y: 100 } - color: gx.Color{0, 0, 255, 255} + color: gg.Color{0, 0, 255, 255} effect: .add }) @@ -115,7 +114,7 @@ fn main() { width: 800 height: 600 user_data: window - bg_color: gx.gray + bg_color: gg.gray // FNs init_fn: window.init frame_fn: window.draw diff --git a/examples/gg/arcs_and_slices.v b/examples/gg/arcs_and_slices.v index c9301d5c4..fc0484a22 100644 --- a/examples/gg/arcs_and_slices.v +++ b/examples/gg/arcs_and_slices.v @@ -1,16 +1,15 @@ module main import gg -import gx import math const win_width = 700 const win_height = 800 -const bg_color = gx.white +const bg_color = gg.white // A transparent color is used to aid in verifying that // rendering is precise on each of the arc types (e.g. no overlapping or double rendered slices) -const colour = gx.rgba(100, 100, 0, 100) +const colour = gg.rgba(100, 100, 0, 100) enum Selection { segs = 0 diff --git a/examples/gg/bezier.v b/examples/gg/bezier.v index 27d679269..192d92931 100644 --- a/examples/gg/bezier.v +++ b/examples/gg/bezier.v @@ -1,7 +1,6 @@ module main import gg -import gx const points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0] @@ -14,7 +13,7 @@ mut: fn main() { mut app := &App{} app.gg = gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 600 height: 400 window_title: 'Cubic Bézier curve' @@ -31,8 +30,8 @@ fn (mut app App) change(delta int) { fn frame(mut app App) { app.gg.begin() - app.gg.draw_cubic_bezier_in_steps(points, u32(app.steps), gx.blue) - app.gg.draw_cubic_bezier_recursive(points, gx.rgba(255, 50, 50, 150)) + app.gg.draw_cubic_bezier_in_steps(points, u32(app.steps), gg.blue) + app.gg.draw_cubic_bezier_recursive(points, gg.rgba(255, 50, 50, 150)) app.gg.end() if app.gg.pressed_keys[int(gg.KeyCode.down)] { app.change(-1) diff --git a/examples/gg/bezier_anim.v b/examples/gg/bezier_anim.v index aff0f548c..b8b58ec0d 100644 --- a/examples/gg/bezier_anim.v +++ b/examples/gg/bezier_anim.v @@ -1,7 +1,6 @@ module main import gg -import gx const rate = f32(1) / 60 * 10 @@ -34,7 +33,7 @@ fn main() { anim: &Anim{} } app.gg = gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 600 height: 400 window_title: 'Animated cubic Bézier curve' @@ -61,7 +60,7 @@ fn frame(mut app App) { points := [p1_x, p1_y, ctrl_p1_x, ctrl_p1_y, ctrl_p2_x, ctrl_p2_y, p2_x, p2_y] app.gg.begin() - app.gg.draw_cubic_bezier(points, gx.blue) + app.gg.draw_cubic_bezier(points, gg.blue) app.gg.end() app.anim.advance() } diff --git a/examples/gg/cursor.v b/examples/gg/cursor.v index 13a813370..8ed10be7a 100644 --- a/examples/gg/cursor.v +++ b/examples/gg/cursor.v @@ -1,12 +1,11 @@ module main import gg -import gx import sokol.sapp fn main() { mut ctx := gg.new_context( - bg_color: gx.white + bg_color: gg.white window_title: 'Cursor' frame_fn: frame init_fn: init diff --git a/examples/gg/digital_rain.v b/examples/gg/digital_rain.v index 48c3639c0..6885cd740 100644 --- a/examples/gg/digital_rain.v +++ b/examples/gg/digital_rain.v @@ -2,7 +2,6 @@ module main import gg -import gx import rand import time @@ -37,7 +36,7 @@ fn main() { fn rain(mut app App) { app.ctx = gg.new_context( - bg_color: gx.rgb(0, 0, 0) + bg_color: gg.rgb(0, 0, 0) width: app.screen_size.width height: app.screen_size.height user_data: app @@ -84,7 +83,7 @@ fn frame(mut app App) { draw_rain_column(rc, app) } app.ctx.draw_text(app.screen_size.width / 2 - 190, app.screen_size.height - 15, 'press `f` to toggle fullscreen, Up/Down arrows to change speed', - color: gx.gray + color: gg.gray ) app.ctx.end() vprintln('frame: ${app.ctx.frame} | app.cols: ${app.cols} | app.rows: ${app.rows} | app.rain_columns.len: ${app.rain_columns.len} | app.delay: ${app.delay}') @@ -98,9 +97,9 @@ fn vprintln(msg string) { fn calc_sizes(mut app App) { app.screen_size = gg.window_size() - app.ctx.set_text_cfg(gx.TextCfg{ + app.ctx.set_text_cfg(gg.TextCfg{ size: font_size - color: gx.green + color: gg.green mono: true }) // figure out how big character is in pixels @@ -138,7 +137,7 @@ fn draw_rain_column(rc RainColumn, app App) { else { u8(255) } } at_head := i == rc.head - 1 - cfg := gx.TextCfg{ + cfg := gg.TextCfg{ size: font_size color: gg.Color{ r: if at_head { u8(255) } else { 0 } diff --git a/examples/gg/drag_n_drop.v b/examples/gg/drag_n_drop.v index 844ce97b1..2e4b27746 100644 --- a/examples/gg/drag_n_drop.v +++ b/examples/gg/drag_n_drop.v @@ -1,7 +1,6 @@ module main import gg -import gx import sokol.sapp const max_files = 12 @@ -16,7 +15,7 @@ mut: fn main() { mut app := &App{} app.gg = gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 600 height: 400 window_title: 'Drag and drop' @@ -45,8 +44,8 @@ fn my_event_manager(mut ev gg.Event, mut app App) { fn frame(mut app App) { app.gg.begin() - mut txt_conf := gx.TextCfg{ - color: gx.black + mut txt_conf := gg.TextCfg{ + color: gg.black align: .left size: int(text_size * app.gg.scale + 0.5) } diff --git a/examples/gg/draw_pixels.v b/examples/gg/draw_pixels.v index 0e7562e9e..e99f02d46 100644 --- a/examples/gg/draw_pixels.v +++ b/examples/gg/draw_pixels.v @@ -1,7 +1,6 @@ module main import gg -import gx struct App { mut: @@ -28,7 +27,7 @@ fn main() { pixels: pixels } app.gg = gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 100 height: 100 window_title: 'Set Pixels' @@ -42,12 +41,12 @@ fn frame(mut app App) { app.gg.begin() // Draw a blue pixel near each corner. (Find your magnifying glass) - app.gg.draw_pixel(2, 2, gx.blue) - app.gg.draw_pixel(app.gg.width - 2, 2, gx.blue) - app.gg.draw_pixel(app.gg.width - 2, app.gg.height - 2, gx.blue) - app.gg.draw_pixel(2, app.gg.height - 2, gx.blue) + app.gg.draw_pixel(2, 2, gg.blue) + app.gg.draw_pixel(app.gg.width - 2, 2, gg.blue) + app.gg.draw_pixel(app.gg.width - 2, app.gg.height - 2, gg.blue) + app.gg.draw_pixel(2, app.gg.height - 2, gg.blue) // Draw pixels in a grid-like pattern. - app.gg.draw_pixels(app.pixels, gx.red) + app.gg.draw_pixels(app.pixels, gg.red) app.gg.end() } diff --git a/examples/gg/easing_animation.v b/examples/gg/easing_animation.v index 380bbe698..693382ac3 100644 --- a/examples/gg/easing_animation.v +++ b/examples/gg/easing_animation.v @@ -1,7 +1,6 @@ module main import gg -import gx import math.easing const all = { @@ -60,8 +59,8 @@ mut: fn (mut app App) draw_circle(label string, f easing.EasingFN) { offset := 30 app.gg.draw_text_def(int(app.x) - 30, 5, label) - app.gg.draw_line(f32(app.x), offset, f32(app.x), f32(app.h + offset), gx.gray) - app.gg.draw_circle_filled(f32(app.x), f32(offset + f(app.t) * app.h), 10, gx.rgb(0, + app.gg.draw_line(f32(app.x), offset, f32(app.x), f32(app.h + offset), gg.gray) + app.gg.draw_circle_filled(f32(app.x), f32(offset + f(app.t) * app.h), 10, gg.rgb(0, 0, 255)) app.x += 120 } @@ -73,7 +72,7 @@ fn (mut app App) frame() { app.x = 80 app.h = size.height - 100 app.gg.begin() - app.gg.draw_line(0, f32(app.h + 30), size.width, f32(app.h + 30), gx.gray) + app.gg.draw_line(0, f32(app.h + 30), size.width, f32(app.h + 30), gg.gray) current_map := unsafe { all[app.kind].clone() } for k, e in current_map { app.draw_circle(k, e) @@ -100,7 +99,7 @@ fn (mut app App) on_event(ev &gg.Event, x voidptr) { mut app := &App{} app.gg = gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 1350 height: 800 window_title: 'Easing functions' diff --git a/examples/gg/fire.v b/examples/gg/fire.v index a95325b74..d41c95ce3 100644 --- a/examples/gg/fire.v +++ b/examples/gg/fire.v @@ -1,6 +1,5 @@ // Use `v -d show_fps run examples/gg/fire.v` to show a fire effect with an FPS counter. import gg -import gx import rand const win_width = 800 @@ -9,43 +8,43 @@ const width = 100 const height = 140 const scale = 4 const palette = [ - gx.rgb(0x07, 0x07, 0x07), - gx.rgb(0x1f, 0x07, 0x07), - gx.rgb(0x2f, 0x0f, 0x07), - gx.rgb(0x47, 0x0f, 0x07), - gx.rgb(0x57, 0x17, 0x07), - gx.rgb(0x67, 0x1f, 0x07), - gx.rgb(0x77, 0x1f, 0x07), - gx.rgb(0x8f, 0x27, 0x07), - gx.rgb(0x9f, 0x2f, 0x07), - gx.rgb(0xaf, 0x3f, 0x07), - gx.rgb(0xbf, 0x47, 0x07), - gx.rgb(0xc7, 0x47, 0x07), - gx.rgb(0xdf, 0x4f, 0x07), - gx.rgb(0xdf, 0x57, 0x07), - gx.rgb(0xdf, 0x57, 0x07), - gx.rgb(0xd7, 0x5f, 0x07), - gx.rgb(0xd7, 0x5f, 0x07), - gx.rgb(0xd7, 0x67, 0x0f), - gx.rgb(0xcf, 0x6f, 0x0f), - gx.rgb(0xcf, 0x77, 0x0f), - gx.rgb(0xcf, 0x7f, 0x0f), - gx.rgb(0xcf, 0x87, 0x17), - gx.rgb(0xc7, 0x87, 0x17), - gx.rgb(0xc7, 0x8f, 0x17), - gx.rgb(0xc7, 0x97, 0x1f), - gx.rgb(0xbf, 0x9f, 0x1f), - gx.rgb(0xbf, 0x9f, 0x1f), - gx.rgb(0xbf, 0xa7, 0x27), - gx.rgb(0xbf, 0xa7, 0x27), - gx.rgb(0xbf, 0xaf, 0x2f), - gx.rgb(0xb7, 0xaf, 0x2f), - gx.rgb(0xb7, 0xb7, 0x2f), - gx.rgb(0xb7, 0xb7, 0x37), - gx.rgb(0xcf, 0xcf, 0x6f), - gx.rgb(0xdf, 0xdf, 0x9f), - gx.rgb(0xef, 0xef, 0xc7), - gx.rgb(0xff, 0xff, 0xff), + gg.rgb(0x07, 0x07, 0x07), + gg.rgb(0x1f, 0x07, 0x07), + gg.rgb(0x2f, 0x0f, 0x07), + gg.rgb(0x47, 0x0f, 0x07), + gg.rgb(0x57, 0x17, 0x07), + gg.rgb(0x67, 0x1f, 0x07), + gg.rgb(0x77, 0x1f, 0x07), + gg.rgb(0x8f, 0x27, 0x07), + gg.rgb(0x9f, 0x2f, 0x07), + gg.rgb(0xaf, 0x3f, 0x07), + gg.rgb(0xbf, 0x47, 0x07), + gg.rgb(0xc7, 0x47, 0x07), + gg.rgb(0xdf, 0x4f, 0x07), + gg.rgb(0xdf, 0x57, 0x07), + gg.rgb(0xdf, 0x57, 0x07), + gg.rgb(0xd7, 0x5f, 0x07), + gg.rgb(0xd7, 0x5f, 0x07), + gg.rgb(0xd7, 0x67, 0x0f), + gg.rgb(0xcf, 0x6f, 0x0f), + gg.rgb(0xcf, 0x77, 0x0f), + gg.rgb(0xcf, 0x7f, 0x0f), + gg.rgb(0xcf, 0x87, 0x17), + gg.rgb(0xc7, 0x87, 0x17), + gg.rgb(0xc7, 0x8f, 0x17), + gg.rgb(0xc7, 0x97, 0x1f), + gg.rgb(0xbf, 0x9f, 0x1f), + gg.rgb(0xbf, 0x9f, 0x1f), + gg.rgb(0xbf, 0xa7, 0x27), + gg.rgb(0xbf, 0xa7, 0x27), + gg.rgb(0xbf, 0xaf, 0x2f), + gg.rgb(0xb7, 0xaf, 0x2f), + gg.rgb(0xb7, 0xb7, 0x2f), + gg.rgb(0xb7, 0xb7, 0x37), + gg.rgb(0xcf, 0xcf, 0x6f), + gg.rgb(0xdf, 0xdf, 0x9f), + gg.rgb(0xef, 0xef, 0xc7), + gg.rgb(0xff, 0xff, 0xff), ]! struct App { diff --git a/examples/gg/mandelbrot.v b/examples/gg/mandelbrot.v index 1e27705bd..8f76ca719 100644 --- a/examples/gg/mandelbrot.v +++ b/examples/gg/mandelbrot.v @@ -1,5 +1,4 @@ import gg -import gx import runtime import time @@ -40,8 +39,8 @@ mut: ntasks int = runtime.nr_jobs() } -const colors = [gx.black, gx.blue, gx.red, gx.green, gx.yellow, gx.orange, gx.purple, gx.white, - gx.indigo, gx.violet, gx.black, gx.blue, gx.orange, gx.yellow, gx.green].map(u32(it.abgr8())) +const colors = [gg.black, gg.blue, gg.red, gg.green, gg.yellow, gg.orange, gg.purple, gg.white, + gg.indigo, gg.violet, gg.black, gg.blue, gg.orange, gg.yellow, gg.green].map(u32(it.abgr8())) struct MandelChunk { cview ViewRect diff --git a/examples/gg/many_thousands_of_circles.v b/examples/gg/many_thousands_of_circles.v index 196b68e42..80efded23 100644 --- a/examples/gg/many_thousands_of_circles.v +++ b/examples/gg/many_thousands_of_circles.v @@ -1,13 +1,12 @@ module main import gg -import gx import rand const max_circles_per_pass = 1000 // prepare some random colors ahead of time -const colors = []gx.Color{len: max_circles_per_pass, init: gx.Color{ +const colors = []gg.Color{len: max_circles_per_pass, init: gg.Color{ r: u8(index * 0 + rand.u8()) g: u8(index * 0 + rand.u8()) b: u8(index * 0 + rand.u8()) @@ -47,7 +46,7 @@ fn frame(mut ctx gg.Context) { fn main() { mut ctx := gg.new_context( window_title: 'Many Thousands of Circles' - bg_color: gx.black + bg_color: gg.black width: 600 height: 400 frame_fn: frame diff --git a/examples/gg/memory.v b/examples/gg/memory.v index 720b6c7fc..ed724c8ff 100644 --- a/examples/gg/memory.v +++ b/examples/gg/memory.v @@ -1,11 +1,10 @@ module main import gg -import gx import rand import time -const cover = gx.rgba(85, 200, 85, 255) +const cover = gg.rgba(85, 200, 85, 255) const csize = 120 // cell size in pixels const letters = 'AABBOOCCVVXXYYZZMMKKHHTT'.split('') const header_size = 30 @@ -45,9 +44,9 @@ fn (mut g Game) draw_cell(i int, cell Cell) { rect_x, rect_y := x * csize, header_size + y * csize if g.cells[i].is_open || g.sw.elapsed().milliseconds() <= 1000 { lsize := 96 - g.ctx.draw_rect_empty(rect_x + 6, rect_y + 6, csize - 10, csize - 10, gx.light_gray) + g.ctx.draw_rect_empty(rect_x + 6, rect_y + 6, csize - 10, csize - 10, gg.light_gray) g.ctx.draw_text(rect_x + csize / 2 - lsize / 3, rect_y + csize / 2 - lsize / 2, - g.cells[i].letter, color: gx.yellow, size: lsize) + g.cells[i].letter, color: gg.yellow, size: lsize) } else { g.ctx.draw_rect_filled(rect_x + 6, rect_y + 6, csize - 10, csize - 10, cover) } @@ -57,7 +56,7 @@ fn on_frame(mut g Game) { ws := gg.window_size() g.ctx.begin() message := '(r)estart (esc)ape | remaining: ${g.remaining:02} | time: ${f64(g.sw.elapsed().milliseconds()) / 1000.0:06.1f}s' - g.ctx.draw_text(ws.width / 2, 7, message, color: gx.light_gray, size: 22, align: .center) + g.ctx.draw_text(ws.width / 2, 7, message, color: gg.light_gray, size: 22, align: .center) for i, cell in g.cells { g.draw_cell(i, cell) } @@ -123,7 +122,7 @@ mut g := &Game{ } g.restart() g.ctx = gg.new_context( - bg_color: gx.black + bg_color: gg.black width: g.size * csize height: header_size + g.size * csize window_title: 'V Memory ${g.size} x ${g.size}' diff --git a/examples/gg/minesweeper.v b/examples/gg/minesweeper.v index 457425b25..f1ab25900 100644 --- a/examples/gg/minesweeper.v +++ b/examples/gg/minesweeper.v @@ -1,7 +1,6 @@ module main import gg -import gx import rand import os.asset @@ -172,23 +171,23 @@ fn (mut g Game) draw_cell(y int, x int) { rect_x, rect_y := x * g.csize, y * g.csize if g.revealed[y][x] { if g.grid[y][x] == .mine { - g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gx.red) - g.ctx.draw_text(rect_x + 10, o + rect_y + 5, '*', color: gx.black) + g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gg.red) + g.ctx.draw_text(rect_x + 10, o + rect_y + 5, '*', color: gg.black) } else if int(g.grid[y][x]) > 0 { - g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gx.light_gray) + g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gg.light_gray) n := int(g.grid[y][x]).str() - g.ctx.draw_text(rect_x + 10, o + rect_y + 5, n, color: gx.black) + g.ctx.draw_text(rect_x + 10, o + rect_y + 5, n, color: gg.black) } else { - c := gx.rgb(240, 240, 240) + c := gg.rgb(240, 240, 240) g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, c) } } else if g.flags[y][x] { - g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gx.gray) - g.ctx.draw_text(rect_x + 10, o + rect_y + 5, 'F', color: gx.white) + g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gg.gray) + g.ctx.draw_text(rect_x + 10, o + rect_y + 5, 'F', color: gg.white) } else { - g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gx.gray) + g.ctx.draw_rect_filled(rect_x, o + rect_y, g.csize, g.csize, gg.gray) } - g.ctx.draw_rect_empty(rect_x, o + rect_y, g.csize, g.csize, gx.black) + g.ctx.draw_rect_empty(rect_x, o + rect_y, g.csize, g.csize, gg.black) } fn on_frame(mut g Game) { @@ -199,7 +198,7 @@ fn on_frame(mut g Game) { } } message := 'Flagged: ${g.mines_flagged:02}/${g.mines:02} (r)estart (ESC)ape' - g.ctx.draw_text(5, 7, message, color: gx.green) + g.ctx.draw_text(5, 7, message, color: gg.green) g.ctx.end() } @@ -207,7 +206,7 @@ fn main() { mut g := &Game{} g.restart() g.ctx = gg.new_context( - bg_color: gx.black + bg_color: gg.black width: g.size * g.csize height: header_size + g.size * g.csize window_title: 'V Minesweeper' diff --git a/examples/gg/path_finding_algorithm_visualizer/aStar.v b/examples/gg/path_finding_algorithm_visualizer/aStar.v index 0bd5fa9a8..b3a5a911a 100644 --- a/examples/gg/path_finding_algorithm_visualizer/aStar.v +++ b/examples/gg/path_finding_algorithm_visualizer/aStar.v @@ -1,7 +1,6 @@ module main import gg // actual graphics lib -import gx // lib have some constants like colors import math // for math related function const window_width = 800 @@ -48,7 +47,7 @@ mut: col int width int pos Point - color gx.Color + color gg.Color flag int // 0->empty, 1-> closed, 2-> open, 3-> barrier, 4-> start, 5-> end, 6-> path neighbors []Point } @@ -76,7 +75,7 @@ fn main() { // setting values of app app.gg = gg.new_context( - bg_color: gx.black // background color + bg_color: gg.black // background color width: window_width // window width height: window_height // window height create_window: true // this will create a different window @@ -217,9 +216,9 @@ fn draw_gridlines(mut app App) { dy := window_height / nrows for i := 0; i < nrows; i++ { // horizontal lines - app.gg.draw_line(0, i * dy, window_width, i * dy, gx.black) + app.gg.draw_line(0, i * dy, window_width, i * dy, gg.black) // vertical lines - app.gg.draw_line(i * dx, 0, dx * i, window_height, gx.black) + app.gg.draw_line(i * dx, 0, dx * i, window_height, gg.black) } } @@ -251,7 +250,7 @@ fn initialise_grid() [][]Cell { x: j * gap y: i * gap } - color: gx.white + color: gg.white flag: 0 } } @@ -378,31 +377,31 @@ fn astar_path_finding(mut app App, mut grid [][]Cell, start Point, end Point) { fn set_cell_type(mut grid [][]Cell, row int, col int, typ string) { match typ { 'reset' { - grid[row][col].color = gx.white + grid[row][col].color = gg.white grid[row][col].flag = 0 } 'close' { - grid[row][col].color = gx.red + grid[row][col].color = gg.red grid[row][col].flag = 1 } 'open' { - grid[row][col].color = gx.green + grid[row][col].color = gg.green grid[row][col].flag = 2 } 'barrier' { - grid[row][col].color = gx.black + grid[row][col].color = gg.black grid[row][col].flag = 3 } 'start' { - grid[row][col].color = gx.orange + grid[row][col].color = gg.orange grid[row][col].flag = 4 } 'end' { - grid[row][col].color = gx.blue + grid[row][col].color = gg.blue grid[row][col].flag = 5 } 'path' { - grid[row][col].color = gx.pink + grid[row][col].color = gg.pink grid[row][col].flag = 6 } else {} diff --git a/examples/gg/polygons.v b/examples/gg/polygons.v index ddf58f6dd..b19c49898 100644 --- a/examples/gg/polygons.v +++ b/examples/gg/polygons.v @@ -1,11 +1,10 @@ module main import gg -import gx fn main() { mut context := gg.new_context( - bg_color: gx.rgb(174, 198, 255) + bg_color: gg.rgb(174, 198, 255) width: 600 height: 400 window_title: 'Polygons' @@ -17,8 +16,8 @@ fn main() { fn frame(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], - gx.blue) - ctx.draw_poly_empty([f32(50.0), 50.0, 70.0, 60.0, 90.0, 80.0, 70.0, 110.0], gx.black) - ctx.draw_triangle_filled(450, 142, 530, 280, 370, 280, gx.red) + 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() } diff --git a/examples/gg/raven_text_rendering.v b/examples/gg/raven_text_rendering.v index 9e145fa38..b07b0075c 100644 --- a/examples/gg/raven_text_rendering.v +++ b/examples/gg/raven_text_rendering.v @@ -1,13 +1,12 @@ module main import gg -import gx import os.asset import math const win_width = 600 const win_height = 700 -const bg_color = gx.white +const bg_color = gg.white const text = ' Once upon a midnight dreary, while I pondered, weak and weary, @@ -84,7 +83,7 @@ fn frame(mut app App) { if scale_factor <= 0 { scale_factor = 1 } - text_cfg := gx.TextCfg{ + text_cfg := gg.TextCfg{ size: 16 * int(scale_factor) } mut y := 10 diff --git a/examples/gg/raycaster.v b/examples/gg/raycaster.v index 28078f78f..3c04a360e 100644 --- a/examples/gg/raycaster.v +++ b/examples/gg/raycaster.v @@ -12,7 +12,6 @@ // learn more on how this code works. There are some silly // digressons in the video but the tech content is spot on. import gg -import gx import math const player_size = 8 @@ -59,7 +58,7 @@ fn main() { window_title: 'Raycaster Demo' width: 1024 height: 512 - bg_color: gx.gray + bg_color: gg.gray frame_fn: draw event_fn: handle_events ) @@ -79,7 +78,7 @@ fn draw(mut app App) { fn draw_map_2d(app App) { for y := 0; y < map_y_size; y++ { for x := 0; x < map_x_size; x++ { - color := if app.map[y * map_x_size + x] == 1 { gx.white } else { gx.black } + color := if app.map[y * map_x_size + x] == 1 { gg.white } else { gg.black } app.ctx.draw_rect_filled(x * map_square, y * map_square, map_square - 1, map_square - 1, color) } @@ -87,10 +86,10 @@ fn draw_map_2d(app App) { } fn draw_player(app App) { - app.ctx.draw_rect_filled(app.player_x, app.player_y, player_size, player_size, gx.yellow) + app.ctx.draw_rect_filled(app.player_x, app.player_y, player_size, player_size, gg.yellow) cx := app.player_x + player_size / 2 cy := app.player_y + player_size / 2 - app.ctx.draw_line(cx, cy, cx + app.player_dx * 5, cy + app.player_dy * 5, gx.yellow) + app.ctx.draw_line(cx, cy, cx + app.player_dx * 5, cy + app.player_dy * 5, gg.yellow) } fn draw_rays_and_walls(app App) { @@ -109,7 +108,7 @@ fn draw_rays_and_walls(app App) { mut map_x := 0 mut map_y := 0 mut map_pos := 0 - mut color := gx.red + mut color := gg.red mut ray_angle := clamp_ray_angle(app.player_angle - degree_radian * field_of_view / 2) // each step = 1/2 degree @@ -196,17 +195,17 @@ fn draw_rays_and_walls(app App) { ray_x = vx ray_y = vy distance = vd - color = gx.rgb(0, 100, 0) + color = gg.rgb(0, 100, 0) } else if hd < vd { ray_x = hx ray_y = hy distance = hd - color = gx.rgb(0, 120, 0) + color = gg.rgb(0, 120, 0) } // draw ray cx := app.player_x + player_size / 2 cy := app.player_y + player_size / 2 - app.ctx.draw_line(cx, cy, ray_x, ray_y, gx.green) + app.ctx.draw_line(cx, cy, ray_x, ray_y, gg.green) // draw wall section mut ca := clamp_ray_angle(app.player_angle - ray_angle) distance *= math.cosf(ca) // remove fish eye diff --git a/examples/gg/rectangles.v b/examples/gg/rectangles.v index 1211a6cea..ec9950836 100644 --- a/examples/gg/rectangles.v +++ b/examples/gg/rectangles.v @@ -1,7 +1,6 @@ module main import gg -import gx import os.asset const win_width = 600 @@ -16,7 +15,7 @@ mut: fn main() { mut app := &App{} app.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white width: win_width height: win_height create_window: true @@ -38,7 +37,7 @@ fn frame(app &App) { fn (app &App) draw() { // app.gg.draw_text_def(200,20, 'hello world!') // app.gg.draw_text_def(300,300, 'привет') - app.gg.draw_rect_filled(10, 10, 100, 30, gx.blue) - app.gg.draw_rect_empty(110, 150, 80, 40, gx.black) + app.gg.draw_rect_filled(10, 10, 100, 30, gg.blue) + app.gg.draw_rect_empty(110, 150, 80, 40, gg.black) app.gg.draw_image_by_id(230, 30, 200, 200, app.image) } diff --git a/examples/gg/rotating_textured_quad.v b/examples/gg/rotating_textured_quad.v index a550fff9c..46282f8c4 100644 --- a/examples/gg/rotating_textured_quad.v +++ b/examples/gg/rotating_textured_quad.v @@ -1,5 +1,4 @@ import gg -import gx import os.asset import sokol.sgl @@ -45,7 +44,7 @@ fn main() { mut window := &Window{} window.ctx = gg.new_context( window_title: 'Rotating V logo' - bg_color: gx.light_green + bg_color: gg.light_green width: 500 height: 500 user_data: window diff --git a/examples/gg/sample_count.v b/examples/gg/sample_count.v index 87657d3eb..4fa8c56de 100644 --- a/examples/gg/sample_count.v +++ b/examples/gg/sample_count.v @@ -1,24 +1,23 @@ module main import gg -import gx import os fn main() { scount := os.args[1] or { '2' }.int() println('> sample count: ${scount}') mut ctx := gg.new_context( - bg_color: gx.white + bg_color: gg.white window_title: 'sample_count: ${scount}' width: 320 height: 240 sample_count: scount frame_fn: fn (mut ctx gg.Context) { ctx.begin() - ctx.draw_rounded_rect_empty(110, 70, 100, 100, 10, gx.blue) - ctx.draw_circle_empty(160, 120, 100, gx.red) - ctx.draw_triangle_empty(160, 93, 186, 138, 132, 138, gx.green) - ctx.draw_rect_filled(159, 119, 2, 2, gx.black) + ctx.draw_rounded_rect_empty(110, 70, 100, 100, 10, gg.blue) + ctx.draw_circle_empty(160, 120, 100, gg.red) + ctx.draw_triangle_empty(160, 93, 186, 138, 132, 138, gg.green) + ctx.draw_rect_filled(159, 119, 2, 2, gg.black) ctx.end() } ) diff --git a/examples/gg/stars.v b/examples/gg/stars.v index 0c5839099..eb112d751 100644 --- a/examples/gg/stars.v +++ b/examples/gg/stars.v @@ -2,7 +2,6 @@ module main import os.asset import gg -import gx import rand import sokol.sgl @@ -47,7 +46,7 @@ fn main() { v_letters: []VLetter{len: max_v_letters} } app.gg = gg.new_context( - bg_color: gx.black + bg_color: gg.black width: win_width height: win_height create_window: true diff --git a/examples/gg/worker_thread.v b/examples/gg/worker_thread.v index bb526d9ac..4e7b913cd 100644 --- a/examples/gg/worker_thread.v +++ b/examples/gg/worker_thread.v @@ -5,14 +5,13 @@ module main // Example of how to send a value through a channel from a worker thread to the main/rendering thread. // This can be useful to do long running computations while keeping your framerate high (60 fps in this example). import gg -import gx import math import time const win_width = 600 const win_height = 700 -const bg_color = gx.white -const count_color = gx.black +const bg_color = gg.white +const count_color = gg.black struct App { mut: @@ -62,7 +61,7 @@ fn frame(mut app App) { if scale_factor <= 0 { scale_factor = 1 } - text_cfg := gx.TextCfg{ + text_cfg := gg.TextCfg{ size: 64 * int(scale_factor) } diff --git a/examples/hot_reload/bounce.v b/examples/hot_reload/bounce.v index 3cc28bd70..d9c22e704 100644 --- a/examples/hot_reload/bounce.v +++ b/examples/hot_reload/bounce.v @@ -2,7 +2,6 @@ // v -live bounce.v module main -import gx import gg import time @@ -38,7 +37,7 @@ fn main() { window_title: 'Hot code reloading demo' create_window: true frame_fn: frame - bg_color: gx.white + bg_color: gg.white ) // window.onkeydown(key_down) println('Starting the game loop...') @@ -52,10 +51,10 @@ fn main() { fn frame(mut game Game) { game.gg.begin() game.gg.draw_text_def(10, 5, 'Modify examples/hot_reload/bounce.v to get instant updates') - game.gg.draw_rect_filled(game.x, game.y, width, width, gx.blue) + game.gg.draw_rect_filled(game.x, game.y, width, width, gg.blue) game.gg.draw_rect_filled(window_width - width - game.x + 10, 200 - game.y + width, - width, width, gx.rgb(228, 10, 55)) - game.gg.draw_rect_filled(game.x - 25, 250 - game.y, width, width, gx.rgb(28, 240, + width, width, gg.rgb(228, 10, 55)) + game.gg.draw_rect_filled(game.x - 25, 250 - game.y, width, width, gg.rgb(28, 240, 55)) game.gg.end() } diff --git a/examples/hot_reload/graph.v b/examples/hot_reload/graph.v index 067041521..3200364a1 100644 --- a/examples/hot_reload/graph.v +++ b/examples/hot_reload/graph.v @@ -1,6 +1,5 @@ module main -import gx import gg import time import math @@ -24,7 +23,7 @@ fn main() { create_window: true frame_fn: frame resizable: true - bg_color: gx.white + bg_color: gg.white ) context.gg.run() } @@ -44,17 +43,17 @@ fn (ctx &Context) draw() { w /= 2 h /= 2 } - ctx.gg.draw_line(0, h / 2, w, h / 2, gx.gray) // x axis - ctx.gg.draw_line(w / 2, 0, w / 2, h, gx.gray) // y axis + ctx.gg.draw_line(0, h / 2, w, h / 2, gg.gray) // x axis + ctx.gg.draw_line(w / 2, 0, w / 2, h, gg.gray) // y axis atime := f64(time.ticks() / 10) stime := math.sin(2.0 * math.pi * f64(time.ticks() % 6000) / 6000) mut y := 0.0 - blue := gx.Color{ + blue := gg.Color{ r: 100 g: 100 b: 200 } - red := gx.Color{ + red := gg.Color{ r: 200 g: 100 b: 100 diff --git a/examples/pendulum-simulation/modules/sim/anim/app.v b/examples/pendulum-simulation/modules/sim/anim/app.v index a3c8de0ee..a73a4b55e 100644 --- a/examples/pendulum-simulation/modules/sim/anim/app.v +++ b/examples/pendulum-simulation/modules/sim/anim/app.v @@ -1,16 +1,15 @@ module anim import gg -import gx import sim import sim.args as simargs -const bg_color = gx.white +const bg_color = gg.white struct Pixel { x f32 y f32 - color gx.Color + color gg.Color } pub struct App { diff --git a/examples/pendulum-simulation/modules/sim/img/ppm.v b/examples/pendulum-simulation/modules/sim/img/ppm.v index 080811772..2f86f3a3a 100644 --- a/examples/pendulum-simulation/modules/sim/img/ppm.v +++ b/examples/pendulum-simulation/modules/sim/img/ppm.v @@ -1,6 +1,6 @@ module img -import gx +import gg import os import sim @@ -53,7 +53,7 @@ pub fn (mut writer PPMWriter) start_for_file(fname string, settings ImageSetting writer.file.writeln('P6 ${settings.width} ${settings.height} 255')! } -pub fn (mut writer PPMWriter) handle_pixel(p gx.Color) ! { +pub fn (mut writer PPMWriter) handle_pixel(p gg.Color) ! { if writer.cache.len >= writer.cache_size { writer.write()! writer.flush()! diff --git a/examples/pendulum-simulation/modules/sim/img/writer.v b/examples/pendulum-simulation/modules/sim/img/writer.v index 6661f2b92..a32029756 100644 --- a/examples/pendulum-simulation/modules/sim/img/writer.v +++ b/examples/pendulum-simulation/modules/sim/img/writer.v @@ -1,10 +1,10 @@ module img -import gx +import gg import sim pub struct ValidColor { - gx.Color + gg.Color pub mut: valid bool } @@ -52,17 +52,17 @@ pub fn (mut iw ImageWriter) handle(result sim.SimResult) !int { return iw.current_index } -pub fn compute_pixel(result sim.SimResult) gx.Color { +pub fn compute_pixel(result sim.SimResult) gg.Color { closest_to_m1 := result.magnet1_distance < result.magnet2_distance && result.magnet1_distance < result.magnet3_distance closest_to_m2 := result.magnet2_distance < result.magnet1_distance && result.magnet2_distance < result.magnet3_distance if closest_to_m1 { - return gx.red + return gg.red } else if closest_to_m2 { - return gx.green + return gg.green } else { - return gx.blue + return gg.blue } } diff --git a/examples/quadtree_demo/quadtree_demo.v b/examples/quadtree_demo/quadtree_demo.v index c2f34e762..45cea66e6 100644 --- a/examples/quadtree_demo/quadtree_demo.v +++ b/examples/quadtree_demo/quadtree_demo.v @@ -2,7 +2,6 @@ module main import datatypes import gg -import gx import time import math import rand @@ -11,12 +10,12 @@ const win_width = 1340 const win_height = 640 const timer_period = 40 * time.millisecond // defaulted at 25 fps -const font_small = gx.TextCfg{ - color: gx.black +const font_small = gg.TextCfg{ + color: gg.black size: 20 } -const font_large = gx.TextCfg{ - color: gx.black +const font_large = gg.TextCfg{ + color: gg.black size: 40 } @@ -114,7 +113,7 @@ fn main() { gg: unsafe { nil } } app.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white width: win_width height: win_height create_window: true @@ -159,19 +158,19 @@ fn frame(app &App) { fn (app &App) display() { for player in app.players { app.gg.draw_rect_filled(f32(player.x), f32(player.y), f32(player.width), f32(player.height), - gx.black) + gg.black) } for particle in app.particles { app.gg.draw_rect_empty(f32(particle.pmt.x), f32(particle.pmt.y), f32(particle.pmt.width), - f32(particle.pmt.height), gx.blue) + f32(particle.pmt.height), gg.blue) } for node in app.nodes { app.gg.draw_rect_empty(f32(node.perimeter.x), f32(node.perimeter.y), f32(node.perimeter.width), - f32(node.perimeter.height), gx.red) + f32(node.perimeter.height), gg.red) } for retrieved in app.retrieveds { app.gg.draw_rect_filled(f32(retrieved.x + 1), f32(retrieved.y + 1), f32(retrieved.width - 2), - f32(retrieved.height - 2), gx.green) + f32(retrieved.height - 2), gg.green) } app.gg.draw_text(1200, 25, 'Nodes: ${app.nodes.len}', font_small) app.gg.draw_text(1200, 50, 'Particles: ${app.particles.len}', font_small) diff --git a/examples/snek/snek.js.v b/examples/snek/snek.js.v index 7d2e577a5..ab311d7e6 100644 --- a/examples/snek/snek.js.v +++ b/examples/snek/snek.js.v @@ -1,5 +1,4 @@ import gg -import gx // import sokol.sapp import time import rand @@ -142,17 +141,17 @@ fn on_frame(mut app App) { // drawing snake for pos in app.snake { app.gg.draw_rect(tile_size * pos.x, tile_size * pos.y + top_height, tile_size, - tile_size, gx.blue) + tile_size, gg.blue) } // drawing food app.gg.draw_rect(tile_size * app.food.x, tile_size * app.food.y + top_height, tile_size, - tile_size, gx.red) + tile_size, gg.red) // drawing top - app.gg.draw_rect(0, 0, canvas_size, top_height, gx.black) - app.gg.draw_text(350, top_height / 2, 'Score: ${app.score}', gx.TextCfg{ - color: gx.white + app.gg.draw_rect(0, 0, canvas_size, top_height, gg.black) + app.gg.draw_text(350, top_height / 2, 'Score: ${app.score}', gg.TextCfg{ + color: gg.white align: .center vertical_align: .middle size: 80 @@ -179,7 +178,7 @@ fn main() { app.reset_game() app.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white frame_fn: on_frame keydown_fn: on_keydown user_data: &app diff --git a/examples/snek/snek.v b/examples/snek/snek.v index e3cb71567..b8ca77e5d 100644 --- a/examples/snek/snek.v +++ b/examples/snek/snek.v @@ -1,5 +1,4 @@ import gg -import gx import os import rand import time @@ -77,35 +76,35 @@ fn on_frame(mut app App) { app.gg.begin() // draw food app.gg.draw_rect_filled(tile_size * app.food.x, tile_size * app.food.y + top_height, - tile_size, tile_size, gx.red) + tile_size, tile_size, gg.red) // draw snake for pos in app.snake[..app.snake.len - 1] { app.gg.draw_rect_filled(tile_size * pos.x, tile_size * pos.y + top_height, tile_size, - tile_size, gx.blue) + tile_size, gg.blue) } // draw partial head head := app.snake[0] app.gg.draw_rect_filled(tile_size * (head.x + app.dir.x * progress), tile_size * (head.y + - app.dir.y * progress) + top_height, tile_size, tile_size, gx.blue) + app.dir.y * progress) + top_height, tile_size, tile_size, gg.blue) // draw partial tail tail := app.snake.last() tail_dir := app.snake[app.snake.len - 2] - tail app.gg.draw_rect_filled(tile_size * (tail.x + tail_dir.x * progress), tile_size * (tail.y + - tail_dir.y * progress) + top_height, tile_size, tile_size, gx.blue) + tail_dir.y * progress) + top_height, tile_size, tile_size, gg.blue) // draw score bar - app.gg.draw_rect_filled(0, 0, canvas_size, top_height, gx.black) - app.gg.draw_text(150, top_height / 2, 'Score: ${app.score}', gx.TextCfg{ - color: gx.white + app.gg.draw_rect_filled(0, 0, canvas_size, top_height, gg.black) + app.gg.draw_text(150, top_height / 2, 'Score: ${app.score}', gg.TextCfg{ + color: gg.white align: .center vertical_align: .middle size: 65 }) - app.gg.draw_text(canvas_size - 150, top_height / 2, 'Best: ${app.best}', gx.TextCfg{ - color: gx.white + app.gg.draw_text(canvas_size - 150, top_height / 2, 'Best: ${app.best}', gg.TextCfg{ + color: gg.white align: .center vertical_align: .middle size: 65 @@ -170,7 +169,7 @@ app.best.load() mut font_copy := font app.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white frame_fn: on_frame keydown_fn: on_keydown user_data: &app diff --git a/examples/sokoban/sokoban.v b/examples/sokoban/sokoban.v index e3ccf0834..d0aa37a34 100644 --- a/examples/sokoban/sokoban.v +++ b/examples/sokoban/sokoban.v @@ -1,7 +1,6 @@ import os import os.asset import gg -import gx const csize = 32 @@ -204,7 +203,7 @@ fn (mut g Game) key_down(key gg.KeyCode, _ gg.Modifier, _ voidptr) { g.win = g.boxes.all(g.warehouse[it.y][it.x] == `@`) } -fn (g &Game) ctext(ws gg.Size, oy int, message string, size int, color gx.Color) { +fn (g &Game) ctext(ws gg.Size, oy int, message string, size int, color gg.Color) { g.ctx.draw_text(ws.width / 2, ws.height + oy, message, color: color size: size @@ -229,20 +228,20 @@ fn (g &Game) draw_frame(_ voidptr) { g.ctx.draw_image_by_id(ox + x * csize, oy + y * csize, 32, 32, iid) } } - g.ctx.draw_rect_filled(0, ws.height - 70, ws.width, 70, gx.black) + g.ctx.draw_rect_filled(0, ws.height - 70, ws.width, 70, gg.black) if g.win { - g.ctext(ws, -50, 'You win!!!', 60, gx.yellow) - g.ctext(ws, -15, 'Press `space` to continue.', 20, gx.gray) + g.ctext(ws, -50, 'You win!!!', 60, gg.yellow) + g.ctext(ws, -15, 'Press `space` to continue.', 20, gg.gray) } else { for idx, title in g.titles { - g.ctext(ws, -65 + (idx * 20), title, 22, gx.white) + g.ctext(ws, -65 + (idx * 20), title, 22, gg.white) } - g.ctext(ws, -65 + (g.titles.len * 20), 'Boxes: ${g.boxes.len:04}', 16, gx.gray) + g.ctext(ws, -65 + (g.titles.len * 20), 'Boxes: ${g.boxes.len:04}', 16, gg.gray) } - g.ctx.draw_rect_filled(0, 0, ws.width, 40, gx.black) - g.ctx.draw_text(30, 0, 'Level: ${g.level + 1:02}', color: gx.green, size: 40) - g.ctx.draw_text(ws.width - 225, 0, 'Moves: ${g.moves:04}', color: gx.green, size: 40) - g.ctx.draw_text(ws.width / 2 - 110, 0, 'Pushes: ${g.pushes:04}', color: gx.green, size: 40) + g.ctx.draw_rect_filled(0, 0, ws.width, 40, gg.black) + g.ctx.draw_text(30, 0, 'Level: ${g.level + 1:02}', color: gg.green, size: 40) + g.ctx.draw_text(ws.width - 225, 0, 'Moves: ${g.moves:04}', color: gg.green, size: 40) + g.ctx.draw_text(ws.width / 2 - 110, 0, 'Pushes: ${g.pushes:04}', color: gg.green, size: 40) g.ctx.end() } diff --git a/examples/sokol/01_cubes/cube.v b/examples/sokol/01_cubes/cube.v index 52ef21b92..e77dbdd50 100644 --- a/examples/sokol/01_cubes/cube.v +++ b/examples/sokol/01_cubes/cube.v @@ -8,7 +8,6 @@ * - add an example with shaders **********************************************************************/ import gg -import gx import math import sokol.sapp import sokol.gfx @@ -16,7 +15,7 @@ import sokol.sgl const win_width = 800 const win_height = 800 -const bg_color = gx.white +const bg_color = gg.white struct App { mut: diff --git a/examples/sokol/02_cubes_glsl/cube_glsl.v b/examples/sokol/02_cubes_glsl/cube_glsl.v index 87a3901f4..0e1f8f793 100644 --- a/examples/sokol/02_cubes_glsl/cube_glsl.v +++ b/examples/sokol/02_cubes_glsl/cube_glsl.v @@ -15,7 +15,6 @@ * - add instancing **********************************************************************/ import gg -import gx // import math import sokol.sapp import sokol.gfx @@ -30,7 +29,7 @@ fn C.cube_shader_desc(gfx.Backend) &gfx.ShaderDesc const win_width = 800 const win_height = 800 -const bg_color = gx.white +const bg_color = gg.white struct App { mut: diff --git a/examples/sokol/03_march_tracing_glsl/rt_glsl.v b/examples/sokol/03_march_tracing_glsl/rt_glsl.v index a4c0a812e..0175cae8b 100644 --- a/examples/sokol/03_march_tracing_glsl/rt_glsl.v +++ b/examples/sokol/03_march_tracing_glsl/rt_glsl.v @@ -16,7 +16,6 @@ **********************************************************************/ import gg import gg.m4 -import gx // import math import sokol.sapp import sokol.gfx @@ -31,7 +30,7 @@ fn C.rt_shader_desc(gfx.Backend) &gfx.ShaderDesc const win_width = 800 const win_height = 800 -const bg_color = gx.white +const bg_color = gg.white struct App { mut: diff --git a/examples/sokol/05_instancing_glsl/rt_glsl.v b/examples/sokol/05_instancing_glsl/rt_glsl.v index e10821648..f0f6473d7 100644 --- a/examples/sokol/05_instancing_glsl/rt_glsl.v +++ b/examples/sokol/05_instancing_glsl/rt_glsl.v @@ -16,7 +16,6 @@ **********************************************************************/ import gg import gg.m4 -import gx import math import sokol.gfx // import sokol.sgl @@ -24,7 +23,7 @@ import time const win_width = 800 const win_height = 800 -const bg_color = gx.white +const bg_color = gg.white const num_inst = 16384 struct App { diff --git a/examples/sokol/06_obj_viewer/show_obj.v b/examples/sokol/06_obj_viewer/show_obj.v index d4fdb7d96..1a99d4b27 100644 --- a/examples/sokol/06_obj_viewer/show_obj.v +++ b/examples/sokol/06_obj_viewer/show_obj.v @@ -22,7 +22,6 @@ **********************************************************************/ import gg import gg.m4 -import gx import math import sokol.sapp import sokol.gfx @@ -39,7 +38,7 @@ fn C.gouraud_shader_desc(gfx.Backend) &gfx.ShaderDesc const win_width = 600 const win_height = 600 -const bg_color = gx.white +const bg_color = gg.white struct App { mut: diff --git a/examples/tetris/tetris.js.v b/examples/tetris/tetris.js.v index a139c96ed..b0e9003ef 100644 --- a/examples/tetris/tetris.js.v +++ b/examples/tetris/tetris.js.v @@ -5,7 +5,6 @@ module main import rand import time -import gx import gg // import sokol.sapp @@ -22,15 +21,15 @@ const timer_period = 250 // ms const text_size = 24 const limit_thickness = 3 -const text_cfg = gx.TextCfg{ +const text_cfg = gg.TextCfg{ align: .left size: text_size - color: gx.rgb(0, 0, 0) + color: gg.rgb(0, 0, 0) } -const over_cfg = gx.TextCfg{ +const over_cfg = gg.TextCfg{ align: .left size: text_size - color: gx.white + color: gg.white } // Tetros' 4 possible states are encoded in binaries @@ -50,18 +49,18 @@ const b_tetros = [ ] // Each tetro has its unique color const colors = [ - gx.rgb(0, 0, 0), // unused ? - gx.rgb(255, 242, 0), // yellow quad - gx.rgb(174, 0, 255), // purple triple - gx.rgb(60, 255, 0), // green short topright - gx.rgb(255, 0, 0), // red short topleft - gx.rgb(255, 180, 31), // orange long topleft - gx.rgb(33, 66, 255), // blue long topright - gx.rgb(74, 198, 255), // lightblue longest - gx.rgb(0, 170, 170), + gg.rgb(0, 0, 0), // unused ? + gg.rgb(255, 242, 0), // yellow quad + gg.rgb(174, 0, 255), // purple triple + gg.rgb(60, 255, 0), // green short topright + gg.rgb(255, 0, 0), // red short topleft + gg.rgb(255, 180, 31), // orange long topleft + gg.rgb(33, 66, 255), // blue long topright + gg.rgb(74, 198, 255), // lightblue longest + gg.rgb(0, 170, 170), ] -const background_color = gx.white -const ui_color = gx.rgba(255, 0, 0, 210) +const background_color = gg.white +const ui_color = gg.rgba(255, 0, 0, 210) // TODO: type Tetro [tetro_size]struct{ x, y int } struct Block { @@ -160,7 +159,7 @@ fn main() { } game.gg = gg.new_context( - bg_color: gx.white + bg_color: gg.white width: win_w