Shaders Library
Magnifies the picture inside a circular lens, or pinches it inwards when Amount is
negative – a magnifying glass one way, a pinch the other.
Assembly
| Assembly | Binarymission.WPF.Shaders.Library.dll |
| Root namespace | Binarymission.WPF.Shaders.Library |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
Only what falls inside Radius moves, and the displacement eases to nothing at
the rim, so the lens blends into the untouched picture instead of showing as a hard circle. The lens
is measured in relative coordinates, so on an element that is not square it takes the element's
proportions. Animate Amount across zero to go from pinch to bulge in one pass.
Settings
| Property | Range and default |
|---|---|
Strength and direction. Default 0.5; 0 leaves the picture unchanged, negative values pinch, and values above 1 turn the middle of the lens inside out. -1 to 1 is the useful range. | |
Reach of the lens from its centre, as a fraction of the element. Default 0.45. | |
Centre of the lens, in relative coordinates: (0,0) is the top-left corner of the element and (1,1) its bottom-right. Default (0.5,0.5). |
Getting started
A magnifier that follows the mouse over a photograph.
<Image Source="Photos/harbour.jpg"
xmlns:fx="clr-namespace:Binarymission.WPF.Shaders.Library.CustomEffects;assembly=Binarymission.WPF.Shaders.Library"
MouseMove="OnPhotoMouseMove">
<Image.Effect>
<fx:BulgeEffect x:Name="Magnifier" Amount="0.7" Radius="0.2" />
</Image.Effect>
</Image>private void OnPhotoMouseMove(object sender, MouseEventArgs e)
{
var photo = (Image)sender;
Point position = e.GetPosition(photo);
Magnifier.CenterXY = new Point(position.X / photo.ActualWidth, position.Y / photo.ActualHeight);
}API reference
Binarymission.WPF.Shaders.Library.CustomEffects
class BandsEffect | Lays evenly spaced vertical stripes over the picture, each shading from darker on its left to brighter on its right - a scan-line or slatted-blind look. |
class BulgeEffect | Magnifies the picture inside a circular lens, or pinches it inwards when Amount is negative - a magnifying glass one way, a pinch the other. |
class ChromaticSplitEffect | Pulls the red and blue channels of the picture apart towards its edges, leaving green in place - the colour fringing a cheap lens leaves at the corners of a photograph. |
class ColorBlendEffect | Washes the picture with a colour, as strongly as the colour's alpha says - from no change at all to the colour alone. |
class ColorToBlackAndWhiteEffect | Turns the picture black and white, or - with DesaturationFactor raised towards 1 - mutes its colours part of the way. |
class DuotoneEffect | Recolours the picture with two colours: its darkest parts become ShadowColor, its brightest HighlightColor, and everything between a blend of the two - the poster look of a two-ink print. |
class FrostedGlassEffect | Scatters every pixel of the picture by a small random amount, so that it looks seen through frosted or etched glass. |
class GlowingEdgesEffect | Finds the edges in the picture - outlines, text, the borders between colours - and draws them in a glowing colour, leaving flat areas as they were. |
class HexPixellateEffect | Turns the picture into a mosaic of flat-coloured hexagons, each the colour of the picture at its centre. |
class HueRotateEffect | Turns every colour in the picture round the colour wheel - reds towards greens, greens towards blues - while leaving how light or dark it is unchanged. |
class KaleidoscopeEffect | Folds the picture into mirrored wedges round a centre point, the way a kaleidoscope folds whatever it is pointed at. |
class NegativeToPositiveEffect | Inverts the colours of the picture - black to white, blue to yellow - turning a scanned negative into a positive, or a positive into a negative. |
class PixellatingEffect | Breaks the picture into flat-coloured blocks, each the colour of the picture at its centre, with every other row offset by half a block like courses of brickwork. |
class PositiveEffect | Looks at the picture through a coloured filter: each colour channel is multiplied by the matching channel of ColorFilter. |
class RadialBlurEffect | Streaks the picture towards a centre point - the blur a camera leaves when it zooms during the exposure. |
class RainFloorEffect | Ripples the picture with overlapping rings, like rain falling on a wet floor or a puddle. |
class TwirlEffect | Twists the middle of the picture round its centre, most at the centre and easing to nothing at the edge of a circle. |
class VignetteEffect | Darkens the picture towards its corners, the way a lens falls off at the edge of its coverage, drawing the eye to the middle. |
class WaterRippleEffect | Ripples the picture in rings spreading out from a point, as if a stone had dropped into still water there. |
class WaterWaveEffect | Wobbles the picture in fine waves across and down it, as if seen through moving water or heat haze. |