Reputation: 12627
I'm asking myself how to create a long shadow programmatically. Here its already working.
I would like to provide this functionality in a Java library (Android and maybe in JavaFX). What amazes me the most is the fact that the shadow creation works for a given text and also a image file.
If someone has any idea / advice how to get this working, please let me know, thanks in advance.
To draw black pixels in a loop which increments X and Y is the easiest part, I guess.
Upvotes: 0
Views: 364
Reputation: 3454
You have to define a line (red line
, see Bresenham) and move the line across your whole image...
in my example: we move move horizontally
1) set the line to the very left (maybe even outside the visible scope).
2) set the line color to 'light'.
3) walk along each pixel from the line and draw the pixel with the line color. if the pixel hits a visible pixel (green rectangle
), change the line color to 'shadow'
4) move the line one pixel to the right
5) if(not reached_right_border) goto 1
6) redraw text/image over the shadow
Upvotes: 1