Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

Commit 645ea08

Browse files
committed
Stop brush wraparound
1 parent 80cbb57 commit 645ea08

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/conjam.gleam

+11-2
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,20 @@ fn apply_brush(
144144
|> result.unwrap(0.0)
145145
|> float.round()
146146

147-
case distance > brush_size {
147+
let new_x = mouse_x + x
148+
let new_y = mouse_y + y
149+
150+
case
151+
distance > brush_size
152+
|| new_x < 0
153+
|| new_x > max_x
154+
|| new_y < 0
155+
|| new_y > max_y
156+
{
148157
True -> pixel_data
149158
False -> {
150159
pixel_data
151-
|> canvas.set_pixel(mouse_x + x, mouse_y + y, brush_colour)
160+
|> canvas.set_pixel(new_x, new_y, brush_colour)
152161
}
153162
}
154163
})

0 commit comments

Comments
 (0)