testing scissoring
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 7 Jul 2021 20:05:07 +0000 (15:05 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 7 Jul 2021 20:05:07 +0000 (15:05 -0500)
res/colors.json [deleted file]
res/colors_dark.json [new file with mode: 0644]
res/colors_light.json [new file with mode: 0644]
src/main.onyx
src/mouse_handler.onyx [new file with mode: 0644]

diff --git a/res/colors.json b/res/colors.json
deleted file mode 100644 (file)
index 31095c1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-    "dark_background": [ 0.1,  0.1,  0.1  ],
-    "background":      [ 0.15, 0.15, 0.15 ],
-    "foreground":      [ 0.9,  0.9,  0.9  ],
-
-    "keyword":   [ 0.7, 0.7, 1.0 ],
-    "value":     [ 0.8, 1.0, 0.8 ],
-    "jumppoint": [ 1, 0.5, 0.5   ],
-
-    "primary":       [ 0.051, 0.278, 0.631 ],
-    "primary_light": [ 0.329, 0.451, 0.827 ],
-    "primary_dark":  [ 0,     0.129, 0.443 ],
-    "primary_text":  [ 1,     1,     1     ],
-
-    "secondary":       [ 0,     0.376, 0.392 ],
-    "secondary_light": [ 0.259, 0.557, 0.573 ],
-    "secondary_dark":  [ 0,     0.212, 0.227 ],
-    "secondary_text":  [ 1,     1,     1     ]
-}
diff --git a/res/colors_dark.json b/res/colors_dark.json
new file mode 100644 (file)
index 0000000..31095c1
--- /dev/null
@@ -0,0 +1,19 @@
+{
+    "dark_background": [ 0.1,  0.1,  0.1  ],
+    "background":      [ 0.15, 0.15, 0.15 ],
+    "foreground":      [ 0.9,  0.9,  0.9  ],
+
+    "keyword":   [ 0.7, 0.7, 1.0 ],
+    "value":     [ 0.8, 1.0, 0.8 ],
+    "jumppoint": [ 1, 0.5, 0.5   ],
+
+    "primary":       [ 0.051, 0.278, 0.631 ],
+    "primary_light": [ 0.329, 0.451, 0.827 ],
+    "primary_dark":  [ 0,     0.129, 0.443 ],
+    "primary_text":  [ 1,     1,     1     ],
+
+    "secondary":       [ 0,     0.376, 0.392 ],
+    "secondary_light": [ 0.259, 0.557, 0.573 ],
+    "secondary_dark":  [ 0,     0.212, 0.227 ],
+    "secondary_text":  [ 1,     1,     1     ]
+}
diff --git a/res/colors_light.json b/res/colors_light.json
new file mode 100644 (file)
index 0000000..e02a70b
--- /dev/null
@@ -0,0 +1,19 @@
+{
+    "dark_background": [ 0.8,  0.8,  0.8  ],
+    "background":      [ 0.9,  0.9,  0.9  ],
+    "foreground":      [ 0,    0,    0,   ],
+
+    "keyword":   [ 0.7, 0.7, 1.0 ],
+    "value":     [ 0.8, 1.0, 0.8 ],
+    "jumppoint": [ 1, 0.5, 0.5   ],
+
+    "primary":       [ 0.051, 0.278, 0.631 ],
+    "primary_light": [ 0.329, 0.451, 0.827 ],
+    "primary_dark":  [ 0,     0.129, 0.443 ],
+    "primary_text":  [ 0,     0,     0     ],
+
+    "secondary":       [ 0,     0.376, 0.392 ],
+    "secondary_light": [ 0.259, 0.557, 0.573 ],
+    "secondary_dark":  [ 0,     0.212, 0.227 ],
+    "secondary_text":  [ 0,     0,     0     ]
+}
index cc2494d10730c2e6b42d2059c507f116f089ce8a..68202a1305351b373a952719710087ea79febae8 100644 (file)
@@ -9,6 +9,8 @@ use package core
 
 keys : Key_Handler;
 
+search_buffer: string.String_Buffer;
+
 background_tile_texture : gfx.Texture;
 
 main :: (args: [] cstr) {
@@ -48,7 +50,7 @@ init :: () {
 
         @DynamicLoading // Currently, this file is just baked into the binary. When a mechanism
         // is added to easily ask JS to make a fetch request for a file, that can be used here.
-        colors_json := #file_contents "res/colors.json";
+        colors_json := #file_contents "res/colors_dark.json";
 
         arena := alloc.arena.make(context.allocator, 4096);
         defer alloc.arena.free(^arena);
@@ -164,7 +166,7 @@ poll_events :: () -> bool {
 }
 
 update :: (dt: f32) {
-    speed :: 200.0f;
+    speed :: 400.0f;
     scale_speed :: 0.02f;
 
     transform := gfx.global_renderer->get_transform();
@@ -201,6 +203,8 @@ draw :: () {
 
     window_rectangle := ui.Rectangle.{ 0, 0, ~~window_width, ~~window_height };
 
+    gfx.push_scissor(ui.mouse_state.x, ui.mouse_state.y, 400, 400);
+
     draw_background_lines(~~window_width, ~~window_height, line_color=config.Colors.background);
 
     random.set_seed(32185);
@@ -209,9 +213,12 @@ draw :: () {
         y := cast(f32) random.between(0, 4000);
         w := cast(f32) random.between(100, 400);
         h := cast(f32) random.between(100, 400);
+        gfx.rect(.{ x+2, y+2 }, .{ w, h }, color=config.Colors.primary_dark);
         gfx.rect(.{ x, y }, .{ w, h }, color=config.Colors.primary);
     }
 
+    gfx.pop_scissor();
+
     gfx.push_matrix();
     gfx.identity();
     draw_menu_bar(window_rectangle);
@@ -221,8 +228,6 @@ draw :: () {
     ui.clear_buttons();
 }
 
-search_buffer: string.String_Buffer;
-
 #private_file
 draw_menu_bar :: (window_rectangle: ui.Rectangle) {
     menu_bar, _ := ui.Flow.split_horizontal(window_rectangle, top_height=32);
diff --git a/src/mouse_handler.onyx b/src/mouse_handler.onyx
new file mode 100644 (file)
index 0000000..81b1af4
--- /dev/null
@@ -0,0 +1,2 @@
+
+// #private_file events :: package js_events