Viewport
Declaration
public class Strawberry.Graphics.Viewport
Represents a viewport for a game engine, defining screen and scene coordinates.
Remarks: This class is serializable to support saving and loading viewport configurations. Percent-based positioning is used when UsePercent is true.
Constructors
Viewport
Creates a new viewport with specified screen and scene coordinates.
void Viewport(string name, Vector2 screenPos, Vector2 screenSize, Vector2 scenePos, Vector2 sceneSize)
Parameters:
| Name | Type | Description |
|---|---|---|
name |
System.String |
Unique identifier for the viewport |
screenPos |
Strawberry.Math.Vector2 |
Position on the screen in pixel coordinates |
screenSize |
Strawberry.Math.Vector2 |
Size of the viewport area on the screen |
scenePos |
Strawberry.Math.Vector2 |
Position in scene/world coordinates |
sceneSize |
Strawberry.Math.Vector2 |
Size of the viewport area in world units |
Properties
ScreenPos
Gets or sets position on the screen in pixel coordinates.
Vector2 ScreenPos { get set }
ScreenSize
Gets or sets the size of the viewport area on the screen in pixel units.
Vector2 ScreenSize { get set }
ScenePos
Gets or sets the position in scene/world coordinates (e.g., for camera targets).
Vector2 ScenePos { get set }
SceneSize
Gets or sets the size of the viewport area in scene/world units.
Vector2 SceneSize { get set }
UsePercent
Gets or sets whether to use percent-based positioning should be used instead of absolute pixels.
bool UsePercent { get set }
PercentPos
Gets or sets the position offset when using percent-based coordinates (0-100% of the screen).
Vector2 PercentPos { get set }
PercentSize
Gets or sets the size percentage when using percent-based coordinates (0-100% of the screen).
Vector2 PercentSize { get set }
Name
Gets or sets the unique identifier name for this viewport.
string Name { get set }