Determining a brush stroke.

Hello everyone.

I have some code that when the player clicks begins to erase a GUI texture based on a brush. I basically use an image with an alpha channel as a brush, load that up in a 2D array and compare the alpha values of the brush with the underlying texture to determine weather or not to change the underlying pixels.

What I’m trying to figure out now is how to create actual brush strokes, because if you try to brush across an area to fast you end up with staggered circular holes instead of a completely solid line.

I am not mathematically inclined, and I suspect there is a mathematical solution to this. I’m wondering if anyone here could send me in the right direction.

Glad that could help :)

2 Answers

2

You’ll need to find the points between the brush’s previous location and the current one, and set them all as well. Basically, if you were using a single dot as brush, you’d just draw a line between the two dots. Using any other (2D) shape, you’ll have to find the parallelogram that fills the space between the two shapes. If you’re using a circle as brush, a rotated rectangle will do. I wouldn’t know how to find it, though. If I did, I wouldn’t have failed geometry in high school :smiley:

hi, i’m looking for the same thing, did you figure it out?