|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.Documents; |
|
|
|
using Avalonia.Controls.Shapes; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Media.Imaging; |
|
|
|
@ -25,9 +26,21 @@ namespace Avalonia.Direct2D1.RenderTests.Media |
|
|
|
Decorator target = new Decorator |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
Width = 80, |
|
|
|
Height = 90, |
|
|
|
Child = new GlyphRunGeometryControl() |
|
|
|
Width = 200, |
|
|
|
Height = 100, |
|
|
|
Child = new GlyphRunGeometryControl |
|
|
|
{ |
|
|
|
[TextElement.ForegroundProperty] = new LinearGradientBrush |
|
|
|
{ |
|
|
|
StartPoint = new RelativePoint(0, 0.5, RelativeUnit.Relative), |
|
|
|
EndPoint = new RelativePoint(1, 0.5, RelativeUnit.Relative), |
|
|
|
GradientStops = |
|
|
|
{ |
|
|
|
new GradientStop { Color = Colors.Red, Offset = 0 }, |
|
|
|
new GradientStop { Color = Colors.Blue, Offset = 1 } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
await RenderToFile(target); |
|
|
|
@ -43,9 +56,9 @@ namespace Avalonia.Direct2D1.RenderTests.Media |
|
|
|
{ |
|
|
|
var glyphTypeface = Typeface.Default.GlyphTypeface; |
|
|
|
|
|
|
|
var glyphIndices = new[] { glyphTypeface.GetGlyph('A') }; |
|
|
|
var glyphIndices = new[] { glyphTypeface.GetGlyph('A'), glyphTypeface.GetGlyph('B'), glyphTypeface.GetGlyph('C') }; |
|
|
|
|
|
|
|
var characters = new[] { 'A' }; |
|
|
|
var characters = new[] { 'A', 'B', 'C' }; |
|
|
|
|
|
|
|
var glyphRun = new GlyphRun(glyphTypeface, 100, characters, glyphIndices); |
|
|
|
|
|
|
|
@ -59,7 +72,9 @@ namespace Avalonia.Direct2D1.RenderTests.Media |
|
|
|
|
|
|
|
public override void Render(DrawingContext context) |
|
|
|
{ |
|
|
|
context.DrawGeometry(Brushes.Green, null, _geometry); |
|
|
|
var foreground = TextElement.GetForeground(this); |
|
|
|
|
|
|
|
context.DrawGeometry(foreground, null, _geometry); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|