count += 1;
state = 0;
- for p: poly_points {
- print_vec(p);
+ // for p: poly_points {
+ // print_vec(p);
- tx := cast(i32) (~~p.x * height / ~~units_per_em);
- ty := cast(i32) (~~p.y * height / ~~units_per_em);
+ // tx := cast(i32) (~~p.x * height / ~~units_per_em);
+ // ty := cast(i32) (~~p.y * height / ~~units_per_em);
- if tx >= 0 && ty >= 0 && tx < width && ty < height {
- data[tx + (height - 1 - ty) * width] += cast(u8) 100;
- }
- }
-
- // for y: 0 .. height do for x: 0 .. width {
- // sx := x * ~~units_per_em / width;
- // sy := y * ~~units_per_em / height;
-
- // if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) {
- // curr := data[x + (height - 1 - y) * width];
- // if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255;
- // else do data[x + (height - 1 - y) * width] = cast(u8) 0;
+ // if tx >= 0 && ty >= 0 && tx < width && ty < height {
+ // data[tx + (height - 1 - ty) * width] += cast(u8) 100;
// }
// }
+ for y: 0 .. height do for x: 0 .. width {
+ sx := x * ~~units_per_em / width;
+ sy := y * ~~units_per_em / height;
+
+ if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) {
+ curr := data[x + (height - 1 - y) * width];
+ if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255;
+ else do data[x + (height - 1 - y) * width] = cast(u8) 0;
+ }
+ }
+
array_clear(^poly_points);
}
}
poll_events :: proc () {
+ use event.DomEventKind;
+
ev : event.Event;
while event.poll(^ev) do switch ev.kind {
- case event.DomEventKind.KeyDown,
- event.DomEventKind.KeyUp,
- event.DomEventKind.MouseDown,
- event.DomEventKind.MouseUp,
- event.DomEventKind.MouseMove {
- input.process_event(^input_state, ^ev);
- }
+ case KeyDown, KeyUp, MouseDown, MouseUp, MouseMove do input.process_event(^input_state, ^ev);
- case event.DomEventKind.Resize {
+ case Resize {
window_width = ev.resize.width;
window_height = ev.resize.height;
ttf = ttf_create(ttf_data);
glyph : ^TTGlyph = null;
- glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "~");
+ glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "A");
glyph = ttf_read_glyph(^ttf, glyph_index);
if glyph == null do return;
defer ttf_glyph_destroy(glyph);