Black Outline

Hello Eclipse

I’m working on a game and I want to know if it possible trough coding to add a black outline to a Sprite.

Something like “Stroke” in Photoshop even when scalled down the image the stroke/outline will nicely adjust to the image.

Imagine for example ROTMG sprites without that black outline, and I add trough coding x1 Pixel Black Outline, wich will adjust nicely even if the sprite changes size for example from 60x60 to 30x30 or whatever, but will keep that nice 1px black outline.

So, is this possible? In JS

If yes, it is something complicated ?

Thank you!

It would be nice to know what graphics library you’re using. However, If it is possible with said graphics library, I wouldn’t know how to do it. Good luck though!

Is this for bad mens?

You have two options, the simple (or lazy, depending on your outlook) option, and the technically correct option.

The simple option is to simply redraw the image 4/8 times offset by 1 pixel (up/down/left/right and optionally up-left/up-right/down-left/down-right) and make them filled black. Obviously, this will impact performance. Test extensively if you try this out.

Your technically correct option (but isn’t necessarily always possible, depends on whether your graphics engine allows it), is to look up some shader options. WebGL certainly allows you to use shaders, dunno about anything else.

I can’t provide any shader code, I’m useless at creating them. 😛

Log in to reply