Last active
May 7, 2026 06:08
-
-
Save cnbluefire/5c4bf20b83989a1c40b328a83f593da1 to your computer and use it in GitHub Desktop.
Composition effect brush without Win2D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Concurrent; | |
| using System.Diagnostics.CodeAnalysis; | |
| using System.Numerics; | |
| using System.Runtime.CompilerServices; | |
| using System.Runtime.InteropServices; | |
| using System.Runtime.InteropServices.Marshalling; | |
| using Windows.UI.Composition; | |
| using WinRT; | |
| namespace CompositionEffects; | |
| public sealed class AlphaMaskEffect : CompositionEffectWithSingleSource<AlphaMaskEffect> | |
| { | |
| public AlphaMaskEffect() : base(CompositionEffectClsids.CLSID_D2D1AlphaMask, 0, 2) | |
| { | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Mask | |
| { | |
| get => Sources[1]; | |
| set => Sources[1] = value; | |
| } | |
| } | |
| public sealed class ArithmeticCompositeEffect : CompositionEffect<ArithmeticCompositeEffect> | |
| { | |
| public ArithmeticCompositeEffect() : base(CompositionEffectClsids.CLSID_D2D1ArithmeticComposite, 2, 2) | |
| { | |
| DefineNamedProperty("MultiplyAmount", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX); | |
| DefineNamedProperty("Source1Amount", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY); | |
| DefineNamedProperty("Source2Amount", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ); | |
| DefineNamedProperty("Offset", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW); | |
| DefineNamedProperty("ClampOutput"); | |
| Properties[0] = new EffectProperty(new float[4] { 1f, 0f, 0f, 0f }); | |
| Properties[1] = new EffectProperty(false); | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Source1 | |
| { | |
| get => Sources[0]; | |
| set => Sources[0] = value; | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Source2 | |
| { | |
| get => Sources[1]; | |
| set => Sources[1] = value; | |
| } | |
| public float MultiplyAmount | |
| { | |
| get => Properties[0].GetValue<float[]>()![0]; | |
| set => Properties[0].GetValue<float[]>()![0] = value; | |
| } | |
| public float Source1Amount | |
| { | |
| get => Properties[0].GetValue<float[]>()![1]; | |
| set => Properties[0].GetValue<float[]>()![1] = value; | |
| } | |
| public float Source2Amount | |
| { | |
| get => Properties[0].GetValue<float[]>()![2]; | |
| set => Properties[0].GetValue<float[]>()![2] = value; | |
| } | |
| public float Offset | |
| { | |
| get => Properties[0].GetValue<float[]>()![3]; | |
| set => Properties[0].GetValue<float[]>()![3] = value; | |
| } | |
| public bool ClampOutput | |
| { | |
| get => Properties[1].GetValue<bool>(); | |
| set => Properties[1].Value = value; | |
| } | |
| } | |
| public sealed class BlendEffect : CompositionEffect<BlendEffect> | |
| { | |
| public BlendEffect() : base(CompositionEffectClsids.CLSID_D2D1Blend, 1, 2) | |
| { | |
| DefineNamedProperty("Mode"); | |
| Properties[0] = EffectProperty.CreateUInt32EnumProperty(BlendEffectMode.Multiply); | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Background | |
| { | |
| get => Sources[0]; | |
| set => Sources[0] = value; | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Foreground | |
| { | |
| get => Sources[1]; | |
| set => Sources[1] = value; | |
| } | |
| public BlendEffectMode Mode | |
| { | |
| get => Properties[0].GetValue<BlendEffectMode>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public enum BlendEffectMode : uint | |
| { | |
| Multiply = 0, | |
| Screen = 1, | |
| Darken = 2, | |
| Lighten = 3, | |
| Dissolve = 4, | |
| ColorBurn = 5, | |
| LinearBurn = 6, | |
| DarkerColor = 7, | |
| LighterColor = 8, | |
| ColorDodge = 9, | |
| LinearDodge = 10, | |
| Overlay = 11, | |
| SoftLight = 12, | |
| HardLight = 13, | |
| VividLight = 14, | |
| LinearLight = 15, | |
| PinLight = 16, | |
| HardMix = 17, | |
| Difference = 18, | |
| Exclusion = 19, | |
| Hue = 20, | |
| Saturation = 21, | |
| Color = 22, | |
| Luminosity = 23, | |
| Subtract = 24, | |
| Division = 25 | |
| } | |
| } | |
| public sealed class BorderEffect : CompositionEffectWithSingleSource<BorderEffect> | |
| { | |
| public BorderEffect() : base(CompositionEffectClsids.CLSID_D2D1Border, 2) | |
| { | |
| DefineNamedProperty("ExtendX"); | |
| DefineNamedProperty("ExtendY"); | |
| Properties[0] = EffectProperty.CreateUInt32EnumProperty(EdgeBehavior.Clamp); | |
| Properties[1] = EffectProperty.CreateUInt32EnumProperty(EdgeBehavior.Clamp); | |
| } | |
| public EdgeBehavior ExtendX | |
| { | |
| get => Properties[0].GetValue<EdgeBehavior>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public EdgeBehavior ExtendY | |
| { | |
| get => Properties[1].GetValue<EdgeBehavior>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public enum EdgeBehavior : uint | |
| { | |
| Clamp = 0, | |
| Wrap = 1, | |
| Mirror = 2 | |
| } | |
| } | |
| public sealed class ColorMatrixEffect : CompositionEffectWithSingleSource<ColorMatrixEffect> | |
| { | |
| public ColorMatrixEffect() : base(CompositionEffectClsids.CLSID_D2D1ColorMatrix, 3) | |
| { | |
| DefineNamedProperty("ColorMatrix"); | |
| DefineNamedProperty("AlphaMode", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE); | |
| DefineNamedProperty("ClampOutput"); | |
| Properties[0] = EffectProperty.CreateMatrix5x4Property(Matrix5x4.Identity); | |
| Properties[1] = EffectProperty.CreateEffectAlphaModeProperty(EffectAlphaMode.Premultiplied); | |
| Properties[2] = EffectProperty.Create(false); | |
| } | |
| public Matrix5x4 ColorMatrix | |
| { | |
| get => Properties[0].GetValue<Matrix5x4>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public EffectAlphaMode AlphaMode | |
| { | |
| get => Properties[1].GetValue<EffectAlphaMode>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public bool ClampOutput | |
| { | |
| get => Properties[2].GetValue<bool>(); | |
| set => Properties[2].Value = value; | |
| } | |
| } | |
| public sealed class ColorSourceEffect : CompositionEffect<ColorSourceEffect> | |
| { | |
| public ColorSourceEffect() | |
| : base(CompositionEffectClsids.CLSID_D2D1Flood, 1, 0) | |
| { | |
| DefineNamedProperty("Color", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4); | |
| Properties[0] = EffectProperty.CreateColorProperty(Windows.UI.Color.FromArgb(255, 0, 0, 0)); | |
| } | |
| public Windows.UI.Color Color | |
| { | |
| get => Properties[0].GetValue<Windows.UI.Color>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class CompositeEffect : CompositionEffectWithSources<CompositeEffect> | |
| { | |
| public CompositeEffect() : base(CompositionEffectClsids.CLSID_D2D1Composite, 1) | |
| { | |
| DefineNamedProperty("CompositeMode"); | |
| Properties[0] = EffectProperty.CreateUInt32EnumProperty(CompositeMode.SourceOver); | |
| } | |
| public CompositeMode Mode | |
| { | |
| get => Properties[0].GetValue<CompositeMode>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public enum CompositeMode : uint | |
| { | |
| SourceOver = 0, | |
| DestinationOver = 1, | |
| SourceIn = 2, | |
| DestinationIn = 3, | |
| SourceOut = 4, | |
| DestinationOut = 5, | |
| SourceAtop = 6, | |
| DestinationAtop = 7, | |
| Xor = 8, | |
| Add = 9, | |
| Copy = 10, | |
| BoundedCopy = 11, | |
| MaskInvert = 12 | |
| } | |
| } | |
| public sealed class ContrastEffect : CompositionEffectWithSingleSource<ContrastEffect> | |
| { | |
| public ContrastEffect() : base(CompositionEffectClsids.CLSID_D2D1Contrast, 2) | |
| { | |
| DefineNamedProperty("Contrast"); | |
| DefineNamedProperty("ClampSource"); | |
| Properties[0] = EffectProperty.Create(0f, v => v is float and >= -1f and <= 1f); | |
| Properties[1] = EffectProperty.Create(false); | |
| } | |
| public float Contrast | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public bool ClampSource | |
| { | |
| get => Properties[1].GetValue<bool>(); | |
| set => Properties[1].Value = value; | |
| } | |
| } | |
| public sealed class CrossFadeEffect : CompositionEffect<CrossFadeEffect> | |
| { | |
| public CrossFadeEffect() : base(CompositionEffectClsids.CLSID_D2D1CrossFade, 1, 2) | |
| { | |
| DefineNamedProperty("CrossFade"); | |
| Properties[0] = EffectProperty.Create(0.5f, v => v is float and >= 0 and <= 1); | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Source2 | |
| { | |
| get => Sources[0]; | |
| set => Sources[0] = value; | |
| } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Source1 | |
| { | |
| get => Sources[1]; | |
| set => Sources[1] = value; | |
| } | |
| public float CrossFade | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class DistantDiffuseEffect : CompositionEffectWithSingleSource<DistantDiffuseEffect> | |
| { | |
| public DistantDiffuseEffect() : base(CompositionEffectClsids.CLSID_D2D1DistantDiffuse, 7) | |
| { | |
| DefineNamedProperty("Azimuth", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("Elevation", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("DiffuseAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateDegreesToRadiansProperty(0f); | |
| Properties[1] = EffectProperty.CreateDegreesToRadiansProperty(0f); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[3] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[4] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[5] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[6] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public float Azimuth | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float Elevation | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float DiffuseAmount | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[4].GetValue<Windows.UI.Color>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[5].GetValue<Vector2>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[6].GetValue<EffectImageInterpolation>(); | |
| set => Properties[6].Value = value; | |
| } | |
| } | |
| public sealed class DistantSpecularEffect : CompositionEffectWithSingleSource<DistantSpecularEffect> | |
| { | |
| public DistantSpecularEffect() : base(CompositionEffectClsids.CLSID_D2D1DistantSpecular, 8) | |
| { | |
| DefineNamedProperty("Azimuth", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("Elevation", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("SpecularExponent"); | |
| DefineNamedProperty("SpecularAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateDegreesToRadiansProperty(0f); | |
| Properties[1] = EffectProperty.CreateDegreesToRadiansProperty(0f); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[4] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[5] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[6] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[7] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public float Azimuth | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float Elevation | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float SpecularExponent | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float SpecularAmount | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[4].GetValue<float>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[5].GetValue<Windows.UI.Color>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[6].GetValue<Vector2>(); | |
| set => Properties[6].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[7].GetValue<EffectImageInterpolation>(); | |
| set => Properties[7].Value = value; | |
| } | |
| } | |
| public sealed class ExposureEffect : CompositionEffectWithSingleSource<ExposureEffect> | |
| { | |
| public ExposureEffect() : base(CompositionEffectClsids.CLSID_D2D1Exposure, 1) | |
| { | |
| DefineNamedProperty("Exposure"); | |
| Properties[0] = EffectProperty.Create(0f, v => v is float and >= -2f and <= 2f); | |
| } | |
| public float Exposure | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class GammaTransferEffect : CompositionEffectWithSingleSource<GammaTransferEffect> | |
| { | |
| public GammaTransferEffect() : base(CompositionEffectClsids.CLSID_D2D1GammaTransfer, 17) | |
| { | |
| DefineNamedProperty("RedAmplitude"); | |
| DefineNamedProperty("RedExponent"); | |
| DefineNamedProperty("RedOffset"); | |
| DefineNamedProperty("RedDisable"); | |
| DefineNamedProperty("GreenAmplitude"); | |
| DefineNamedProperty("GreenExponent"); | |
| DefineNamedProperty("GreenOffset"); | |
| DefineNamedProperty("GreenDisable"); | |
| DefineNamedProperty("BlueAmplitude"); | |
| DefineNamedProperty("BlueExponent"); | |
| DefineNamedProperty("BlueOffset"); | |
| DefineNamedProperty("BlueDisable"); | |
| DefineNamedProperty("AlphaAmplitude"); | |
| DefineNamedProperty("AlphaExponent"); | |
| DefineNamedProperty("AlphaOffset"); | |
| DefineNamedProperty("AlphaDisable"); | |
| DefineNamedProperty("ClampOutput"); | |
| Properties[0] = EffectProperty.Create(1.0f); | |
| Properties[1] = EffectProperty.Create(1.0f); | |
| Properties[2] = EffectProperty.Create(0.0f); | |
| Properties[3] = EffectProperty.Create(false); | |
| Properties[4] = EffectProperty.Create(1.0f); | |
| Properties[5] = EffectProperty.Create(1.0f); | |
| Properties[6] = EffectProperty.Create(0.0f); | |
| Properties[7] = EffectProperty.Create(false); | |
| Properties[8] = EffectProperty.Create(1.0f); | |
| Properties[9] = EffectProperty.Create(1.0f); | |
| Properties[10] = EffectProperty.Create(0.0f); | |
| Properties[11] = EffectProperty.Create(false); | |
| Properties[12] = EffectProperty.Create(1.0f); | |
| Properties[13] = EffectProperty.Create(1.0f); | |
| Properties[14] = EffectProperty.Create(0.0f); | |
| Properties[15] = EffectProperty.Create(false); | |
| Properties[16] = EffectProperty.Create(false); | |
| } | |
| public float RedAmplitude | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float RedExponent | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float RedOffset | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public bool RedDisable | |
| { | |
| get => Properties[3].GetValue<bool>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public float GreenAmplitude | |
| { | |
| get => Properties[4].GetValue<float>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public float GreenExponent | |
| { | |
| get => Properties[5].GetValue<float>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public float GreenOffset | |
| { | |
| get => Properties[6].GetValue<float>(); | |
| set => Properties[6].Value = value; | |
| } | |
| public bool GreenDisable | |
| { | |
| get => Properties[7].GetValue<bool>(); | |
| set => Properties[7].Value = value; | |
| } | |
| public float BlueAmplitude | |
| { | |
| get => Properties[8].GetValue<float>(); | |
| set => Properties[8].Value = value; | |
| } | |
| public float BlueExponent | |
| { | |
| get => Properties[9].GetValue<float>(); | |
| set => Properties[9].Value = value; | |
| } | |
| public float BlueOffset | |
| { | |
| get => Properties[10].GetValue<float>(); | |
| set => Properties[10].Value = value; | |
| } | |
| public bool BlueDisable | |
| { | |
| get => Properties[11].GetValue<bool>(); | |
| set => Properties[11].Value = value; | |
| } | |
| public float AlphaAmplitude | |
| { | |
| get => Properties[12].GetValue<float>(); | |
| set => Properties[12].Value = value; | |
| } | |
| public float AlphaExponent | |
| { | |
| get => Properties[13].GetValue<float>(); | |
| set => Properties[13].Value = value; | |
| } | |
| public float AlphaOffset | |
| { | |
| get => Properties[14].GetValue<float>(); | |
| set => Properties[14].Value = value; | |
| } | |
| public bool AlphaDisable | |
| { | |
| get => Properties[15].GetValue<bool>(); | |
| set => Properties[15].Value = value; | |
| } | |
| public bool ClampOutput | |
| { | |
| get => Properties[16].GetValue<bool>(); | |
| set => Properties[16].Value = value; | |
| } | |
| } | |
| public class GaussianBlurEffect : CompositionEffectWithSingleSource<GaussianBlurEffect> | |
| { | |
| public GaussianBlurEffect() : base(CompositionEffectClsids.CLSID_D2D1GaussianBlur, 3) | |
| { | |
| DefineNamedProperty("BlurAmount"); | |
| DefineNamedProperty("Optimization"); | |
| DefineNamedProperty("BorderMode"); | |
| Properties[0] = EffectProperty.Create(3f, v => v is float and >= 0f and <= 250f); | |
| Properties[1] = EffectProperty.CreateUInt32EnumProperty(EffectOptimization.Balanced); | |
| Properties[2] = EffectProperty.CreateUInt32EnumProperty(EffectBorderMode.Soft); | |
| } | |
| public float BlurAmount | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public EffectOptimization Optimization | |
| { | |
| get => Properties[1].GetValue<EffectOptimization>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public EffectBorderMode BorderMode | |
| { | |
| get => Properties[2].GetValue<EffectBorderMode>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public enum EffectOptimization : uint | |
| { | |
| Speed = 0, | |
| Balanced = 1, | |
| Quality = 2 | |
| } | |
| } | |
| public sealed class GrayscaleEffect : CompositionEffectWithSingleSource<GrayscaleEffect> | |
| { | |
| public GrayscaleEffect() : base(CompositionEffectClsids.CLSID_D2D1Grayscale, 0) { } | |
| } | |
| public sealed class HueRotationEffect : CompositionEffectWithSingleSource<HueRotationEffect> | |
| { | |
| public HueRotationEffect() : base(CompositionEffectClsids.CLSID_D2D1HueRotation, 1) | |
| { | |
| DefineNamedProperty("Angle", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| Properties[0] = EffectProperty.CreateDegreesToRadiansProperty(0f); | |
| } | |
| public float Angle | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class InvertEffect : CompositionEffectWithSingleSource<InvertEffect> | |
| { | |
| public InvertEffect() : base(CompositionEffectClsids.CLSID_D2D1Invert, 0) { } | |
| } | |
| public sealed class LinearTransferEffect : CompositionEffectWithSingleSource<LinearTransferEffect> | |
| { | |
| public LinearTransferEffect() : base(CompositionEffectClsids.CLSID_D2D1LinearTransfer, 13) | |
| { | |
| DefineNamedProperty("RedOffset"); | |
| DefineNamedProperty("RedSlope"); | |
| DefineNamedProperty("RedDisable"); | |
| DefineNamedProperty("GreenOffset"); | |
| DefineNamedProperty("GreenSlope"); | |
| DefineNamedProperty("GreenDisable"); | |
| DefineNamedProperty("BlueOffset"); | |
| DefineNamedProperty("BlueSlope"); | |
| DefineNamedProperty("BlueDisable"); | |
| DefineNamedProperty("AlphaOffset"); | |
| DefineNamedProperty("AlphaSlope"); | |
| DefineNamedProperty("AlphaDisable"); | |
| DefineNamedProperty("ClampOutput"); | |
| Properties[0] = EffectProperty.Create(0.0f); | |
| Properties[1] = EffectProperty.Create(1.0f); | |
| Properties[2] = EffectProperty.Create(false); | |
| Properties[3] = EffectProperty.Create(0.0f); | |
| Properties[4] = EffectProperty.Create(1.0f); | |
| Properties[5] = EffectProperty.Create(false); | |
| Properties[6] = EffectProperty.Create(0.0f); | |
| Properties[7] = EffectProperty.Create(1.0f); | |
| Properties[8] = EffectProperty.Create(false); | |
| Properties[9] = EffectProperty.Create(0.0f); | |
| Properties[10] = EffectProperty.Create(1.0f); | |
| Properties[11] = EffectProperty.Create(false); | |
| Properties[12] = EffectProperty.Create(false); | |
| } | |
| public float RedOffset | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float RedSlope | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public bool RedDisable | |
| { | |
| get => Properties[2].GetValue<bool>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float GreenOffset | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public float GreenSlope | |
| { | |
| get => Properties[4].GetValue<float>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public bool GreenDisable | |
| { | |
| get => Properties[5].GetValue<bool>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public float BlueOffset | |
| { | |
| get => Properties[6].GetValue<float>(); | |
| set => Properties[6].Value = value; | |
| } | |
| public float BlueSlope | |
| { | |
| get => Properties[7].GetValue<float>(); | |
| set => Properties[7].Value = value; | |
| } | |
| public bool BlueDisable | |
| { | |
| get => Properties[8].GetValue<bool>(); | |
| set => Properties[8].Value = value; | |
| } | |
| public float AlphaOffset | |
| { | |
| get => Properties[9].GetValue<float>(); | |
| set => Properties[9].Value = value; | |
| } | |
| public float AlphaSlope | |
| { | |
| get => Properties[10].GetValue<float>(); | |
| set => Properties[10].Value = value; | |
| } | |
| public bool AlphaDisable | |
| { | |
| get => Properties[11].GetValue<bool>(); | |
| set => Properties[11].Value = value; | |
| } | |
| public bool ClampOutput | |
| { | |
| get => Properties[12].GetValue<bool>(); | |
| set => Properties[12].Value = value; | |
| } | |
| } | |
| public sealed class LuminanceToAlphaEffect : CompositionEffectWithSingleSource<LuminanceToAlphaEffect> | |
| { | |
| public LuminanceToAlphaEffect() : base(CompositionEffectClsids.CLSID_D2D1LuminanceToAlpha, 0) { } | |
| } | |
| public sealed class OpacityEffect : CompositionEffectWithSingleSource<OpacityEffect> | |
| { | |
| public OpacityEffect() : base(CompositionEffectClsids.CLSID_D2D1Opacity, 1) | |
| { | |
| DefineNamedProperty("Opacity"); | |
| Properties[0] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 1f); | |
| } | |
| public float Opacity | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class PointDiffuseEffect : CompositionEffectWithSingleSource<PointDiffuseEffect> | |
| { | |
| public PointDiffuseEffect() : base(CompositionEffectClsids.CLSID_D2D1PointDiffuse, 6) | |
| { | |
| DefineNamedProperty("LightPosition"); | |
| DefineNamedProperty("DiffuseAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[1] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[4] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[5] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public Vector3 LightPosition | |
| { | |
| get => Properties[0].GetValue<Vector3>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float DiffuseAmount | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[3].GetValue<Windows.UI.Color>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[4].GetValue<Vector2>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[5].GetValue<EffectImageInterpolation>(); | |
| set => Properties[5].Value = value; | |
| } | |
| } | |
| public sealed class PointSpecularEffect : CompositionEffectWithSingleSource<PointSpecularEffect> | |
| { | |
| public PointSpecularEffect() : base(CompositionEffectClsids.CLSID_D2D1PointSpecular, 6) | |
| { | |
| DefineNamedProperty("LightPosition"); | |
| DefineNamedProperty("SpecularExponent"); | |
| DefineNamedProperty("SpecularAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[4] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[5] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public Vector3 LightPosition | |
| { | |
| get => Properties[0].GetValue<Vector3>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float SpecularExponent | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float SpecularAmount | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[4].GetValue<Windows.UI.Color>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[5].GetValue<Vector2>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[6].GetValue<EffectImageInterpolation>(); | |
| set => Properties[6].Value = value; | |
| } | |
| } | |
| public abstract class PosterizeEffect : CompositionEffectWithSingleSource<PosterizeEffect> | |
| { | |
| public PosterizeEffect() : base(CompositionEffectClsids.CLSID_D2D1Posterize, 3) | |
| { | |
| DefineNamedProperty("RedValueCount"); | |
| DefineNamedProperty("GreenValueCount"); | |
| DefineNamedProperty("BlueValueCount"); | |
| Properties[0] = EffectProperty.Create(4, v => v is int and >= 2 and <= 16); | |
| Properties[1] = EffectProperty.Create(4, v => v is int and >= 2 and <= 16); | |
| Properties[2] = EffectProperty.Create(4, v => v is int and >= 2 and <= 16); | |
| } | |
| public int RedValueCount | |
| { | |
| get => Properties[0].GetValue<int>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public int GreenValueCount | |
| { | |
| get => Properties[1].GetValue<int>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public int BlueValueCount | |
| { | |
| get => Properties[2].GetValue<int>(); | |
| set => Properties[2].Value = value; | |
| } | |
| } | |
| public sealed class PremultiplyEffect : CompositionEffectWithSingleSource<PremultiplyEffect> | |
| { | |
| public PremultiplyEffect() : base(CompositionEffectClsids.CLSID_D2D1Premultiply, 0) { } | |
| } | |
| public sealed class SaturationEffect : CompositionEffectWithSingleSource<SaturationEffect> | |
| { | |
| public SaturationEffect() : base(CompositionEffectClsids.CLSID_D2D1Saturation, 1) | |
| { | |
| DefineNamedProperty("Saturation"); | |
| Properties[0] = EffectProperty.Create(0.5f, v => v is float and >= 0f and <= 2f); | |
| } | |
| public float Saturation | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class SepiaEffect : CompositionEffectWithSingleSource<SepiaEffect> | |
| { | |
| public SepiaEffect() : base(CompositionEffectClsids.CLSID_D2D1Sepia, 1) | |
| { | |
| DefineNamedProperty("Intensity"); | |
| DefineNamedProperty("AlphaMode", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE); | |
| Properties[0] = EffectProperty.Create(0.5f, v => v is float and >= 0f and <= 1f); | |
| Properties[1] = EffectProperty.CreateEffectAlphaModeProperty(EffectAlphaMode.Premultiplied); | |
| } | |
| public float Intensity | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public EffectAlphaMode AlphaMode | |
| { | |
| get => Properties[1].GetValue<EffectAlphaMode>(); | |
| set => Properties[1].Value = value; | |
| } | |
| } | |
| public sealed class SpotDiffuseEffect : CompositionEffectWithSingleSource<SpotDiffuseEffect> | |
| { | |
| public SpotDiffuseEffect() : base(CompositionEffectClsids.CLSID_D2D1SpotDiffuse, 9) | |
| { | |
| DefineNamedProperty("LightPosition"); | |
| DefineNamedProperty("LightTarget"); | |
| DefineNamedProperty("Focus"); | |
| DefineNamedProperty("LimitingConeAngle", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("DiffuseAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[1] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.CreateDegreesToRadiansProperty(MathF.PI / 2); | |
| Properties[4] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[5] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[6] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[7] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[8] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public Vector3 LightPosition | |
| { | |
| get => Properties[0].GetValue<Vector3>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public Vector3 LightTarget | |
| { | |
| get => Properties[1].GetValue<Vector3>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float Focus | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float LimitingConeAngle | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public float DiffuseAmount | |
| { | |
| get => Properties[4].GetValue<float>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[5].GetValue<float>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[6].GetValue<Windows.UI.Color>(); | |
| set => Properties[6].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[7].GetValue<Vector2>(); | |
| set => Properties[7].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[8].GetValue<EffectImageInterpolation>(); | |
| set => Properties[8].Value = value; | |
| } | |
| } | |
| public sealed class SpotSpecularEffect : CompositionEffectWithSingleSource<SpotSpecularEffect> | |
| { | |
| public SpotSpecularEffect() : base(CompositionEffectClsids.CLSID_D2D1SpotSpecular, 9) | |
| { | |
| DefineNamedProperty("LightPosition"); | |
| DefineNamedProperty("LightTarget"); | |
| DefineNamedProperty("Focus"); | |
| DefineNamedProperty("LimitingConeAngle", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES); | |
| DefineNamedProperty("SpecularExponent"); | |
| DefineNamedProperty("SpecularAmount"); | |
| DefineNamedProperty("HeightMapScale"); | |
| DefineNamedProperty("LightColor", GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3); | |
| DefineNamedProperty("HeightMapKernelSize"); | |
| DefineNamedProperty("HeightMapInterpolationMode"); | |
| Properties[0] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[1] = EffectProperty.CreateVectorProperty(Vector3.Zero); | |
| Properties[2] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[3] = EffectProperty.CreateDegreesToRadiansProperty(MathF.PI / 2); | |
| Properties[4] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[5] = EffectProperty.Create(1f, v => v is float and >= 0f and <= 10000f); | |
| Properties[6] = EffectProperty.Create(1f, v => v is float and >= -10000f and <= 10000f); | |
| Properties[7] = EffectProperty.CreateColor3Property(Windows.UI.Color.FromArgb(255, 255, 255, 255)); | |
| Properties[8] = EffectProperty.CreateVectorProperty(Vector2.One, v => v is Vector2 { X: > 0.01f and < 100f, Y: > 0.01f and < 100f }); | |
| Properties[9] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| } | |
| public Vector3 LightPosition | |
| { | |
| get => Properties[0].GetValue<Vector3>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public Vector3 LightTarget | |
| { | |
| get => Properties[1].GetValue<Vector3>(); | |
| set => Properties[1].Value = value; | |
| } | |
| public float Focus | |
| { | |
| get => Properties[2].GetValue<float>(); | |
| set => Properties[2].Value = value; | |
| } | |
| public float LimitingConeAngle | |
| { | |
| get => Properties[3].GetValue<float>(); | |
| set => Properties[3].Value = value; | |
| } | |
| public float SpecularExponent | |
| { | |
| get => Properties[4].GetValue<float>(); | |
| set => Properties[4].Value = value; | |
| } | |
| public float SpecularAmount | |
| { | |
| get => Properties[5].GetValue<float>(); | |
| set => Properties[5].Value = value; | |
| } | |
| public float HeightMapScale | |
| { | |
| get => Properties[6].GetValue<float>(); | |
| set => Properties[6].Value = value; | |
| } | |
| public Windows.UI.Color LightColor | |
| { | |
| get => Properties[7].GetValue<Windows.UI.Color>(); | |
| set => Properties[7].Value = value; | |
| } | |
| public Vector2 HeightMapKernelSize | |
| { | |
| get => Properties[8].GetValue<Vector2>(); | |
| set => Properties[8].Value = value; | |
| } | |
| public EffectImageInterpolation HeightMapInterpolationMode | |
| { | |
| get => Properties[9].GetValue<EffectImageInterpolation>(); | |
| set => Properties[9].Value = value; | |
| } | |
| } | |
| public sealed class TemperatureAndTintEffect : CompositionEffectWithSingleSource<TemperatureAndTintEffect> | |
| { | |
| public TemperatureAndTintEffect() : base(CompositionEffectClsids.CLSID_D2D1TemperatureTint, 2) | |
| { | |
| DefineNamedProperty("Temperature"); | |
| DefineNamedProperty("Tint"); | |
| Properties[0] = EffectProperty.Create(0f, v => v is float and >= -1f and <= 1f); | |
| Properties[1] = EffectProperty.Create(0f, v => v is float and >= -1f and <= 1f); | |
| } | |
| public float Temperature | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float Tint | |
| { | |
| get => Properties[1].GetValue<float>(); | |
| set => Properties[1].Value = value; | |
| } | |
| } | |
| public sealed class TintEffect : CompositionEffectWithSingleSource<TintEffect> | |
| { | |
| public TintEffect() : base(CompositionEffectClsids.CLSID_D2D1Tint, 2) | |
| { | |
| DefineNamedProperty("Temperature"); | |
| DefineNamedProperty("Tint"); | |
| Properties[0] = EffectProperty.CreateColorProperty(Windows.UI.Color.FromArgb(255, 0, 0, 0)); | |
| Properties[1] = EffectProperty.Create(false); | |
| } | |
| public Windows.UI.Color Color | |
| { | |
| get => Properties[0].GetValue<Windows.UI.Color>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public bool ClampOutput | |
| { | |
| get => Properties[1].GetValue<bool>(); | |
| set => Properties[1].Value = value; | |
| } | |
| } | |
| public sealed class Transform2DEffect : CompositionEffectWithSingleSource<Transform2DEffect> | |
| { | |
| public Transform2DEffect() : base(CompositionEffectClsids.CLSID_D2D12DAffineTransform, 4) | |
| { | |
| DefineNamedProperty("InterpolationMode"); | |
| DefineNamedProperty("BorderMode"); | |
| DefineNamedProperty("TransformMatrix"); | |
| DefineNamedProperty("Sharpness"); | |
| Properties[0] = EffectProperty.CreateUInt32EnumProperty(EffectImageInterpolation.Linear); | |
| Properties[1] = EffectProperty.CreateUInt32EnumProperty(EffectBorderMode.Soft); | |
| Properties[2] = EffectProperty.CreateMatrix3x2Property(Matrix3x2.Identity); | |
| Properties[3] = EffectProperty.Create(0f, v => v is float and >= 0f and <= 1f); | |
| } | |
| public EffectImageInterpolation InterpolationMode | |
| { | |
| get => Properties[0].GetValue<EffectImageInterpolation>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public EffectBorderMode BorderMode | |
| { | |
| get => Properties[0].GetValue<EffectBorderMode>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public Matrix3x2 TransformMatrix | |
| { | |
| get => Properties[0].GetValue<Matrix3x2>(); | |
| set => Properties[0].Value = value; | |
| } | |
| public float Sharpness | |
| { | |
| get => Properties[0].GetValue<float>(); | |
| set => Properties[0].Value = value; | |
| } | |
| } | |
| public sealed class UnPremultiplyEffect : CompositionEffectWithSingleSource<UnPremultiplyEffect> | |
| { | |
| public UnPremultiplyEffect() : base(CompositionEffectClsids.CLSID_D2D1UnPremultiply, 0) { } | |
| } | |
| public abstract class CompositionEffectWithSingleSource<T> : CompositionEffect<T> where T : CompositionEffect<T> | |
| { | |
| protected CompositionEffectWithSingleSource(Guid effectId, int propertyCount, int sourceCount = 1) | |
| : base(effectId, propertyCount, sourceCount > 0 ? sourceCount : throw new ArgumentOutOfRangeException(nameof(sourceCount))) { } | |
| public global::Windows.Graphics.Effects.IGraphicsEffectSource? Source | |
| { | |
| get => Sources[0]; | |
| set => Sources[0] = value; | |
| } | |
| } | |
| public abstract class CompositionEffectWithSources<T> : CompositionEffect<T> where T : CompositionEffect<T> | |
| { | |
| protected CompositionEffectWithSources(Guid effectId, int propertyCount) | |
| : base(effectId, propertyCount, null) { } | |
| public new IList<global::Windows.Graphics.Effects.IGraphicsEffectSource> Sources => (IList<global::Windows.Graphics.Effects.IGraphicsEffectSource>)base.Sources; | |
| } | |
| public abstract class CompositionEffect<T> : CompositionEffect where T : CompositionEffect<T> | |
| { | |
| protected CompositionEffect(Guid effectId, int propertyCount, int? sourceCount) | |
| : base(typeof(T).FullName!, effectId, propertyCount, sourceCount) { } | |
| } | |
| public abstract unsafe partial class CompositionEffect | |
| { | |
| private CompositionEffectImpl impl; | |
| protected CompositionEffect( | |
| string runtimeClassName, | |
| Guid effectId, | |
| int propertyCount, | |
| int? sourceCount) | |
| { | |
| ArgumentException.ThrowIfNullOrEmpty(runtimeClassName); | |
| impl = new CompositionEffectImpl(runtimeClassName, effectId, propertyCount, sourceCount); | |
| } | |
| public string? Name | |
| { | |
| get => impl.Name; | |
| set => impl.Name = value; | |
| } | |
| protected IList<global::Windows.Graphics.Effects.IGraphicsEffectSource?> Sources => impl.Sources; | |
| protected IList<EffectProperty> Properties => impl.Properties; | |
| protected void DefineNamedProperty(string name, GRAPHICS_EFFECT_PROPERTY_MAPPING mapping = GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT) | |
| { | |
| for (int i = 0; i < impl.PropertyNames.Count; i++) | |
| { | |
| if (impl.PropertyNames[i].Name == name) | |
| { | |
| throw new ArgumentException(nameof(name)); | |
| } | |
| } | |
| impl.PropertyNames.Add(new EffectPropertyName(name, mapping)); | |
| } | |
| public enum EffectAlphaMode : uint | |
| { | |
| Premultiplied = 0, | |
| Straight = 1, | |
| Ignore = 2 | |
| } | |
| public enum EffectBorderMode : uint | |
| { | |
| Soft = 0, | |
| Hard = 1 | |
| } | |
| public enum EffectImageInterpolation : uint | |
| { | |
| NearestNeighbor = 0, | |
| Linear = 1, | |
| Cubic = 2, | |
| MultiSampleLinear = 3, | |
| Anisotropic = 4, | |
| HighQualityCubic = 5 | |
| } | |
| [GeneratedComClass] | |
| internal partial class CompositionEffectImpl : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | |
| { | |
| private const int S_OK = 0; | |
| private const int E_INVALIDARG = unchecked((int)0x80070057); | |
| private const int E_BOUNDS = unchecked((int)0x8000000B); | |
| private const int E_POINTER = unchecked((int)0x80004003); | |
| private static readonly Guid IID_IPropertyValue = new Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62"); | |
| private static int iidCount = 0; | |
| private static Guid* iids; | |
| static CompositionEffectImpl() | |
| { | |
| iidCount = 5; | |
| iids = (Guid*)NativeMemory.Alloc((nuint)(sizeof(Guid) * iidCount)); | |
| iids[0] = WinRT.Interop.IID.IID_IUnknown; | |
| iids[1] = WinRT.Interop.IID.IID_IInspectable; | |
| iids[2] = typeof(IGraphicsEffectSource).GUID; | |
| iids[3] = typeof(IGraphicsEffect).GUID; | |
| iids[4] = typeof(IGraphicsEffectD2D1Interop).GUID; | |
| } | |
| private string runtimeClassName; | |
| private string? name; | |
| private readonly Guid effectId; | |
| private IList<EffectProperty> properties; | |
| private List<EffectPropertyName> propertyNames; | |
| private IList<global::Windows.Graphics.Effects.IGraphicsEffectSource?> sources; | |
| internal CompositionEffectImpl( | |
| string runtimeClassName, | |
| Guid effectId, | |
| int propertyCount, | |
| int? sourceCount) | |
| { | |
| this.runtimeClassName = runtimeClassName; | |
| this.effectId = effectId; | |
| this.properties = new EffectProperty[propertyCount]; | |
| this.propertyNames = new List<EffectPropertyName>(Math.Max(propertyCount * 2, 5)); | |
| if (sourceCount.HasValue) | |
| { | |
| this.sources = new global::Windows.Graphics.Effects.IGraphicsEffectSource[sourceCount.Value]; | |
| } | |
| else | |
| { | |
| this.sources = new List<global::Windows.Graphics.Effects.IGraphicsEffectSource?>(8); | |
| } | |
| } | |
| public string? Name | |
| { | |
| get => name; | |
| set => name = value; | |
| } | |
| public IList<EffectProperty> Properties => properties; | |
| public IList<EffectPropertyName> PropertyNames => propertyNames; | |
| public IList<global::Windows.Graphics.Effects.IGraphicsEffectSource?> Sources => sources; | |
| public int GetIids(int* iidCount, Guid** iids) | |
| { | |
| *iidCount = CompositionEffectImpl.iidCount; | |
| *iids = CompositionEffectImpl.iids; | |
| return S_OK; | |
| } | |
| public int GetRuntimeClassName(nint* className) | |
| { | |
| *className = MarshalString.FromManaged(runtimeClassName ?? ""); | |
| return S_OK; | |
| } | |
| public int GetTrustLevel(TrustLevel* trustLevel) | |
| { | |
| *trustLevel = TrustLevel.BaseTrust; | |
| return S_OK; | |
| } | |
| public int get_Name(nint* name) | |
| { | |
| if (name == null) return E_INVALIDARG; | |
| *name = MarshalString.FromManaged(this.name ?? ""); | |
| return S_OK; | |
| } | |
| public int put_Name(nint name) | |
| { | |
| if (name == 0) return E_INVALIDARG; | |
| this.name = MarshalString.FromAbi(name); | |
| return S_OK; | |
| } | |
| public int GetEffectId(Guid* id) | |
| { | |
| *id = effectId; | |
| return S_OK; | |
| } | |
| public int GetNamedPropertyMapping([MarshalAs(UnmanagedType.LPWStr)] string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) | |
| { | |
| index = 0; | |
| mapping = GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN; | |
| for (int i = 0; i < propertyNames.Count; i++) | |
| { | |
| if (propertyNames[i].Name == name) | |
| { | |
| index = (uint)i; | |
| mapping = propertyNames[i].Mapping; | |
| return S_OK; | |
| } | |
| } | |
| return E_INVALIDARG; | |
| } | |
| public int GetProperty(uint index, nint* value) | |
| { | |
| if (value == null) return E_INVALIDARG; | |
| if (index >= 0 && index < properties.Count) | |
| { | |
| var ptr = properties[(int)index].PropertyValue; | |
| if (ptr != 0) | |
| { | |
| var hr = Marshal.QueryInterface(ptr, IID_IPropertyValue, out var ppv); | |
| if (hr == S_OK) | |
| { | |
| *value = ppv; | |
| } | |
| return hr; | |
| } | |
| *value = 0; | |
| return S_OK; | |
| } | |
| return E_BOUNDS; | |
| } | |
| public int GetPropertyCount(out uint count) | |
| { | |
| count = (uint)properties.Count; | |
| return S_OK; | |
| } | |
| public int GetSource(int index, out nint source) | |
| { | |
| source = 0; | |
| if (index >= 0 && index < sources.Count) | |
| { | |
| if (sources[index] is null) | |
| { | |
| source = 0; | |
| return S_OK; | |
| } | |
| else if (TryGetIUnknownForObject(sources[index]!, out source)) | |
| { | |
| return S_OK; | |
| } | |
| else | |
| { | |
| return E_POINTER; | |
| } | |
| } | |
| return E_BOUNDS; | |
| } | |
| public int GetSourceCount(out uint count) | |
| { | |
| count = (uint)sources.Count; | |
| return S_OK; | |
| } | |
| private static bool TryGetIUnknownForObject(object obj, out nint pUnk) | |
| { | |
| pUnk = 0; | |
| if (obj is null) return false; | |
| if (ComWrappersSupport.TryUnwrapObject(obj, out var objRef)) | |
| { | |
| pUnk = objRef.ThisPtr; | |
| Marshal.AddRef(pUnk); | |
| return true; | |
| } | |
| else if (ComWrappers.TryGetComInstance(obj, out pUnk)) | |
| { | |
| return true; | |
| } | |
| else if (Marshal.IsComObject(obj)) | |
| { | |
| pUnk = Marshal.GetIUnknownForObject(obj); | |
| return true; | |
| } | |
| return false; | |
| } | |
| } | |
| public class EffectProperty | |
| { | |
| private Func<object?, object?>? convertToWinRTType; | |
| private readonly Func<object?, bool>? condition; | |
| private object? value; | |
| public EffectProperty( | |
| object? value = null, | |
| Func<object?, object?>? convertToWinRTType = null, | |
| Func<object?, bool>? condition = null) | |
| { | |
| this.Value = value; | |
| this.convertToWinRTType = convertToWinRTType; | |
| this.condition = condition; | |
| } | |
| public object? Value | |
| { | |
| get => value; | |
| set | |
| { | |
| if (!Equals(value, this.value)) | |
| { | |
| if (condition != null && !condition.Invoke(value)) | |
| { | |
| ThrowArgumentException("Value does not fall within the expected range.", nameof(Value)); | |
| [DoesNotReturn] | |
| static void ThrowArgumentException(string? message, string? paramName) | |
| { | |
| throw new ArgumentException(message, paramName); | |
| } | |
| } | |
| this.value = value; | |
| } | |
| } | |
| } | |
| public T? GetValue<T>(T? defaultValue = default) | |
| { | |
| if (Value is T value) return value; | |
| return defaultValue; | |
| } | |
| public nint PropertyValue | |
| { | |
| get | |
| { | |
| var value = this.value; | |
| if (value is not null && convertToWinRTType != null) | |
| { | |
| value = convertToWinRTType.Invoke(value); | |
| } | |
| if (value is null) return 0; | |
| return MarshalInspectable<object>.FromManaged(value); | |
| } | |
| } | |
| private static Func<object?, object?> s_ColorToFloat4ConvertFunc = ColorToFloat4Convert; | |
| private static Func<object?, object?> s_ColorToFloat3ConvertFunc = ColorToFloat3Convert; | |
| private static Func<object?, object?> s_EnumToUInt32ConvertFunc = EnumToUInt32ConvertFunc; | |
| private static Func<object?, object?> s_Matrix5x4ToFloat20ConvertFunc = Matrix5x4ToFloat20Convert; | |
| private static Func<object?, object?> s_EffectAlphaModeToD2D1AlphaModeConvertFunc = EffectAlphaModeToD2D1AlphaModeConvert; | |
| private static Func<object?, object?> s_DegreesToRadiansConvertFunc = DegreesToRadiansConvert; | |
| private static Func<object?, object?> s_VectorToFloatArrayConvertFunc = VectorToFloatArrayConvert; | |
| private static Func<object?, object?> s_Matrix3x2ToFloat6ConvertFunc = Matrix3x2ToFloat6Convert; | |
| private static object? ColorToFloat4Convert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| var c = (Windows.UI.Color)value; | |
| return new float[4] { c.R / 255f, c.G / 255f, c.B / 255f, c.A / 255f }; | |
| } | |
| private static object? ColorToFloat3Convert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| var c = (Windows.UI.Color)value; | |
| return new float[3] { c.R / 255f, c.G / 255f, c.B / 255f }; | |
| } | |
| private static object? EnumToUInt32ConvertFunc(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| return Convert.ToUInt32(value); | |
| } | |
| private static object? Matrix5x4ToFloat20Convert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| var m = (Matrix5x4)value; | |
| return MemoryMarshal.CreateSpan(ref m.M11, 20).ToArray(); | |
| } | |
| private static object? EffectAlphaModeToD2D1AlphaModeConvert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| return (EffectAlphaMode)value switch | |
| { | |
| EffectAlphaMode.Premultiplied => (uint)1, | |
| EffectAlphaMode.Straight => (uint)2, | |
| _ => throw new NotSupportedException() | |
| }; | |
| } | |
| public static object? DegreesToRadiansConvert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| return (float)value * 180.0f / MathF.PI; | |
| } | |
| public static object? VectorToFloatArrayConvert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| if (value is Vector2 v2) return new float[2] { v2.X, v2.Y }; | |
| if (value is Vector3 v3) return new float[3] { v3.X, v3.Y, v3.Z }; | |
| if (value is Vector4 v4) return new float[4] { v4.X, v4.Y, v4.Z, v4.W }; | |
| else ThrowArgumentException(null, nameof(value)); | |
| return default; | |
| [DoesNotReturn] | |
| static void ThrowArgumentException(string? message, string? paramName) | |
| { | |
| throw new ArgumentException(message, paramName); | |
| } | |
| } | |
| public static object? Matrix3x2ToFloat6Convert(object? value) | |
| { | |
| ArgumentNullException.ThrowIfNull(value); | |
| var m = (Matrix3x2)value; | |
| return MemoryMarshal.CreateSpan(ref m.M11, 6).ToArray(); | |
| } | |
| public static EffectProperty Create<T>(T? value = default, Func<T?, bool>? condition = null) | |
| => new EffectProperty(value, null, CreateCondition(condition)); | |
| public static EffectProperty CreateColorProperty(Windows.UI.Color value, Func<Windows.UI.Color, bool>? condition = null) | |
| => new EffectProperty(value, s_ColorToFloat4ConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateColor3Property(Windows.UI.Color value, Func<Windows.UI.Color, bool>? condition = null) | |
| => new EffectProperty(value, s_ColorToFloat3ConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateUInt32EnumProperty<T>(T value, Func<T, bool>? condition = null) where T : struct, Enum | |
| => new EffectProperty(value, s_EnumToUInt32ConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateMatrix5x4Property(Matrix5x4 value, Func<Matrix5x4, bool>? condition = null) | |
| => new EffectProperty(value, s_Matrix5x4ToFloat20ConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateEffectAlphaModeProperty(EffectAlphaMode value, Func<EffectAlphaMode, bool>? condition = null) | |
| => new EffectProperty(value, s_EffectAlphaModeToD2D1AlphaModeConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateDegreesToRadiansProperty(float value, Func<float, bool>? condition = null) | |
| => new EffectProperty(value, s_DegreesToRadiansConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateVectorProperty<T>(T value, Func<T, bool>? condition = null) where T : struct | |
| => new EffectProperty(value, s_VectorToFloatArrayConvertFunc, CreateCondition(condition)); | |
| public static EffectProperty CreateMatrix3x2Property(Matrix3x2 value, Func<Matrix3x2, bool>? condition = null) | |
| => new EffectProperty(value, s_Matrix3x2ToFloat6ConvertFunc, CreateCondition(condition)); | |
| private static Func<object?, bool>? CreateCondition<T>(Func<T?, bool>? func) | |
| => func is not null ? new ConditionFactory<T>(func).Condition : null; | |
| private class ConditionFactory<T> | |
| { | |
| public ConditionFactory(Func<T?, bool> condition) | |
| { | |
| this.typedCondition = condition; | |
| Condition = OnCondition; | |
| } | |
| private readonly Func<T?, bool> typedCondition; | |
| public readonly Func<object?, bool> Condition; | |
| private bool OnCondition(object? obj) | |
| { | |
| return typedCondition((T?)(object?)obj); | |
| } | |
| } | |
| } | |
| internal protected record struct EffectPropertyName(string Name, GRAPHICS_EFFECT_PROPERTY_MAPPING Mapping); | |
| [GeneratedComInterface, Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90")] | |
| internal partial interface IInspectable | |
| { | |
| [PreserveSig] int GetIids(int* iidCount, Guid** iids); | |
| [PreserveSig] int GetRuntimeClassName(nint* className); | |
| [PreserveSig] int GetTrustLevel(TrustLevel* trustLevel); | |
| } | |
| [GeneratedComInterface, Guid("2D8F9DDC-4339-4EB9-9216-F9DEB75658A2")] | |
| internal partial interface IGraphicsEffectSource : IInspectable { } | |
| [GeneratedComInterface, Guid("CB51C0CE-8FE6-4636-B202-861FAA07D8F3")] | |
| internal partial interface IGraphicsEffect : IInspectable | |
| { | |
| [PreserveSig] int get_Name(nint* name); | |
| [PreserveSig] int put_Name(nint name); | |
| } | |
| [GeneratedComInterface, Guid("2FC57384-A068-44D7-A331-30982FCF7177")] | |
| internal partial interface IGraphicsEffectD2D1Interop | |
| { | |
| [PreserveSig] int GetEffectId(Guid* id); | |
| [PreserveSig] | |
| int GetNamedPropertyMapping( | |
| [MarshalAs(UnmanagedType.LPWStr)] string name, | |
| out uint index, | |
| out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping); | |
| [PreserveSig] int GetPropertyCount(out uint count); | |
| [PreserveSig] int GetProperty(uint index, nint* value); | |
| [PreserveSig] int GetSource(int index, out nint source); | |
| [PreserveSig] int GetSourceCount(out uint count); | |
| } | |
| public enum GRAPHICS_EFFECT_PROPERTY_MAPPING | |
| { | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, | |
| GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 | |
| } | |
| } | |
| partial class CompositionEffect : global::Windows.Graphics.Effects.IGraphicsEffect, IDynamicInterfaceCastable | |
| { | |
| private static ComWrappers? comWrappers; | |
| private IObjectReference? nativeObject; | |
| private IObjectReference EnsureNativeObject() | |
| { | |
| if (nativeObject == null) | |
| { | |
| if (comWrappers == null) comWrappers = new StrategyBasedComWrappers(); | |
| var ptr = comWrappers.GetOrCreateComInterfaceForObject(impl, CreateComInterfaceFlags.None); | |
| nativeObject = ObjectReference<WinRT.Interop.IUnknownVftbl>.Attach(ref ptr, WinRT.Interop.IID.IID_IUnknown); | |
| } | |
| return nativeObject; | |
| } | |
| RuntimeTypeHandle IDynamicInterfaceCastable.GetInterfaceImplementation(RuntimeTypeHandle interfaceType) | |
| { | |
| if (interfaceType.Equals(typeof(IWinRTObject).TypeHandle)) | |
| { | |
| return typeof(ICompositionEffectMarshalHelper).TypeHandle; | |
| } | |
| return default; | |
| } | |
| bool IDynamicInterfaceCastable.IsInterfaceImplemented(RuntimeTypeHandle interfaceType, bool throwIfNotImplemented) | |
| { | |
| if (interfaceType.Equals(typeof(IWinRTObject).TypeHandle)) | |
| { | |
| return true; | |
| } | |
| else if (throwIfNotImplemented) | |
| { | |
| ThrowNotImplementedException($"{Type.GetTypeFromHandle(interfaceType)?.FullName ?? "interfaceType"} not implemented."); | |
| } | |
| return false; | |
| } | |
| [DoesNotReturn] | |
| private static void ThrowNotImplementedException(string? message = null) | |
| { | |
| throw new NotImplementedException(message); | |
| } | |
| [DoesNotReturn] | |
| private static T ThrowNotImplementedException<T>(string? message = null) | |
| { | |
| throw new NotImplementedException(message); | |
| } | |
| [DynamicInterfaceCastableImplementation] | |
| private interface ICompositionEffectMarshalHelper : IWinRTObject | |
| { | |
| IObjectReference IWinRTObject.NativeObject => Unsafe.As<CompositionEffect>(this).EnsureNativeObject(); | |
| bool IWinRTObject.HasUnwrappableNativeObject => true; | |
| ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> IWinRTObject.QueryInterfaceCache => ThrowNotImplementedException<ConcurrentDictionary<RuntimeTypeHandle, IObjectReference>>(); | |
| ConcurrentDictionary<RuntimeTypeHandle, object> IWinRTObject.AdditionalTypeData => ThrowNotImplementedException<ConcurrentDictionary<RuntimeTypeHandle, object>>(); | |
| } | |
| } | |
| partial class CompositionEffect | |
| { | |
| internal protected static class CompositionEffectClsids | |
| { | |
| public static readonly Guid CLSID_D2D1AlphaMask = new Guid(0xc80ecff0, 0x3fd5, 0x4f05, 0x83, 0x28, 0xc5, 0xd1, 0x72, 0x4b, 0x4f, 0x0a); | |
| public static readonly Guid CLSID_D2D1ArithmeticComposite = new Guid(0xfc151437, 0x049a, 0x4784, 0xa2, 0x4a, 0xf1, 0xc4, 0xda, 0xf2, 0x09, 0x87); | |
| public static readonly Guid CLSID_D2D1Blend = new Guid(0x81c5b77b, 0x13f8, 0x4cdd, 0xad, 0x20, 0xc8, 0x90, 0x54, 0x7a, 0xc6, 0x5d); | |
| public static readonly Guid CLSID_D2D1Border = new Guid(0x2A2D49C0, 0x4ACF, 0x43c7, 0x8C, 0x6A, 0x7C, 0x4A, 0x27, 0x87, 0x4D, 0x27); | |
| public static readonly Guid CLSID_D2D1ColorMatrix = new Guid(0x921F03D6, 0x641C, 0x47DF, 0x85, 0x2D, 0xB4, 0xBB, 0x61, 0x53, 0xAE, 0x11); | |
| public static readonly Guid CLSID_D2D1Flood = new Guid(0x61c23c20, 0xae69, 0x4d8e, 0x94, 0xcf, 0x50, 0x07, 0x8d, 0xf6, 0x38, 0xf2); | |
| public static readonly Guid CLSID_D2D1Composite = new Guid(0x48fc9f51, 0xf6ac, 0x48f1, 0x8b, 0x58, 0x3b, 0x28, 0xac, 0x46, 0xf7, 0x6d); | |
| public static readonly Guid CLSID_D2D1Contrast = new Guid(0xb648a78a, 0x0ed5, 0x4f80, 0xa9, 0x4a, 0x8e, 0x82, 0x5a, 0xca, 0x6b, 0x77); | |
| public static readonly Guid CLSID_D2D1CrossFade = new Guid(0x12f575e8, 0x4db1, 0x485f, 0x9a, 0x84, 0x03, 0xa0, 0x7d, 0xd3, 0x82, 0x9f); | |
| public static readonly Guid CLSID_D2D1DistantDiffuse = new Guid(0x3e7efd62, 0xa32d, 0x46d4, 0xa8, 0x3c, 0x52, 0x78, 0x88, 0x9a, 0xc9, 0x54); | |
| public static readonly Guid CLSID_D2D1DistantSpecular = new Guid(0x428c1ee5, 0x77b8, 0x4450, 0x8a, 0xb5, 0x72, 0x21, 0x9c, 0x21, 0xab, 0xda); | |
| public static readonly Guid CLSID_D2D1Exposure = new Guid(0xb56c8cfa, 0xf634, 0x41ee, 0xbe, 0xe0, 0xff, 0xa6, 0x17, 0x10, 0x60, 0x04); | |
| public static readonly Guid CLSID_D2D1GammaTransfer = new Guid(0x409444c4, 0xc419, 0x41a0, 0xb0, 0xc1, 0x8c, 0xd0, 0xc0, 0xa1, 0x8e, 0x42); | |
| public static readonly Guid CLSID_D2D1GaussianBlur = new Guid(0x1feb6d69, 0x2fe6, 0x4ac9, 0x8c, 0x58, 0x1d, 0x7f, 0x93, 0xe7, 0xa6, 0xa5); | |
| public static readonly Guid CLSID_D2D1Grayscale = new Guid(0x36DDE0EB, 0x3725, 0x42E0, 0x83, 0x6D, 0x52, 0xFB, 0x20, 0xAE, 0xE6, 0x44); | |
| public static readonly Guid CLSID_D2D1HueRotation = new Guid(0x0f4458ec, 0x4b32, 0x491b, 0x9e, 0x85, 0xbd, 0x73, 0xf4, 0x4d, 0x3e, 0xb6); | |
| public static readonly Guid CLSID_D2D1Invert = new Guid(0xe0c3784d, 0xcb39, 0x4e84, 0xb6, 0xfd, 0x6b, 0x72, 0xf0, 0x81, 0x02, 0x63); | |
| public static readonly Guid CLSID_D2D1LinearTransfer = new Guid(0xad47c8fd, 0x63ef, 0x4acc, 0x9b, 0x51, 0x67, 0x97, 0x9c, 0x03, 0x6c, 0x06); | |
| public static readonly Guid CLSID_D2D1LuminanceToAlpha = new Guid(0x41251ab7, 0x0beb, 0x46f8, 0x9d, 0xa7, 0x59, 0xe9, 0x3f, 0xcc, 0xe5, 0xde); | |
| public static readonly Guid CLSID_D2D1Opacity = new Guid(0x811d79a4, 0xde28, 0x4454, 0x80, 0x94, 0xc6, 0x46, 0x85, 0xf8, 0xbd, 0x4c); | |
| public static readonly Guid CLSID_D2D1PointDiffuse = new Guid(0xb9e303c3, 0xc08c, 0x4f91, 0x8b, 0x7b, 0x38, 0x65, 0x6b, 0xc4, 0x8c, 0x20); | |
| public static readonly Guid CLSID_D2D1PointSpecular = new Guid(0x09c3ca26, 0x3ae2, 0x4f09, 0x9e, 0xbc, 0xed, 0x38, 0x65, 0xd5, 0x3f, 0x22); | |
| public static readonly Guid CLSID_D2D1Posterize = new Guid(0x2188945e, 0x33a3, 0x4366, 0xb7, 0xbc, 0x08, 0x6b, 0xd0, 0x2d, 0x08, 0x84); | |
| public static readonly Guid CLSID_D2D1Premultiply = new Guid(0x06eab419, 0xdeed, 0x4018, 0x80, 0xd2, 0x3e, 0x1d, 0x47, 0x1a, 0xde, 0xb2); | |
| public static readonly Guid CLSID_D2D1Saturation = new Guid(0x5cb2d9cf, 0x327d, 0x459f, 0xa0, 0xce, 0x40, 0xc0, 0xb2, 0x08, 0x6b, 0xf7); | |
| public static readonly Guid CLSID_D2D1Sepia = new Guid(0x3a1af410, 0x5f1d, 0x4dbe, 0x84, 0xdf, 0x91, 0x5d, 0xa7, 0x9b, 0x71, 0x53); | |
| public static readonly Guid CLSID_D2D1SpotDiffuse = new Guid(0x818a1105, 0x7932, 0x44f4, 0xaa, 0x86, 0x08, 0xae, 0x7b, 0x2f, 0x2c, 0x93); | |
| public static readonly Guid CLSID_D2D1SpotSpecular = new Guid(0xedae421e, 0x7654, 0x4a37, 0x9d, 0xb8, 0x71, 0xac, 0xc1, 0xbe, 0xb3, 0xc1); | |
| public static readonly Guid CLSID_D2D1TemperatureTint = new Guid(0x89176087, 0x8AF9, 0x4A08, 0xAE, 0xB1, 0x89, 0x5F, 0x38, 0xDB, 0x17, 0x66); | |
| public static readonly Guid CLSID_D2D1Tint = new Guid(0x36312b17, 0xf7dd, 0x4014, 0x91, 0x5d, 0xff, 0xca, 0x76, 0x8c, 0xf2, 0x11); | |
| public static readonly Guid CLSID_D2D12DAffineTransform = new Guid(0x6AA97485, 0x6354, 0x4cfc, 0x90, 0x8C, 0xE4, 0xA7, 0x4F, 0x62, 0xC9, 0x6C); | |
| public static readonly Guid CLSID_D2D1UnPremultiply = new Guid(0xfb9ac489, 0xad8d, 0x41ed, 0x99, 0x99, 0xbb, 0x63, 0x47, 0xd1, 0x10, 0xf7); | |
| } | |
| } | |
| public struct Matrix5x4 | |
| { | |
| public float M11, M12, M13, M14; | |
| public float M21, M22, M23, M24; | |
| public float M31, M32, M33, M34; | |
| public float M41, M42, M43, M44; | |
| public float M51, M52, M53, M54; | |
| public Matrix5x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44, float m51, float m52, float m53, float m54) | |
| { | |
| M11 = m11; | |
| M12 = m12; | |
| M13 = m13; | |
| M14 = m14; | |
| M21 = m21; | |
| M22 = m22; | |
| M23 = m23; | |
| M24 = m24; | |
| M31 = m31; | |
| M32 = m32; | |
| M33 = m33; | |
| M34 = m34; | |
| M41 = m41; | |
| M42 = m42; | |
| M43 = m43; | |
| M44 = m44; | |
| M51 = m51; | |
| M52 = m52; | |
| M53 = m53; | |
| M54 = m54; | |
| } | |
| public static Matrix5x4 Identity => new(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var compositor = new Compositor(); | |
| var visual = compositor.CreateSpriteVisual(); | |
| var effect = new GaussianBlurEffect() | |
| { | |
| Name = "GaussianBlurEffect", | |
| BlurAmount = 0, | |
| Optimization = GaussianBlurEffect.EffectOptimization.Balanced, | |
| BorderMode = GaussianBlurEffect.EffectBorderMode.Soft, | |
| Source = new CompositionEffectSourceParameter("source"), | |
| }; | |
| var factory = compositor.CreateEffectFactory( | |
| effect, | |
| new string[] { "GaussianBlurEffect.BlurAmount" }); | |
| var brush = factory.CreateBrush(); | |
| brush.SetSourceParameter("source", compositor.CreateBackdropBrush()); | |
| visual.Brush = brush; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment