Gondwana Game Engine Development (master) - 2.7.0
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
DirectPolyline.cs
1using System.Drawing;
5using SkiaSharp;
6
8
10public sealed class DirectPolyline : DirectShapeBase<DirectPolyline>
11{
12 private PointF[] _points = [];
13
15 public DirectPolyline(Color color, RenderSurfaceHostBase host, SceneLayer sceneLayer, Rectangle worldBounds, IEnumerable<PointF> points, string? nickname = null)
16 : this(color, host, DirectDrawingMode.SceneLayer, sceneLayer, null, worldBounds, CopyPoints(points, 2), nickname)
17 {
18 }
19
21 public DirectPolyline(Color color, RenderSurfaceHostBase host, View view, Rectangle screenBounds, IEnumerable<PointF> points, string? nickname = null)
22 : this(color, host, DirectDrawingMode.View, null, view, screenBounds, CopyPoints(points, 2), nickname)
23 {
24 }
25
26 private DirectPolyline(Color color, RenderSurfaceHostBase host, DirectDrawingMode mode,
27 SceneLayer? sceneLayer, View? view, Rectangle bounds, PointF[] points, string? nickname)
28 : base(color, host, mode, sceneLayer, view, bounds, nickname)
29 {
30 _points = points;
31 ForceRefresh();
32 }
33
35 public DirectPolyline SetPoints(IEnumerable<PointF> points)
36 {
37 _points = CopyPoints(points, 2);
38 ForceRefresh();
39 return this;
40 }
41
43 protected override void DrawGeometry(SKCanvas canvas, SKRect bounds, SKPaint paint)
44 {
45 PointF[] points = _points;
46
47 if (points is not null)
48 DrawPointSequence(canvas, bounds, paint, points, false);
49 }
50}
override void DrawGeometry(SKCanvas canvas, SKRect bounds, SKPaint paint)
DirectPolyline(Color color, RenderSurfaceHostBase host, View view, Rectangle screenBounds, IEnumerable< PointF > points, string? nickname=null)
Creates a view-space polyline within the supplied bounds.
DirectPolyline SetPoints(IEnumerable< PointF > points)
Replaces the point sequence with a defensive copy of normalized local points.
DirectPolyline(Color color, RenderSurfaceHostBase host, SceneLayer sceneLayer, Rectangle worldBounds, IEnumerable< PointF > points, string? nickname=null)
Creates a scene-layer polyline within the supplied bounds.
static PointF[] CopyPoints(IEnumerable< PointF > points, int minimumCount)
Copies and validates a sequence of normalized local points.
static void DrawPointSequence(SKCanvas canvas, SKRect bounds, SKPaint paint, PointF[] points, bool closed)
Draws a point sequence as an open or closed path.
DirectShapeBase(Color color, RenderSurfaceHostBase host, DirectDrawingMode mode, SceneLayer? sceneLayer, View? view, Rectangle bounds, string? nickname)
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
@ View
Performs direct drawing at the view level using screen-space coordinates.
@ SceneLayer
Performs direct drawing within a scene layer using world-space coordinates.