MonoGame.StrokeEffect

MonoGame.StrokeEffect is a library to generate strokes for Texture2D in MonoGame. We also support Sprite Font. We use a shader effect to process the outline


Keywords
MonoGame, border, effect, outline, stroke
License
MIT
Install
Install-Package MonoGame.StrokeEffect -Version 1.0.1

Documentation

MonoGame.StrokeEffect

MonoGame.StrokeEffect

MonoGame.StrokeEffect is a library to generate strokes for Texture2D in MonoGame. We also support Sprite Font. We use a shader effect to generate the Stroke effect.

Nuget package

There is a nuget package avaliable here https://www.nuget.org/packages/MonoGame.StrokeEffect/.

Examples

MonoGame.StrokeEffect

https://github.com/DaniloPeres/MonoGame.StrokeEffect/tree/main/MonoGame.StrokeEffect-Samples

Anti-Aliasing

MonoGame.StrokeEffect

How to use

Stroke Types:

  • 'OutlineAndTexture' - Create a new Texture with the original Texture and an outline stroke
  • 'OutlineWithoutTexture' - Create a new Texture with only the outline stroke

Create a new Texture with stroke

int strokeSize = 3;
Color strokeColor = Color.Black;
StrokeType strokeType = StrokeType.OutlineAndTexture;
var textureWithStroke = StrokeEffect.CreateStroke(myTexture, strokeSize, strokeColor, GraphicsDevice, Content, strokeType);

Color textColor = Color.White;
Vector2 scale = Vector2.One;
int strokeSize = 3;
Color strokeColor = Color.Black;
StrokeType strokeType = StrokeType.OutlineAndTexture;
var textStroke = StrokeEffect.CreateStrokeSpriteFont(arialSpriteFont, "My Text", textColor, scale, strokeSize, strokeColor, GraphicsDevice, Content, strokeType);

License

MIT