Vignette — darken the edges of the view by drawing a real radial-gradient overlay on top of the finished content: transparent at the center, fading to edge_color (scaled by intensity) at the corners. More...
#include <view_effect.hpp>
Public Member Functions | |
| void | configure_layer (Canvas &canvas, float x, float y, float w, float h) override |
| Push the compositing layer(s) this effect needs, configured with its opacity, image filters, blend mode, etc. | |
| void | paint_overlay (Canvas &canvas, float x, float y, float w, float h) override |
| Paint an overlay on TOP of the already-painted subtree, but still INSIDE the effect's compositing layer(s) (called by View::paint_all just before the layers are popped). | |
| virtual int | layer_count () const |
| How many layers configure_layer() pushes. | |
| virtual bool | needs_layer () const |
| Whether this effect requires a compositing layer (most do). | |
Public Attributes | |
| float | intensity = 0.5f |
| Darkening strength (0=none, 1=full edge_color). | |
| float | radius = 0.75f |
| Fraction of view half-extent where darkening starts. | |
| Color | edge_color = Color::rgba(0.0f, 0.0f, 0.0f, 0.5f) |
Vignette — darken the edges of the view by drawing a real radial-gradient overlay on top of the finished content: transparent at the center, fading to edge_color (scaled by intensity) at the corners.
The overlay is painted in paint_overlay(), INSIDE the effect's compositing layer, so it darkens the edges rather than uniformly fading the whole view (the old approximation, which just reduced the layer opacity).
|
inlineoverridevirtual |
Push the compositing layer(s) this effect needs, configured with its opacity, image filters, blend mode, etc.
The subtree paints into the layer(s); the caller pops them once the subtree is done.
An implementation MUST push exactly layer_count() layers. The caller (View::paint_all) pops that many, so an effect that saves a different number than it reports unbalances the canvas save stack for the rest of the frame.
Implements pulp::canvas::ViewEffect.
|
inlinevirtualinherited |
How many layers configure_layer() pushes.
One for a simple effect; EffectChain reports the sum across its children.
Reimplemented in pulp::canvas::EffectChain.
|
inlinevirtualinherited |
Whether this effect requires a compositing layer (most do).
Reimplemented in pulp::canvas::EffectChain.
|
inlineoverridevirtual |
Paint an overlay on TOP of the already-painted subtree, but still INSIDE the effect's compositing layer(s) (called by View::paint_all just before the layers are popped).
This is how an effect that darkens or tints the finished content — a vignette drawing a radial gradient — is implemented, instead of the wrong "reduce the whole layer's opacity" approximation. Default: nothing.
Limitation: the overlay draws into the innermost still-open layer. That is correct for a single effect (the only non-chain path today), but in a multi-effect EffectChain (e.g. [vignette, blur]) an earlier effect's overlay lands in a later effect's layer and is filtered by it. See the View::paint_all call site — revisit if overlays-in-chains are needed.
Reimplemented from pulp::canvas::ViewEffect.
| Color pulp::canvas::VignetteEffect::edge_color = Color::rgba(0.0f, 0.0f, 0.0f, 0.5f) |
| float pulp::canvas::VignetteEffect::intensity = 0.5f |
Darkening strength (0=none, 1=full edge_color).
| float pulp::canvas::VignetteEffect::radius = 0.75f |
Fraction of view half-extent where darkening starts.