Rounded corner
BlitzMax Forums/BlitzMax Programming/Rounded corner
| ||
Hi Everyone. Let's say I have an array of coordinates used to describe a polygon. I would like to be able to rewrite this array with more detail so I can add rounded corners. (for example, a corner could consist of 8 coordinates instead of the original 1 and so the array would go from holding 4 coords to 32). I would supply the radius of the rounding as well. Is this called anything in particular so I can read up on it? Or even better, has anyone done something similar? Ta! |
| ||
I would use a list for that. If you're set on using arrays then check Slicing to resize the array dynamically. |
| ||
Cheers tony, the actual storage of the information wasn't the problem (well it isnt yet ;) It's more the working out of the coordinates. Like, I know the red coords, I know the radius of the circle and I would like it to work out the green coords. So the function would be something like function roundCorner(x1#, y1#, x2#, y2#, x3#, y3#, radius#, detail:int) where detail specifies how many coords to return. |
| ||
However, I think I should be able to do it once I work out the center of the circle coords and where the circle hits each line. I can work out the circle position by working out where two lines parallel to the original lines cross. There's some code in the archives that tells you where a line intersects a circle as well, so I'll have a closer look at that and should be sorted :D |
| ||
Huzzah! |