Skip to main content

Drawing

Draw shapes and control the look of them.

Summary

Functions

Name
voidbackground(Color color)
Sets the color and alpha of each pixel of the canvas.
voidsquare(FullScreen )
Draws a square.
voidsquare(Center center = {}, Radius radius = {}, Rotation rotation = {})
voidsquare(TopLeftCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare(TopRightCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare(BottomLeftCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare(BottomRightCorner corner, Radius radius = {}, Rotation rotation = {})
voidrectangle(FullScreen = {})
Draws a rectangle.
voidrectangle(Center center, Radii radii = {}, Rotation rotation = {})
voidrectangle(TopLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle(TopRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle(BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle(BottomRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle(Transform2D transform)
voidcircle(FullScreen )
Draws a circle.
voidcircle(Center center = {}, Radius radius = {})
voidellipse(FullScreen = {})
Draws an ellipse.
voidellipse(Center center, Radii radii = {}, Rotation rotation = {})
voidellipse(Transform2D transform)
voidequilateral_triangle(Center center, Radius radius = {}, Rotation rotation = {})
Draws an equilateral triangle. [Radius](/reference/Types/radius) is the distance between the [Center](/reference/Types/center) and one of the tips of the triangle.
voidtriangle(Point2D p1, Point2D p2, Point2D p3, Center center = {}, Rotation rotation = {})
Draws a triangle between the three points, translated by [Center](/reference/Types/center) and rotated by Rotation.
voidtriangle(Point2D p1, Point2D p2, Point2D p3, Transform2D transform)
Draws a triangle between the three points, and applies the transform to the triangle.
voidimage(const ImageOrCanvas & img, Fit = {})
Draws an image as big as possible on the screen. This will respect the aspect ratio of the image.
voidimage(const ImageOrCanvas & img, FitX )
voidimage(const ImageOrCanvas & img, FitY )
voidimage(const ImageOrCanvas & img, Center center, RadiusX radiusX = {}, Rotation rotation = {})
Draws an image. This will respect the aspect ratio of the image.
voidimage(const ImageOrCanvas & img, TopLeftCorner corner, RadiusX radiusX = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, TopRightCorner corner, RadiusX radiusX = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusX radiusX = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomRightCorner corner, RadiusX radiusX = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, Center center, RadiusY radiusY = {}, Rotation rotation = {})
Draws an image. This will respect the aspect ratio of the image.
voidimage(const ImageOrCanvas & img, TopLeftCorner corner, RadiusY radiusY = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, TopRightCorner corner, RadiusY radiusY = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusY radiusY = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomRightCorner corner, RadiusY radiusY = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, FullScreen )
Draws an image that takes the entire window. ⚠️ This might distort the image if the window doesn't have the same aspect ratio as the image.
voidimage(const ImageOrCanvas & img, Center center, Radii radii = {}, Rotation rotation = {})
Draws an image. ⚠️ This might distort the image if radii doesn't have the same aspect ratio as the image.
voidimage(const ImageOrCanvas & img, TopLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, TopRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, BottomRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidimage(const ImageOrCanvas & img, Transform2D transform)
voidrectangle_with_shader(const Shader & shader, FullScreen = {})
Draws a rectangle using a custom fragment shader.
voidrectangle_with_shader(const Shader & shader, Center center, Radii radii = {}, Rotation rotation = {})
voidrectangle_with_shader(const Shader & shader, TopLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle_with_shader(const Shader & shader, TopRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle_with_shader(const Shader & shader, BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {})
voidrectangle_with_shader(const Shader & shader, BottomRightCorner corner, Radii radii = {}, Rotation rotation = {})
voidsquare_with_shader(const Shader & shader, Center center = {}, Radius radius = {}, Rotation rotation = {})
voidsquare_with_shader(const Shader & shader, TopLeftCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare_with_shader(const Shader & shader, TopRightCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare_with_shader(const Shader & shader, BottomLeftCorner corner, Radius radius = {}, Rotation rotation = {})
voidsquare_with_shader(const Shader & shader, BottomRightCorner corner, Radius radius = {}, Rotation rotation = {})
voidrectangle_with_shader(const Shader & shader, Transform2D transform)
voidline(glm::vec2 start, glm::vec2 end)
Draws a line between two points.

Attributes

Name
Colorfill
The color that is used for the interior of the shapes.
booluse_fill
Whether the shapes will have an interior.
Colorstroke
The color that is used for the boundary of the shapes.
floatstroke_weight
The size of the boundary of the shapes.
booluse_stroke
Whether there will be a boundary on the shape.

Functions

background()

void background(Color color);

Sets the color and alpha of each pixel of the canvas.

NB: No blending is applied; even if you specify an alpha of 0.5 the old canvas is completely erased. This means that setting an alpha here doesn't matter much. It is only meaningful if you export the canvas as a png, or if you later try to blend the canvas on top of another image.

square()

void square(FullScreen );

Draws a square.

square()

void square(Center center ={}, Radius radius ={}, Rotation rotation ={});

square()

void square(TopLeftCorner corner, Radius radius ={}, Rotation rotation ={});

square()

void square(TopRightCorner corner, Radius radius ={}, Rotation rotation ={});

square()

void square(BottomLeftCorner corner, Radius radius ={}, Rotation rotation ={});

square()

void square(BottomRightCorner corner, Radius radius ={}, Rotation rotation ={});

rectangle()

void rectangle(FullScreen ={});

Draws a rectangle.

rectangle()

void rectangle(Center center, Radii radii ={}, Rotation rotation ={});

rectangle()

void rectangle(TopLeftCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle()

void rectangle(TopRightCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle()

void rectangle(BottomLeftCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle()

void rectangle(BottomRightCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle()

void rectangle(Transform2D transform);

circle()

void circle(FullScreen );

Draws a circle.

circle()

void circle(Center center ={}, Radius radius ={});

ellipse()

void ellipse(FullScreen ={});

Draws an ellipse.

ellipse()

void ellipse(Center center, Radii radii ={}, Rotation rotation ={});

ellipse()

void ellipse(Transform2D transform);

equilateral_triangle()

void equilateral_triangle(Center center, Radius radius ={}, Rotation rotation ={});

Draws an equilateral triangle. [Radius](/reference/Types/radius) is the distance between the [Center](/reference/Types/center) and one of the tips of the triangle.

triangle()

void triangle(Point2D p1, Point2D p2, Point2D p3, Center center ={}, Rotation rotation ={});

Draws a triangle between the three points, translated by [Center](/reference/Types/center) and rotated by Rotation.

triangle()

void triangle(Point2D p1, Point2D p2, Point2D p3, Transform2D transform);

Draws a triangle between the three points, and applies the transform to the triangle.

image()

void image(const ImageOrCanvas & img, Fit ={});

Draws an image as big as possible on the screen. This will respect the aspect ratio of the image.

image()

void image(const ImageOrCanvas & img, FitX );

image()

void image(const ImageOrCanvas & img, FitY );

image()

void image(const ImageOrCanvas & img, Center center, RadiusX radiusX ={}, Rotation rotation ={});

Draws an image. This will respect the aspect ratio of the image.

image()

void image(const ImageOrCanvas & img, TopLeftCorner corner, RadiusX radiusX ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, TopRightCorner corner, RadiusX radiusX ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusX radiusX ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomRightCorner corner, RadiusX radiusX ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, Center center, RadiusY radiusY ={}, Rotation rotation ={});

Draws an image. This will respect the aspect ratio of the image.

image()

void image(const ImageOrCanvas & img, TopLeftCorner corner, RadiusY radiusY ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, TopRightCorner corner, RadiusY radiusY ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusY radiusY ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomRightCorner corner, RadiusY radiusY ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, FullScreen );

Draws an image that takes the entire window. ⚠️ This might distort the image if the window doesn't have the same aspect ratio as the image.

image()

void image(const ImageOrCanvas & img, Center center, Radii radii ={}, Rotation rotation ={});

Draws an image. ⚠️ This might distort the image if radii doesn't have the same aspect ratio as the image.

image()

void image(const ImageOrCanvas & img, TopLeftCorner corner, Radii radii ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, TopRightCorner corner, Radii radii ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomLeftCorner corner, Radii radii ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, BottomRightCorner corner, Radii radii ={}, Rotation rotation ={});

image()

void image(const ImageOrCanvas & img, Transform2D transform);

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, FullScreen ={});

Draws a rectangle using a custom fragment shader.

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, Center center, Radii radii ={}, Rotation rotation ={});

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, TopLeftCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, TopRightCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, BottomLeftCorner corner, Radii radii ={}, Rotation rotation ={});

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, BottomRightCorner corner, Radii radii ={}, Rotation rotation ={});

square_with_shader()

void square_with_shader(const Shader & shader, Center center ={}, Radius radius ={}, Rotation rotation ={});

square_with_shader()

void square_with_shader(const Shader & shader, TopLeftCorner corner, Radius radius ={}, Rotation rotation ={});

square_with_shader()

void square_with_shader(const Shader & shader, TopRightCorner corner, Radius radius ={}, Rotation rotation ={});

square_with_shader()

void square_with_shader(const Shader & shader, BottomLeftCorner corner, Radius radius ={}, Rotation rotation ={});

square_with_shader()

void square_with_shader(const Shader & shader, BottomRightCorner corner, Radius radius ={}, Rotation rotation ={});

rectangle_with_shader()

void rectangle_with_shader(const Shader & shader, Transform2D transform);

line()

void line(glm::vec2 start, glm::vec2 end);

Draws a line between two points.

It uses the stroke color, and stroke_weight as its thickness.

Attributes

fill

Color fill {1.f, 1.f, 1.f, 0.5f};

The color that is used for the interior of the shapes.

use_fill

bool use_fill = true;

Whether the shapes will have an interior.

stroke

Color stroke {0.f, 0.f, 0.f};

The color that is used for the boundary of the shapes.

stroke_weight

float stroke_weight = 0.01f;

The size of the boundary of the shapes.

use_stroke

bool use_stroke = true;

Whether there will be a boundary on the shape.


Updated on 2024 October 24