

I have currently set it to fixed but if a string does not work for you you can change it however you want. Let canvas = document.getElementById("canvas") Ĭtx.fillRect(0,0,canvas.width,canvas.height) If(shape > boundingBox) boundingBox = shape Ĭtx.fillRect(boundingBox, boundingBox, boundingBox-boundingBox, boundingBox-boundingBox) If(shape boundingBox) boundingBox = shape The shapes will all be made of straight line segments and won't have any holes inside them.Įdit: made changes to the pixel RGB sampling that improve performance.Ĭanvas = document.getElementById('canvas') How do I cast rays at a different angle within the bounding box? Now it's going left to right, but how would I fill my bounding box with rays cast at any specified angle? i.e.:.Perhaps there is a better way than casting rays? Or perhaps there is a way to optimize the ray logic? Perhaps something more intelligent than just checking for RGB color values? Thus I know start and end coordinates for each line within my shape and if one ray enters and exits the shape multiple times - this will generate all line segments within that one ray cast.įor the most part it works but there are issues:

I know when it exits the shape if the pixel value is not 100, 255, 100. Whenever a cast ray gets to a pixel with RGB values of 100, 255, 100 I then know it has entered the shape. The ray goes from left to right incrementing by 1 pixel. Next, I cast rays within the bounding box with a set spacing between each ray. I calculate and draw the bounding box of this shape I have a closed irregular shape (can have dozens of sides) defined by coordinates shape = [ I'll go through what I have and explain the issues I'm facing I need to create line segments within a shape and not just a visual pattern - I need to know start and end coordinates for those lines that are within a given boundary (shape).
