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
DirectPolygon.cs
1using System.Drawing;
5using SkiaSharp;
6
8
10public sealed class DirectPolygon : DirectShapeBase<DirectPolygon>
11{
12 private PointF[] _points = [];
13
15 public DirectPolygon(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, 3), nickname)
17 {
18 }
19
21 public DirectPolygon(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, 3), nickname)
23 {
24 }
25
26 private DirectPolygon(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 DirectPolygon SetPoints(IEnumerable<PointF> points)
36 {
37 _points = CopyPoints(points, 3);
38 ForceRefresh();
39 return this;
40 }
41
43 public DirectPolygon SetFillColor(Color? color) => SetShapeFill(color);
44
46 protected override void DrawGeometry(SKCanvas canvas, SKRect bounds, SKPaint paint)
47 {
48 PointF[] points = _points;
49
50 if (points is not null)
51 DrawPointSequence(canvas, bounds, paint, points, true);
52 }
53}
DirectPolygon SetPoints(IEnumerable< PointF > points)
Replaces the point sequence with a defensive copy of normalized local points.
override void DrawGeometry(SKCanvas canvas, SKRect bounds, SKPaint paint)
DirectPolygon(Color color, RenderSurfaceHostBase host, View view, Rectangle screenBounds, IEnumerable< PointF > points, string? nickname=null)
Creates a view-space polygon within the supplied bounds.
DirectPolygon SetFillColor(Color? color)
Sets the interior color, or null to disable filling.
DirectPolygon(Color color, RenderSurfaceHostBase host, SceneLayer sceneLayer, Rectangle worldBounds, IEnumerable< PointF > points, string? nickname=null)
Creates a scene-layer polygon within the supplied bounds.
static PointF[] CopyPoints(IEnumerable< PointF > points, int minimumCount)
Copies and validates a sequence of normalized local points.
TShape SetShapeFill(Color? color)
Sets or clears the fill of a fillable shape.
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.