HypernovaDesktop Components · docs
Binarymission
WPF › Shaders Library › HexPixellateEffect

HexPixellateEffect

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Shaders.Library.CustomEffects

Turns the picture into a mosaic of flat-coloured hexagons, each the colour of the picture at its centre.

public class HexPixellateEffect : ShaderEffect

Inherits from / implements: ShaderEffect

Remarks

The hexagonal counterpart of PixellatingEffect. Animating HexSize down from something large resolves the picture out of the mosaic – a striking reveal for a photograph or a screenshot.

Settings

PropertyRange and default

HexSize

Width of one hexagon, as a fraction of the element: 0.04, the default, gives about twenty-five across. Values below 0.002 count as 0.002.

Examples

A photograph that resolves out of the mosaic as it loads.

<Image Source="Photos/harbour.jpg"
       xmlns:fx="clr-namespace:Binarymission.WPF.Shaders.Library.CustomEffects;assembly=Binarymission.WPF.Shaders.Library">
    <Image.Effect>
        <fx:HexPixellateEffect x:Name="Mosaic" HexSize="0.1" />
    </Image.Effect>
    <Image.Triggers>
        <EventTrigger RoutedEvent="Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="Mosaic" Storyboard.TargetProperty="HexSize"
                                     To="0.002" Duration="0:0:1.5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Image.Triggers>
</Image>

See also

Members at a glance

Constructors
HexPixellateEffectCreates the effect with its default settings: HexSize 0.04.
Properties
HexSizeGets or sets the size of the hexagons.
InputGets or sets the picture the effect works on.
Fields
HexSizePropertyIdentifies the HexSize dependency property.
InputPropertyIdentifies the Input dependency property.

Constructors

HexPixellateEffect

public HexPixellateEffect()

Creates the effect with its default settings: HexSize 0.04.

Properties

HexSize

public double HexSize

Gets or sets the size of the hexagons.

Value
The width of one hexagon as a fraction of the element's width: the default, 0.04, gives about twenty-five across. Values below 0.002 count as 0.002, the finest mosaic.

Input

public Brush Input

Gets or sets the picture the effect works on.

Value
A brush. The default is the element the effect is applied to, as WPF renders it – the effect's implicit input.
Remarks

Leave it unset in the usual case, where the effect is set as an element's Effect. Set it to a ImageBrush or VisualBrush to have the effect work on that picture instead.

Fields

HexSizeProperty static

public static readonly DependencyProperty HexSizeProperty

Identifies the HexSize dependency property.

InputProperty static

public static readonly DependencyProperty InputProperty

Identifies the Input dependency property.