Gondwana Game Engine Development (master) - 2.6.1
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
Gondwana.Rendering.Views.Viewport Class Referencesealed

A rectangular window on the render target with its own zoom and placement. Viewport never moves the world; it only scales and positions the drawing. More...

Public Member Functions

void Resize (int width, int height)
 Updates the viewport size while preserving its current on-screen origin. This is a convenience around TargetRectPx that only changes the width and height.
void SnapZoom (float zoom)
 Instantly sets the zoom level, raising the ZoomChanged event.
void ZoomTo (float targetZoom, float lerpPerSecond)
 Smoothly animates the zoom toward a target level using an exponential lerp rate in "per second" units. Values <= 0 snap immediately.
void ZoomToOverDuration (float targetZoom, float durationSeconds)
 Smoothly animates the zoom using exponential easing and snaps exactly to the target when the requested duration has elapsed. Values <= 0 snap.

Properties

Rectangle TargetRectPx [get, set]
 Screen-space rectangle (in SCREEN / RenderSurface pixels) where this view is drawn. This defines the on-screen position and size of the viewport for this view.
float Zoom [get, set]
 Zoom factor applied to the world when rendering this view. Values greater than 1 zoom in, values between 0 and 1 zoom out. Used when converting between screen-space and world-space pixels.
PointF ScreenOffsetPx = PointF.Empty [get, set]
 Optional per-view HUD/safe-area offset in screen pixels.
SizeF VisibleWorldSizePx [get]
 World size visible through this viewport (used for Camera clamping).

Events

Action< ViewportResizedEventArgs >? TargetRectChanged
 Fired whenever TargetRectPx changes (viewport resized or moved). Provides the Viewport instance and the old and new rectangles.
Action< ViewportZoomChangedEventArgs >? ZoomChanged
 Occurs when the zoom level of the viewport changes.

Detailed Description

A rectangular window on the render target with its own zoom and placement. Viewport never moves the world; it only scales and positions the drawing.

Definition at line 9 of file Viewport.cs.

Member Function Documentation

◆ Resize()

void Gondwana.Rendering.Views.Viewport.Resize ( int width,
int height )

Updates the viewport size while preserving its current on-screen origin. This is a convenience around TargetRectPx that only changes the width and height.

Parameters
widthNew viewport width in pixels.
heightNew viewport height in pixels.

Definition at line 55 of file Viewport.cs.

◆ SnapZoom()

void Gondwana.Rendering.Views.Viewport.SnapZoom ( float zoom)

Instantly sets the zoom level, raising the ZoomChanged event.

Parameters
zoomThe zoom factor.

Definition at line 95 of file Viewport.cs.

◆ ZoomTo()

void Gondwana.Rendering.Views.Viewport.ZoomTo ( float targetZoom,
float lerpPerSecond )

Smoothly animates the zoom toward a target level using an exponential lerp rate in "per second" units. Values <= 0 snap immediately.

Parameters
targetZoomThe zoom factor to reach at the end of the effect.
lerpPerSecondThe lerp per second.

Definition at line 112 of file Viewport.cs.

◆ ZoomToOverDuration()

void Gondwana.Rendering.Views.Viewport.ZoomToOverDuration ( float targetZoom,
float durationSeconds )

Smoothly animates the zoom using exponential easing and snaps exactly to the target when the requested duration has elapsed. Values <= 0 snap.

Parameters
targetZoomThe zoom factor to reach at the end of the effect.
durationSecondsThe duration in seconds.

Definition at line 133 of file Viewport.cs.

Property Documentation

◆ ScreenOffsetPx

PointF Gondwana.Rendering.Views.Viewport.ScreenOffsetPx = PointF.Empty
getset

Optional per-view HUD/safe-area offset in screen pixels.

Definition at line 81 of file Viewport.cs.

◆ TargetRectPx

Rectangle Gondwana.Rendering.Views.Viewport.TargetRectPx
getset

Screen-space rectangle (in SCREEN / RenderSurface pixels) where this view is drawn. This defines the on-screen position and size of the viewport for this view.

Definition at line 34 of file Viewport.cs.

◆ VisibleWorldSizePx

SizeF Gondwana.Rendering.Views.Viewport.VisibleWorldSizePx
get

World size visible through this viewport (used for Camera clamping).

Definition at line 84 of file Viewport.cs.

◆ Zoom

float Gondwana.Rendering.Views.Viewport.Zoom
getset

Zoom factor applied to the world when rendering this view. Values greater than 1 zoom in, values between 0 and 1 zoom out. Used when converting between screen-space and world-space pixels.

Definition at line 66 of file Viewport.cs.

Event Documentation

◆ TargetRectChanged

Action<ViewportResizedEventArgs>? Gondwana.Rendering.Views.Viewport.TargetRectChanged

Fired whenever TargetRectPx changes (viewport resized or moved). Provides the Viewport instance and the old and new rectangles.

Definition at line 23 of file Viewport.cs.

◆ ZoomChanged

Action<ViewportZoomChangedEventArgs>? Gondwana.Rendering.Views.Viewport.ZoomChanged

Occurs when the zoom level of the viewport changes.

Definition at line 28 of file Viewport.cs.