Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Erasing a certain area of a sprite on mouse click  (Read 983 times)

0 Members and 1 Guest are viewing this topic.

n00boxular

  • Newbie
  • *
  • Posts: 2
    • View Profile
Erasing a certain area of a sprite on mouse click
« on: March 29, 2018, 07:37:00 pm »
I have a program that users can "draw" onto the window using color detection (OpenCV). Basically paint, but instead of using the mouse, they draw using hand-held colored discs. The color detection isn't perfect and sometimes there are a couple of spots where there is color drawn onto the screen where the user doesn't want.

The drawing is stored as a sprite.

How would I go around making a function such that, on mouse click, a circle of radius 30px around the mouse is erased? I'm assuming that it would not only erase the sprite that has the user's drawing on it but also the background sprite and I'm not sure how I would get around that either...

Fililip

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Erasing a certain area of a sprite on mouse click
« Reply #1 on: March 30, 2018, 10:22:44 am »
I think you have to modify the sf::Texture of your sprite and you'll see the changes automatically as SFML stores a reference to it, rather than a copy of it.
Dunno about how you'd delete a certain part of a texture though.

 

anything