committed by
Nelson Carrillo
12 changed files with 172 additions and 87 deletions
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using global::Cairo; |
|||
|
|||
namespace Perspex.Cairo |
|||
{ |
|||
public abstract class BrushImpl : IDisposable |
|||
{ |
|||
public Pattern PlatformBrush { get; protected set; } |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (this.PlatformBrush != null) |
|||
this.PlatformBrush.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using global::Cairo; |
|||
|
|||
namespace Perspex.Cairo.Media |
|||
{ |
|||
public class ImageBrushImpl : BrushImpl |
|||
{ |
|||
public ImageBrushImpl(Perspex.Media.ImageBrush brush, Size destinationSize) |
|||
{ |
|||
this.PlatformBrush = TileBrushes.CreateImageBrush(brush, destinationSize); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using global::Cairo; |
|||
|
|||
namespace Perspex.Cairo |
|||
{ |
|||
public class LinearGradientBrushImpl : BrushImpl |
|||
{ |
|||
public LinearGradientBrushImpl(Perspex.Media.LinearGradientBrush brush, Size destinationSize) |
|||
{ |
|||
var start = brush.StartPoint.ToPixels(destinationSize); |
|||
var end = brush.EndPoint.ToPixels(destinationSize); |
|||
|
|||
this.PlatformBrush = new LinearGradient(start.X, start.Y, end.X, end.Y); |
|||
|
|||
foreach (var stop in brush.GradientStops) |
|||
((LinearGradient)this.PlatformBrush).AddColorStop(stop.Offset, stop.Color.ToCairo()); |
|||
|
|||
((LinearGradient)this.PlatformBrush).Extend = Extend.Pad; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using global::Cairo; |
|||
|
|||
namespace Perspex.Cairo |
|||
{ |
|||
public class SolidColorBrushImpl : BrushImpl |
|||
{ |
|||
public SolidColorBrushImpl(Perspex.Media.SolidColorBrush brush, double opacityOverride = 1.0f) |
|||
{ |
|||
var color = brush?.Color.ToCairo() ?? new Color(); |
|||
|
|||
if (brush != null && brush.Opacity > 1) |
|||
color.A = Math.Min(brush.Opacity, color.A); |
|||
|
|||
color.A = Math.Min(opacityOverride, color.A); |
|||
this.PlatformBrush = new SolidPattern(brush?.Color.ToCairo() ?? new Color()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using global::Cairo; |
|||
|
|||
namespace Perspex.Cairo.Media |
|||
{ |
|||
public class VisualBrushImpl : BrushImpl |
|||
{ |
|||
public VisualBrushImpl(Perspex.Media.VisualBrush brush, Size destinationSize) |
|||
{ |
|||
this.PlatformBrush = TileBrushes.CreateVisualBrush(brush, destinationSize); |
|||
} |
|||
} |
|||
} |
|||
|
|||
Binary file not shown.
Loading…
Reference in new issue