Drawing
Draw shapes and control the look of them.
Summary
Functions
Name | |
---|---|
void | background(Color color)Sets the color and alpha of each pixel of the canvas. |
void | square(FullScreen )Draws a square. |
void | square(Center center = {}, Radius radius = {}, Rotation rotation = {}) |
void | square(TopLeftCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square(TopRightCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square(BottomLeftCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square(BottomRightCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | rectangle(FullScreen = {})Draws a rectangle. |
void | rectangle(Center center, Radii radii = {}, Rotation rotation = {}) |
void | rectangle(TopLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle(TopRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle(BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle(BottomRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle(Transform2D transform) |
void | circle(FullScreen )Draws a circle. |
void | circle(Center center = {}, Radius radius = {}) |
void | ellipse(FullScreen = {})Draws an ellipse. |
void | ellipse(Center center, Radii radii = {}, Rotation rotation = {}) |
void | ellipse(Transform2D transform) |
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. |
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 . |
void | triangle(Point2D p1, Point2D p2, Point2D p3, Transform2D transform)Draws a triangle between the three points, and applies the transform to the triangle. |
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. |
void | image(const ImageOrCanvas & img, FitX ) |
void | image(const ImageOrCanvas & img, FitY ) |
void | image(const ImageOrCanvas & img, Center center, RadiusX radiusX = {}, Rotation rotation = {})Draws an image. This will respect the aspect ratio of the image. |
void | image(const ImageOrCanvas & img, TopLeftCorner corner, RadiusX radiusX = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, TopRightCorner corner, RadiusX radiusX = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusX radiusX = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomRightCorner corner, RadiusX radiusX = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, Center center, RadiusY radiusY = {}, Rotation rotation = {})Draws an image. This will respect the aspect ratio of the image. |
void | image(const ImageOrCanvas & img, TopLeftCorner corner, RadiusY radiusY = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, TopRightCorner corner, RadiusY radiusY = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomLeftCorner corner, RadiusY radiusY = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomRightCorner corner, RadiusY radiusY = {}, Rotation rotation = {}) |
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. |
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. |
void | image(const ImageOrCanvas & img, TopLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, TopRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, BottomRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | image(const ImageOrCanvas & img, Transform2D transform) |
void | rectangle_with_shader(const Shader & shader, FullScreen = {})Draws a rectangle using a custom fragment shader. |
void | rectangle_with_shader(const Shader & shader, Center center, Radii radii = {}, Rotation rotation = {}) |
void | rectangle_with_shader(const Shader & shader, TopLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle_with_shader(const Shader & shader, TopRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle_with_shader(const Shader & shader, BottomLeftCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | rectangle_with_shader(const Shader & shader, BottomRightCorner corner, Radii radii = {}, Rotation rotation = {}) |
void | square_with_shader(const Shader & shader, Center center = {}, Radius radius = {}, Rotation rotation = {}) |
void | square_with_shader(const Shader & shader, TopLeftCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square_with_shader(const Shader & shader, TopRightCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square_with_shader(const Shader & shader, BottomLeftCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | square_with_shader(const Shader & shader, BottomRightCorner corner, Radius radius = {}, Rotation rotation = {}) |
void | rectangle_with_shader(const Shader & shader, Transform2D transform) |
void | line(glm::vec2 start, glm::vec2 end)Draws a line between two points. |
Attributes
Name | |
---|---|
Color | fill The color that is used for the interior of the shapes. |
bool | use_fill Whether the shapes will have an interior. |
Color | stroke The color that is used for the boundary of the shapes. |
float | stroke_weight The size of the boundary of the shapes. |
bool | use_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