I would like to implent an highlighting feature in my engine. Like when your mouse is over an object in Baldur''s Gate, the contour of the object becomes highlighted.
I figured two way of doing this:
- First one, change my bitmap of the object to include a single pixel line, which is very close to the key color of the blit, around it. When I would blit the object, I would spread the the key color to include or not the highlight line.
- Second one, do it all with a draw line function. Which seems to me pretty slow and hard to implent.
So which one is the faster ?
And fell free to tell me your ideas on this and give other ways of doing it.
Assuming your sprites have proper masks, you can extract the mask and do edge detection on it. This will give you the outline of the figure. You may need to enlarge and crop it to get it to be around your figure properly. From there you can either use this as a mask for whatever highlighting you want to do or just transform it into a highlight image.