This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -0,0 +1,117 @@
using WPFDark.Internals;
using System.Windows;
using System.Windows.Media.Effects;
using System.Windows.Media.Media3D;
namespace WPFDark.Controls.Effects
{
internal class HsvBoxBackgroundEffect : ShaderEffect
{
static HsvBoxBackgroundEffect()
{
_PixelShader = new PixelShader
{
UriSource = new Uri($"pack://application:,,,/{ThemeManager.LibraryNamespace};component/Controls/Effects/HsvBoxBackgroundEffect.ps")
};
_PixelShader.Freeze();
}
// ReSharper disable once InconsistentNaming
private static readonly PixelShader _PixelShader;
internal HsvBoxBackgroundEffect()
{
base.PixelShader = _PixelShader;
UpdateShaderValue(ValueProperty);
UpdateShaderValue(IsEnabledProperty);
UpdateShaderValue(DisableColorProperty);
}
#region Value
public double Value
{
get => value;
set
{
if (NumberHelper.AreClose(value, Value) == false)
SetValue(ValueProperty, value);
}
}
private double value;
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(double), typeof(HsvBoxBackgroundEffect),
new PropertyMetadata(
0.0,
(s, e) =>
{
var self = (HsvBoxBackgroundEffect)s;
self.value = (double)e.NewValue;
PixelShaderConstantCallback(0)(s, e);
}));
#endregion
#region IsEnabled
public float IsEnabled
{
get => isEnabled;
set
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (value != isEnabled)
SetValue(IsEnabledProperty, value);
}
}
private float isEnabled = 1.0f;
public static readonly DependencyProperty IsEnabledProperty =
DependencyProperty.Register(nameof(IsEnabled), typeof(float), typeof(HsvBoxBackgroundEffect),
new PropertyMetadata(
1.0f,
(s, e) =>
{
var self = (HsvBoxBackgroundEffect)s;
self.isEnabled = (float)e.NewValue;
PixelShaderConstantCallback(6)(s, e);
}));
#endregion
#region DisableColor
public Point3D DisableColor
{
get => disableColor;
set
{
if (value != disableColor)
SetValue(DisableColorProperty, value);
}
}
private Point3D disableColor = new Point3D(1.0, 0.0, 0.0);
public static readonly DependencyProperty DisableColorProperty =
DependencyProperty.Register(nameof(DisableColor), typeof(Point3D), typeof(HsvBoxBackgroundEffect),
new PropertyMetadata(
new Point3D(1.0, 0.0, 0.0),
(s, e) =>
{
var self = (HsvBoxBackgroundEffect)s;
self.disableColor = (Point3D)e.NewValue;
PixelShaderConstantCallback(7)(s, e);
}));
#endregion
}
}

View File

@@ -0,0 +1,22 @@
float Value : register(C0);
float IsEnabled : register(C6);
float3 DisableColor : register(C7);
float4 main(float2 uv : TEXCOORD) : COLOR
{
if (IsEnabled != 0.0f)
{
float h = uv.x;
float s = 1 - uv.y;
// https://qiita.com/keim_at_si/items/c2d1afd6443f3040e900
float3 color = ((clamp(abs(frac(h + float3(0, 2, 1) / 3) * 6 - 3) - 1, 0, 1) - 1) * s + 1) * Value;
return float4(color, 1);
}
else
{
return float4(DisableColor, 1);
}
}

Binary file not shown.

View File

@@ -0,0 +1,206 @@
using WPFDark.Internals;
using System.Windows;
using System.Windows.Media.Effects;
using System.Windows.Media.Media3D;
namespace WPFDark.Controls.Effects
{
internal class HsvWheelBackgroundEffect : ShaderEffect
{
static HsvWheelBackgroundEffect()
{
_PixelShader = new PixelShader
{
UriSource = new Uri($"pack://application:,,,/{ThemeManager.LibraryNamespace};component/Controls/Effects/HsvWheelBackgroundEffect.ps")
};
_PixelShader.Freeze();
}
// ReSharper disable once InconsistentNaming
private static readonly PixelShader _PixelShader;
internal HsvWheelBackgroundEffect()
{
PixelShader = _PixelShader;
UpdateShaderValue(ValueProperty);
UpdateShaderValue(AspectRatioCorrectionXProperty);
UpdateShaderValue(AspectRatioCorrectionYProperty);
UpdateShaderValue(BorderColorProperty);
UpdateShaderValue(IsEnabledProperty);
UpdateShaderValue(DisableColorProperty);
}
#region Value
public double Value
{
get => value;
set
{
if (NumberHelper.AreClose(value, this.value) == false)
SetValue(ValueProperty, value);
}
}
private double value;
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(double), typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
0.0,
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self.value = (double)e.NewValue;
PixelShaderConstantCallback(0)(s, e);
}));
#endregion
#region AspectRatioCorrectionX
public double AspectRatioCorrectionX
{
get => _AspectRatioCorrectionX;
set
{
if (NumberHelper.AreClose(value, _AspectRatioCorrectionX) == false)
SetValue(AspectRatioCorrectionXProperty, value);
}
}
private double _AspectRatioCorrectionX = 1;
public static readonly DependencyProperty AspectRatioCorrectionXProperty =
DependencyProperty.Register(nameof(AspectRatioCorrectionX), typeof(double),
typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
1.0,
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self._AspectRatioCorrectionX = (double)e.NewValue;
PixelShaderConstantCallback(1)(s, e);
}));
#endregion
#region AspectRatioCorrectionY
public double AspectRatioCorrectionY
{
get => _AspectRatioCorrectionY;
set
{
if (NumberHelper.AreClose(value, _AspectRatioCorrectionY) == false)
SetValue(AspectRatioCorrectionYProperty, value);
}
}
private double _AspectRatioCorrectionY = 1;
public static readonly DependencyProperty AspectRatioCorrectionYProperty =
DependencyProperty.Register(nameof(AspectRatioCorrectionY), typeof(double),
typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
1.0,
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self._AspectRatioCorrectionY = (double)e.NewValue;
PixelShaderConstantCallback(2)(s, e);
}));
#endregion
#region BorderColor
public Point3D BorderColor
{
get => borderColor;
set
{
if (value != borderColor)
SetValue(BorderColorProperty, value);
}
}
private Point3D borderColor = new Point3D(1.0, 0.0, 0.0);
public static readonly DependencyProperty BorderColorProperty =
DependencyProperty.Register(nameof(BorderColor), typeof(Point3D), typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
new Point3D(1.0, 0.0, 0.0),
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self.borderColor = (Point3D)e.NewValue;
PixelShaderConstantCallback(3)(s, e);
}));
#endregion
#region IsEnabled
public float IsEnabled
{
get => isEnabled;
set
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (value != isEnabled)
SetValue(IsEnabledProperty, value);
}
}
private float isEnabled = 1.0f;
public static readonly DependencyProperty IsEnabledProperty =
DependencyProperty.Register(nameof(IsEnabled), typeof(float), typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
1.0f,
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self.isEnabled = (float)e.NewValue;
PixelShaderConstantCallback(6)(s, e);
}));
#endregion
#region DisableColor
public Point3D DisableColor
{
get => disableColor;
set
{
if (value != disableColor)
SetValue(DisableColorProperty, value);
}
}
private Point3D disableColor = new(1.0, 0.0, 0.0);
public static readonly DependencyProperty DisableColorProperty =
DependencyProperty.Register(nameof(DisableColor), typeof(Point3D), typeof(HsvWheelBackgroundEffect),
new PropertyMetadata(
new Point3D(1.0, 0.0, 0.0),
(s, e) =>
{
var self = (HsvWheelBackgroundEffect)s;
self.disableColor = (Point3D)e.NewValue;
PixelShaderConstantCallback(7)(s, e);
}));
#endregion
}
}

View File

@@ -0,0 +1,36 @@
float Value : register(C0);
float AspectRatioCorrectionX : register(C1);
float AspectRatioCorrectionY : register(C2);
float3 BorderColor : register(C3);
float IsEnabled : register(C6);
float3 DisableColor : register(C7);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float2 d = float2(
(uv.x - 0.5) * AspectRatioCorrectionX,
(uv.y - 0.5) * AspectRatioCorrectionY);
float i = dot(d, d);
if (i >= 0.5*0.5)
return float4(0,0,0,0);
if (IsEnabled != 0.0f)
{
float h = (atan2(-d.y, -d.x) + 3.14159265359) / (2.0*3.14159265359);
float s10 = sqrt(i) * 2;
// https://qiita.com/keim_at_si/items/c2d1afd6443f3040e900
float3 color = ((clamp(abs(frac(h + float3(0, 2, 1) / 3) * 6 - 3) - 1, 0, 1) - 1) * s10 + 1) * Value;
float r = min(1, (0.5 - sqrt(i)) * 100 * 2);
color = lerp(BorderColor, color, r);
return float4(color, 1);
}
else
{
return float4(DisableColor, 1);
}
}

Binary file not shown.

View File

@@ -0,0 +1,4 @@
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\fxc" HsvBoxBackgroundEffect.fx /T ps_2_0 /Fo HsvBoxBackgroundEffect.ps
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\fxc" HsvWheelBackgroundEffect.fx /T ps_2_0 /Fo HsvWheelBackgroundEffect.ps