I’m trying to make curving lasers, and since I have no idea of how to do this I thought stretching out an image along a line (or a polygon )would be the best approach.
Does anyone know how to do this, or got a better idea?
~Thanks.
I’m trying to make curving lasers, and since I have no idea of how to do this I thought stretching out an image along a line (or a polygon )would be the best approach.
Does anyone know how to do this, or got a better idea?
~Thanks.
What api? Java2d?
No api is used.
You’re using something to draw the image…
oh sorry, I’m using Graphics2D. Is that the same as java2D?
what you are trying to do sounds difficult especially as you dont have an API to manipulate the image for you. Maybe sequence each pixel to be draw and then draw that around the curve
My suggestion?
Make the image a ‘thick enough’ sliver of the beam (I’m imagining a gradient going from high saturation in the middle to low saturation at the edges). Say several 10 pixels across. Then pick out several discrete points along the line, typically less than width of the sliver. Draw the sliver along that line and rotate it to follow the slope of the curve. This method will have a little bit of overlap where corners of the beam end up going over the higher saturation areas and giving it a sort of jagged edge along the interior.
If you want to get fancy and you know the maximum curve-per-arc-length you can get even fancier and make ‘curved’ slivers that better match the points where the line has more sudden curves (This will help with overlap issue I described above). But this takes a bit more work to get ‘pixel perfect’.