DrawingBrush alternative to draw a 2D grid as a canvas background
Posted: 08 Apr 2022, 12:31
I have the following xaml the is used to fill a canvas with a 2D grid background:
Unfortunately, using the solution provided in a similar question will not work as the pattern is 2 dimensional rather than 1 dimensional.
viewtopic.php?p=13789&hilit=DrawingBrush#p13789
How can this be achieved with Noesis? Is there a plan to support DrawingBrush?
Update:
Ok, I think my current direction is to inherit from Noesis::Canvas and override its OnRender Method to draw the grid background using DrawingContext::DrawRectangle or DrawingContext::DrawLine
Now the question is - Is this a good approach? specifically. An Ideal approach would achieve instanced rendering of triangles / lines. can this be achieved?
Code: Select all
<UserControl x:Class="EM.Map2DDisplay"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:EM"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Canvas>
<Canvas.Background>
<DrawingBrush TileMode="Tile" Viewport="0,0,50,50" ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,50,50"/>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Brush="Gray" Thickness="1"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</Canvas.Background>
</Canvas>
</UserControl>Unfortunately, using the solution provided in a similar question will not work as the pattern is 2 dimensional rather than 1 dimensional.
viewtopic.php?p=13789&hilit=DrawingBrush#p13789
How can this be achieved with Noesis? Is there a plan to support DrawingBrush?
Update:
Ok, I think my current direction is to inherit from Noesis::Canvas and override its OnRender Method to draw the grid background using DrawingContext::DrawRectangle or DrawingContext::DrawLine
Now the question is - Is this a good approach? specifically. An Ideal approach would achieve instanced rendering of triangles / lines. can this be achieved?