Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
62 changes: 33 additions & 29 deletions NGraphics/Brush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GradientStop
public double Offset;
public Color Color;
public GradientStop ()
{
{
}
public GradientStop (double offset, Color color)
{
Expand All @@ -58,17 +58,19 @@ public void AddStop (double offset, Color color)
}
public void AddStops (IEnumerable<GradientStop> stops)
{
Stops.AddRange(stops);
Stops.AddRange (stops);
}
}

public class RadialGradientBrush : GradientBrush
{
public Point Center;
public Point Focus;
public Size Radius;
public Size Radius;
public bool Absolute = false;

public Transform GradientTransform { get; set; }

public RadialGradientBrush ()
{
}
Expand Down Expand Up @@ -99,25 +101,25 @@ public RadialGradientBrush (Point relCenter, Size relRadius, Color startColor, C
Stops.Add (new GradientStop (0, startColor));
Stops.Add (new GradientStop (0.5, midColor));
Stops.Add (new GradientStop (1, endColor));
}
}
public RadialGradientBrush (Color startColor, Color midColor, Color endColor)
: this (new Point (0.5, 0.5), new Size (0.5), startColor, midColor, endColor)
{
}
public Point GetAbsoluteCenter (Rect frame)
{
if (Absolute) return Center;
return frame.TopLeft + Center * frame.Size;
}
public Size GetAbsoluteRadius (Rect frame)
{
if (Absolute) return Radius;
return Radius * frame.Size;
}
public Point GetAbsoluteFocus (Rect frame)
{
if (Absolute) return Focus;
return frame.TopLeft + Focus * frame.Size;
public Point GetAbsoluteCenter (Rect frame)
{
if (Absolute) return Center;
return frame.TopLeft + Center * frame.Size;
}
public Size GetAbsoluteRadius (Rect frame)
{
if (Absolute) return Radius;
return Radius * frame.Size;
}
public Point GetAbsoluteFocus (Rect frame)
{
if (Absolute) return Focus;
return frame.TopLeft + Focus * frame.Size;
}
}

Expand All @@ -127,6 +129,8 @@ public class LinearGradientBrush : GradientBrush
public Point End;
public bool Absolute = false;

public Transform GradientTransform { get; set; }

public LinearGradientBrush ()
{
}
Expand All @@ -150,16 +154,16 @@ public LinearGradientBrush (Point relStart, Point relEnd, Color startColor, Colo
Stops.Add (new GradientStop (0, startColor));
Stops.Add (new GradientStop (0.5, midColor));
Stops.Add (new GradientStop (1, endColor));
}
public Point GetAbsoluteStart (Rect frame)
{
if (Absolute) return Start;
return frame.TopLeft + Start * frame.Size;
}
public Point GetAbsoluteEnd (Rect frame)
{
if (Absolute) return End;
return frame.TopLeft + End * frame.Size;
}
}
public Point GetAbsoluteStart (Rect frame)
{
if (Absolute) return Start;
return frame.TopLeft + Start * frame.Size;
}
public Point GetAbsoluteEnd (Rect frame)
{
if (Absolute) return End;
return frame.TopLeft + End * frame.Size;
}
}
}
Loading