|
| 1 | +\page graphicsEffects Graphics effects |
| 2 | + |
| 3 | +libscratchcpp provides API for implementing custom graphics effects. |
| 4 | +No effects are currently included with libscratchcpp, but that is planned to change. |
| 5 | + |
| 6 | +In case you've implemented some of the effects yourself, feel free to make pull requests! |
| 7 | +These are the issues (tasks) for the default graphics effects: |
| 8 | + |
| 9 | +- Color: https://github.com/scratchcpp/libscratchcpp/issues/283 |
| 10 | +- Fisheye: https://github.com/scratchcpp/libscratchcpp/issues/284 |
| 11 | +- Whirl: https://github.com/scratchcpp/libscratchcpp/issues/285 |
| 12 | +- Pixelate: https://github.com/scratchcpp/libscratchcpp/issues/286 |
| 13 | +- Mosaic: https://github.com/scratchcpp/libscratchcpp/issues/287 |
| 14 | +- Brightness: https://github.com/scratchcpp/libscratchcpp/issues/288 |
| 15 | +- Ghost: https://github.com/scratchcpp/libscratchcpp/issues/289 |
| 16 | + |
| 17 | +# Implementing a graphics effect |
| 18 | +To implement a graphics effect that libscratchcpp doesn't support, |
| 19 | +subclass \link libscratchcpp::IGraphicsEffect IGraphicsEffect \endlink |
| 20 | +and override all of the methods. |
| 21 | + |
| 22 | +It's recommended to use the libscratchcpp namespace like this in your class: |
| 23 | +```cpp |
| 24 | +using namespace libscratchcpp; |
| 25 | +``` |
| 26 | + |
| 27 | +The `name()` method should return the name of the effect which is |
| 28 | +used by the set and change effect blocks, for example `ghost` or `fisheye`. |
| 29 | + |
| 30 | +The `apply()` method is used to apply the effect on a bitmap. The bitmap |
| 31 | +can be accessed using the `bitmap` parameter and is writable. |
| 32 | + |
| 33 | +# Registering the graphics effect |
| 34 | +To register the graphics effect, use \link libscratchcpp::ScratchConfiguration::registerGraphicsEffect() ScratchConfiguration::registerGraphicsEffect() \endlink. |
| 35 | + |
| 36 | +```cpp |
| 37 | +libscratchcpp::ScratchConfiguration::registerGraphicsEffect(std::make_shared<MyGraphicsEffect>()); |
| 38 | +``` |
0 commit comments