Drawing
namespace Griff.Scenes;
public sealed class DrawingWhat a IDrawable draws into: the entity it belongs to, what the camera sees, and quads, lines and text to add. Everything added belongs to Entity, so it’s lit, hidden and picked with it.
Properties
Section titled “Properties”public StepBlend Blend { get; }How far this frame is between the game’s last two steps, for Entity: draw what changes once a step from a component’s own state (not its transform, which is placed between steps already) between what it was and is, so it moves smoothly on a fast screen. Things are drawn as they are in the editor, while the game is held still, and for an entity that jumped in the last step; see StepBlend.
CanCull
Section titled “CanCull”public bool CanCull { get; }True if leaving out what’s outside View is safe; false when the entity’s draws are moved afterwards (it’s on a parallax layer), so they have to be drawn whole.
Entity
Section titled “Entity”public Entity Entity { get; }The entity being drawn.
IsPlaying
Section titled “IsPlaying”public bool IsPlaying { get; }True while the game runs; false in the editor, where nothing has started.
LineWidth
Section titled “LineWidth”public float LineWidth { get; }A thin line’s width in world units: about two pixels on a 720-pixel-high screen, whatever the zoom.
public Box View { get; }The part of the world the camera sees (ignoring its rotation): its middle and half its size.
Methods
Section titled “Methods”public void Add(in SpriteDraw draw)Adds a quad as it is.
public void Bar(Vector2 size, BarDirection direction, float fraction, float trail, Color background, Color fill, Color trailColor, BarImages images = default)A bar of size centered on the entity, in its own space: the background, then the trail up to trail and the fill up to fraction (both 0 to 1), filling towards direction. Fully transparent parts are left out. With images, its parts are pictures tinted by those colors.
Circle
Section titled “Circle”public void Circle(Vector2 center, float radius, float thickness, Color color)A ring in the world.
public void Image(Matrix4x4 world, string? image, Color tint, Vector4? source = default)An image (or, with none, a quad of tint) filling the unit quad placed by world.
public void Line(Vector2 from, Vector2 to, float thickness, Color color)A line in the world thickness wide.
Outline
Section titled “Outline”public void Outline(Vector2 center, Vector2 size, float thickness, Color color)The edges of a rectangle in the world.
public void Quad(Vector2 center, Vector2 size, Color color)A solid rectangle in the world.
public void Rect(Vector2 center, Vector2 size, Color color)A solid rectangle in the entity’s own space (moving, turning and scaling with it).
SortAt
Section titled “SortAt”public void SortAt(float y)Sorts what’s added from here on (up to the next call) by world height y instead of by the entity’s position, when the camera sorts by Y (SortByY): what’s lower down draws in front. A tilemap sorting by Y calls it for each row of tiles, so a character passes in front of a wall and behind it.
public void Text(string text, Vector2 at, float size, Color color, TextAlign align = TextAlign.Center, string? font = null, TextVerticalAlign vertical = TextVerticalAlign.Middle, float wrapWidth = 0f)Text size high a line in the world, placed at at as align and vertical say, its lines broken between words to fit wrapWidth world units across when that’s more than 0 (as a Text’s are).
public Color Tint(IDrawable drawn, Color color)The color drawn (one of the entity’s own components) draws in instead of color, after the entity’s IDrawEffects have had their say.