-
Notifications
You must be signed in to change notification settings - Fork 265
/
PolarInversionEffect.cs
73 lines (60 loc) · 2.06 KB
/
PolarInversionEffect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/////////////////////////////////////////////////////////////////////////////////
// Paint.NET //
// Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
// Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
// See license-pdn.txt for full licensing and attribution details. //
// //
// Ported to Pinta by: Olivier Dufour <olivier.duff@gmail.com> //
/////////////////////////////////////////////////////////////////////////////////
using System;
using Cairo;
using Pinta.Gui.Widgets;
using Pinta.Core;
using Mono.Unix;
namespace Pinta.Effects
{
//[System.ComponentModel.Composition.Export (typeof (BaseEffect))]
public class PolarInversionEffect : WarpEffect
{
public override string Icon {
get { return "Menu.Effects.Distort.PolarInversion.png"; }
}
public override string Text {
get { return Catalog.GetString ("Polar Inversion"); }
}
public override bool IsConfigurable {
get { return true; }
}
public PolarInversionData Data {
get { return EffectData as PolarInversionData; }
}
public override string EffectMenuCategory
{
get { return Catalog.GetString ("Distort"); }
}
public PolarInversionEffect ()
{
EffectData = new PolarInversionData ();
}
#region Algorithm Code Ported From PDN
protected override void InverseTransform (ref TransformData transData)
{
double x = transData.X;
double y = transData.Y;
// NOTE: when x and y are zero, this will divide by zero and return NaN
double invertDistance = Utility.Lerp (1.0, DefaultRadius2 / ((x * x) + (y * y)), Data.Amount);
transData.X = x * invertDistance;
transData.Y = y * invertDistance;
}
#endregion
public class PolarInversionData : WarpEffect.WarpData
{
[MinimumValue(-4), MaximumValue(4)]
public double Amount = 0;
public PolarInversionData () : base()
{
EdgeBehavior = WarpEdgeBehavior.Reflect;
}
}
}
}