Hi,
I want to create a (circle) brush to lighten or darken pixels of a sprite/texture.
I thought about getting all the pixels inside the radius of my circle.
loop through the pixels from the inside to the outside and change the color depending on the distance of the circle origin.
I am struggling with a good way to implement this feature and my implementation seems to suck hard. First step is to find ALL the pixels inside the circle from a sprite ... fails
Here's my code:
static List
<Vector2f
> FindPixelsOnSprite
(CircleShape c, Sprite s
) { List
<Vector2f
> pixels
= new List
<Vector2f
>(); float radius
= c
.Radius; float m1
= c
.Position.X - s
.Position.X; float m2
= c
.Position.Y - s
.Position.Y; for (float x
= 0; x
< s
.TextureRect.Width; x
++) { for (float y
= 0; y
< s
.TextureRect.Height; y
++) { float dx
= x
- m1
; float dy
= y
- m2
; float distance
= dx
* dx
+ dy
* dy
; if(distance
<= c
.Radius) { pixels
.Add(new Vector2f
(x, y
)); } } } return pixels
; } I attached my Visual Studio 2013 (Premium) project too ... set the working directory to the project directory, so the program will find the pic.png
Also add the NuGet SFML package (couldn't upload the whole solution)
Maybe you can help me out here :/
Edit:
This is the effect I want to achieve on mouse click: