HypernovaDesktop Components · docs
Binarymission
WPF › Shaders Library

Shaders Library

.NET Framework 4.8.NET 6 / 8 / 10WPF

Magnifies the picture inside a circular lens, or pinches it inwards when Amount is negative – a magnifying glass one way, a pinch the other.

20public types
133public members
1namespaces

Assembly

AssemblyBinarymission.WPF.Shaders.Library.dll
Root namespaceBinarymission.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

PropertyRange and default

Amount

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.

Radius

Reach of the lens from its centre, as a fraction of the element. Default 0.45.

CenterXY

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 BandsEffectLays 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 BulgeEffectMagnifies the picture inside a circular lens, or pinches it inwards when Amount is negative - a magnifying glass one way, a pinch the other.
class ChromaticSplitEffectPulls 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 ColorBlendEffectWashes the picture with a colour, as strongly as the colour's alpha says - from no change at all to the colour alone.
class ColorToBlackAndWhiteEffectTurns the picture black and white, or - with DesaturationFactor raised towards 1 - mutes its colours part of the way.
class DuotoneEffectRecolours 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 FrostedGlassEffectScatters every pixel of the picture by a small random amount, so that it looks seen through frosted or etched glass.
class GlowingEdgesEffectFinds 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 HexPixellateEffectTurns the picture into a mosaic of flat-coloured hexagons, each the colour of the picture at its centre.
class HueRotateEffectTurns 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 KaleidoscopeEffectFolds the picture into mirrored wedges round a centre point, the way a kaleidoscope folds whatever it is pointed at.
class NegativeToPositiveEffectInverts 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 PixellatingEffectBreaks 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 PositiveEffectLooks at the picture through a coloured filter: each colour channel is multiplied by the matching channel of ColorFilter.
class RadialBlurEffectStreaks the picture towards a centre point - the blur a camera leaves when it zooms during the exposure.
class RainFloorEffectRipples the picture with overlapping rings, like rain falling on a wet floor or a puddle.
class TwirlEffectTwists the middle of the picture round its centre, most at the centre and easing to nothing at the edge of a circle.
class VignetteEffectDarkens the picture towards its corners, the way a lens falls off at the edge of its coverage, drawing the eye to the middle.
class WaterRippleEffectRipples the picture in rings spreading out from a point, as if a stone had dropped into still water there.
class WaterWaveEffectWobbles the picture in fine waves across and down it, as if seen through moving water or heat haze.