summaryrefslogtreecommitdiff
path: root/drawing
diff options
context:
space:
mode:
Diffstat (limited to 'drawing')
-rw-r--r--drawing/drawing.ha23
1 files changed, 12 insertions, 11 deletions
diff --git a/drawing/drawing.ha b/drawing/drawing.ha
index 54116a3..ae36501 100644
--- a/drawing/drawing.ha
+++ b/drawing/drawing.ha
@@ -127,23 +127,24 @@ export fn stroke(picture: *picture, c0: pos, c1: pos, r: i32, color: u32) void =
};
// ehh should check bounding box instead of doing all pictures maybe
-export fn perform(pictures: []picture, op: op) void = {
+export fn perform(pic: *picture, op: op) void = {
match (op) {
case let o: op_circle =>
const x = o.pos.0, y=o.pos.1;
const r = o.radius;
const c = o.color & 0xffffff;
- for (const pic &.. pictures) {
- let pos_within_pic =
- (x - pic.world_pos.0, y - pic.world_pos.1): pos;
- circle(pic, pos_within_pic, r: i32, c);
- };
+ const pos_within_pic: pos =
+ (x - pic.world_pos.0, y - pic.world_pos.1);
+ circle(pic, pos_within_pic, r: i32, c);
case let s: op_stroke =>
const col = s.color & 0xffffff;
- for (const pic &.. pictures) {
- const c0 = (s.pos0.0 - pic.world_pos.0, s.pos0.1 - pic.world_pos.1);
- const c1 = (s.pos1.0 - pic.world_pos.0, s.pos1.1 - pic.world_pos.1);
- stroke(pic, c0, c1, s.radius: i32, col);
- };
+ const c0 = (s.pos0.0 - pic.world_pos.0, s.pos0.1 - pic.world_pos.1);
+ const c1 = (s.pos1.0 - pic.world_pos.0, s.pos1.1 - pic.world_pos.1);
+ stroke(pic, c0, c1, s.radius: i32, col);
};
};
+
+export fn perform_multi(pictures: []picture, op: op) void = {
+ for (const pic &.. pictures)
+ perform(pic, op);
+};