DrawTarget
Mojo trait 🡭
DrawTarget
Implemented traits
AnyType
Methods
fill_rect
fn def fill_rect(mut self, x: Int, y: Int, width: Int, height: Int, color: Color)Fill the pixels x through x + width - 1 by y through y + height - 1 with a solid color.
Args:
- self (
_Self) - x (
Int): First column. - y (
Int): First row. - width (
Int): Columns. - height (
Int): Rows. - color (
Color): Fill color.
fn def fill_rect(mut self, x: Float64, y: Float64, width: Float64, height: Float64, color: Color)Fill the geometric box from (x, y) spanning width x height, snapped to whole pixels: each edge goes to the nearest pixel boundary (pixel k spans k - 0.5 to k + 0.5), so a caller laying out in Float64 gets crisp edges without rounding itself. See the placement rule in this module’s docstring.
Args:
- self (
_Self) - x (
Float64): Left edge. - y (
Float64): Top edge. - width (
Float64): Width. - height (
Float64): Height. - color (
Color): Fill color.
fill_rect_gradient
fn def fill_rect_gradient(mut self, x: Int, y: Int, width: Int, height: Int, gradient: LinearGradient)Fill a rectangle, sourcing each point’s color from gradient rather than one flat color.
Args:
- self (
_Self) - x (
Int): First column. - y (
Int): First row. - width (
Int): Columns. - height (
Int): Rows. - gradient (
LinearGradient): Fill source, projected across the rectangle.
fn def fill_rect_gradient(mut self, x: Float64, y: Float64, width: Float64, height: Float64, gradient: LinearGradient)fill_rect_gradient for a geometric box, snapped to whole pixels as the Float64 fill_rect is.
Args:
- self (
_Self) - x (
Float64): Left edge. - y (
Float64): Top edge. - width (
Float64): Width. - height (
Float64): Height. - gradient (
LinearGradient): Fill source, projected across the rectangle.
draw_line_aa
fn def draw_line_aa(mut self, x0: Int, y0: Int, x1: Int, y1: Int, color: Color, width: Float64 = 1, dashes: List[Float64] = List(), dash_offset: Float64 = 0, cap: LineCap = LineCap.ROUND, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)An anti-aliased line, round-capped by default.
Args:
- self (
_Self) - x0 (
Int): Start point x. - y0 (
Int): Start point y. - x1 (
Int): End point x. - y1 (
Int): End point y. - color (
Color): Line color. - width (
Float64): Stroke width in pixels. - dashes (
List[Float64]): On/off segment lengths in user-space pixels, cycled along the line. Empty (default) draws a solid line. - dash_offset (
Float64): Distance into the dash pattern the line starts at. - cap (
LineCap): How the two ends are finished – see LineCap. - join (
LineJoin): Unused for a single segment, which has no corners. - miter_limit (
Float64): Unused for a single segment.
fn def draw_line_aa(mut self, x0: Float64, y0: Float64, x1: Float64, y1: Float64, color: Color, width: Float64 = 1, dashes: List[Float64] = List(), dash_offset: Float64 = 0, cap: LineCap = LineCap.ROUND, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)An anti-aliased line between sub-pixel endpoints, round-capped by default.
Args:
- self (
_Self) - x0 (
Float64): Start point x. - y0 (
Float64): Start point y. - x1 (
Float64): End point x. - y1 (
Float64): End point y. - color (
Color): Line color. - width (
Float64): Stroke width in pixels. - dashes (
List[Float64]): On/off segment lengths in user-space pixels, cycled along the line. Empty (default) draws a solid line. - dash_offset (
Float64): Distance into the dash pattern the line starts at. - cap (
LineCap): How the two ends are finished – see LineCap. - join (
LineJoin): Unused for a single segment, which has no corners. - miter_limit (
Float64): Unused for a single segment.
fill_circle_aa
fn def fill_circle_aa(mut self, cx: Int, cy: Int, radius: Int, color: Color)An anti-aliased filled disk.
Args:
- self (
_Self) - cx (
Int): Center x. - cy (
Int): Center y. - radius (
Int): Circle radius in pixels. - color (
Color): Fill color.
fn def fill_circle_aa(mut self, cx: Float64, cy: Float64, radius: Float64, color: Color)An anti-aliased filled disk at a sub-pixel center and radius.
Args:
- self (
_Self) - cx (
Float64): Center x, sub-pixel. - cy (
Float64): Center y, sub-pixel. - radius (
Float64): Circle radius in pixels. - color (
Color): Fill color.
fill_circles_aa
fn def fill_circles_aa(mut self, centers: List[FPoint], radius: Float64, color: Color)Many equal-radius disks in one call, in draw order.
The same pixels as fill_circle_aa per centre, and on the
raster backend a great deal faster: it splits the canvas
across cores rather than the markers, which are individually
far too small to be worth a thread. A vector backend emits one
element per marker either way, so there the batch is the loop
and nothing changes but the call.
On the trait because a caller drawing a scatter through it
cannot otherwise reach the batched path: Mojo has no way to
specialize a [T: DrawTarget] function on the concrete type,
so the alternative is a second copy of the marker loop that
drifts from the first.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each marker, in draw order. - radius (
Float64): Radius shared by every marker, in pixels. - color (
Color): Fill color shared by every marker.
Raises:
fn def fill_circles_aa(mut self, centers: List[FPoint], radius: Float64, colors: List[Color])fill_circles_aa with a color per marker – a scatter whose points carry a color scale.
The only method on this trait that raises, because it is the
only one with an argument that can disagree with another:
colors has to be the same length as centers, and silently
drawing the shorter of the two would lose markers.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each marker, in draw order. - radius (
Float64): Radius shared by every marker, in pixels. - colors (
List[Color]): One color per centre, same length ascenters.
Raises:
fill_mesh
fn def fill_mesh(mut self, points: List[FPoint], faces: List[Int], colors: List[Color])Many adjacent triangles in one call, drawn as one shape: no seam along an edge two faces share, anti-aliasing only at the outline of the whole. What a surface plot draws.
On the raster backend a face filled on its own leaves a light
line along every edge it shares with a neighbour, because each
face’s edge coverage blends against the background rather
than against the other face (#425). Only a call that sees all
the faces can fix that, which is why this is on the trait
rather than a loop over fill_path_aa. The vector backends
emit one element per face; browsers and PDF viewers seam the
same way, so an opaque face there also carries a hairline
stroke in its own color, which is the standard remedy. A
translucent face is left unstroked, since the stroke would
double its alpha along the edge, and keeps the viewer’s seam.
Faces are drawn in the order given – a mesh sorted back to front composites as the painter’s algorithm expects where faces overlap. Under a transform the vertices map through it. A face of zero area draws nothing; winding does not matter.
Args:
- self (
_Self) - points (
List[FPoint]): The vertices, in user space. - faces (
List[Int]): Index triples intopoints, one triangle each, in draw order. - colors (
List[Color]): One color per triangle, same count as triples.
Raises:
Error: faces is not whole triples, an index is out of
range, or colors is not one per triangle.
fill_mesh_shaded
fn def fill_mesh_shaded(mut self, points: List[FPoint], faces: List[Int], vertex_colors: List[Color])fill_mesh with a color per vertex, interpolated across each face: a smoothly shaded surface rather than a faceted one (#426). Seam-free shared edges, painter’s order and the transform are fill_mesh’s.
The raster backend interpolates in the canvas’s color space,
SRGB or LINEAR, the rule source-over follows. PdfCanvas has
the same thing natively, a Type 4 free-form triangle mesh
shading, and emits it. SvgCanvas does not: mesh gradients
are SVG 2 and no shipping browser renders them, so it emits
each face flat at the mean of its three corner colors, which
is what every SVG exporter does and the first place the three
backends do not produce the same picture. A consumer whose
SVG must match the raster output draws the surface with
fill_mesh and a color per face instead.
A different name rather than an overload of fill_mesh,
because a color per vertex and a color per face are the same
type and differ only in count.
Args:
- self (
_Self) - points (
List[FPoint]): The vertices, in user space. - faces (
List[Int]): Index triples intopoints, one triangle each, in draw order. - vertex_colors (
List[Color]): One color per vertex, same count aspoints.
Raises:
Error: faces is not whole triples, an index is out of
range, or vertex_colors is not one per vertex.
fill_ellipses_aa
fn def fill_ellipses_aa(mut self, centers: List[FPoint], rx: Float64, ry: Float64, color: Color)Many equal-size ellipses in one call, in draw order.
fill_circles_aa for markers that are not round – the same
pixels as fill_ellipse_aa per centre, and on the raster
backend far faster for the same reason: the canvas splits
across cores rather than the markers, which are individually
too small to be worth a thread. A vector backend emits one
element per marker either way.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each marker, in draw order. - rx (
Float64): Horizontal radius shared by every marker, in pixels. - ry (
Float64): Vertical radius shared by every marker, in pixels. - color (
Color): Fill color shared by every marker.
Raises:
fn def fill_ellipses_aa(mut self, centers: List[FPoint], rx: Float64, ry: Float64, colors: List[Color])fill_ellipses_aa with a color per marker.
Raises for the same reason the disk overload does: colors
has to be the same length as centers, and drawing the
shorter of the two would silently lose markers.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each marker, in draw order. - rx (
Float64): Horizontal radius shared by every marker, in pixels. - ry (
Float64): Vertical radius shared by every marker, in pixels. - colors (
List[Color]): One color per centre, same length ascenters.
Raises:
draw_circle_aa
fn def draw_circle_aa(mut self, cx: Float64, cy: Float64, radius: Float64, color: Color, width: Float64 = 1)An anti-aliased circle outline, width pixels wide (default 1), at a sub-pixel center and radius.
Args:
- self (
_Self) - cx (
Float64): Center x, sub-pixel. - cy (
Float64): Center y, sub-pixel. - radius (
Float64): Circle radius in pixels, to the middle of the stroke. - color (
Color): Outline color. - width (
Float64): Stroke width in pixels.
fill_ellipse_aa
fn def fill_ellipse_aa(mut self, cx: Int, cy: Int, rx: Int, ry: Int, color: Color)An anti-aliased filled ellipse.
Args:
- self (
_Self) - cx (
Int): Center x. - cy (
Int): Center y. - rx (
Int): Horizontal radius in pixels. - ry (
Int): Vertical radius in pixels. - color (
Color): Fill color.
fn def fill_ellipse_aa(mut self, cx: Float64, cy: Float64, rx: Float64, ry: Float64, color: Color)An anti-aliased filled ellipse at a sub-pixel center and radii.
Args:
- self (
_Self) - cx (
Float64): Center x, sub-pixel. - cy (
Float64): Center y, sub-pixel. - rx (
Float64): Horizontal radius in pixels. - ry (
Float64): Vertical radius in pixels. - color (
Color): Fill color.
draw_ellipse_aa
fn def draw_ellipse_aa(mut self, cx: Int, cy: Int, rx: Int, ry: Int, color: Color)An anti-aliased ellipse outline, ~1px wide.
Args:
- self (
_Self) - cx (
Int): Center x. - cy (
Int): Center y. - rx (
Int): Horizontal radius in pixels. - ry (
Int): Vertical radius in pixels. - color (
Color): Outline color.
fn def draw_ellipse_aa(mut self, cx: Float64, cy: Float64, rx: Float64, ry: Float64, color: Color, width: Float64 = 1)An anti-aliased ellipse outline, width pixels wide (default 1), at a sub-pixel center and radii.
Args:
- self (
_Self) - cx (
Float64): Center x, sub-pixel. - cy (
Float64): Center y, sub-pixel. - rx (
Float64): Horizontal radius in pixels, to the middle of the stroke. - ry (
Float64): Vertical radius in pixels, to the middle of the stroke. - color (
Color): Outline color. - width (
Float64): Stroke width in pixels.
fill_arc_aa
fn def fill_arc_aa(mut self, cx: Float64, cy: Float64, radius: Float64, start_angle: Float64, end_angle: Float64, color: Color)An anti-aliased filled pie-slice wedge.
Args:
- self (
_Self) - cx (
Float64): Center x. - cy (
Float64): Center y. - radius (
Float64): Wedge radius in pixels. - start_angle (
Float64): Sweep start, radians, 0 pointing along +x. - end_angle (
Float64): Sweep end, radians. Must be >= start_angle. - color (
Color): Fill color.
fill_arcs_aa
fn def fill_arcs_aa(mut self, centers: List[FPoint], radius: Float64, start_angle: Float64, end_angle: Float64, color: Color)Many equal-size wedges in one call, in draw order.
fill_circles_aa for pie and donut segments: the same pixels
as fill_arc_aa per centre, with the canvas split across
cores rather than the wedges. The sweep is shared by the
batch, so this draws one shape repeated at many centres, not
many different shapes.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each wedge, in draw order. - radius (
Float64): Radius shared by every wedge, in pixels. - start_angle (
Float64): Start of the sweep, radians, shared. - end_angle (
Float64): End of the sweep, radians, shared. - color (
Color): Fill color shared by every wedge.
Raises:
fn def fill_arcs_aa(mut self, centers: List[FPoint], radius: Float64, start_angle: Float64, end_angle: Float64, colors: List[Color])fill_arcs_aa with a color per wedge.
Args:
- self (
_Self) - centers (
List[FPoint]): Sub-pixel centre of each wedge, in draw order. - radius (
Float64): Radius shared by every wedge, in pixels. - start_angle (
Float64): Start of the sweep, radians, shared. - end_angle (
Float64): End of the sweep, radians, shared. - colors (
List[Color]): One color per centre, same length ascenters.
Raises:
fill_ring_sector_aa
fn def fill_ring_sector_aa(mut self, cx: Float64, cy: Float64, inner_radius: Float64, outer_radius: Float64, start_angle: Float64, end_angle: Float64, color: Color)An anti-aliased filled ring/donut segment.
Args:
- self (
_Self) - cx (
Float64): Center x. - cy (
Float64): Center y. - inner_radius (
Float64): Ring’s inner edge, in pixels. - outer_radius (
Float64): Ring’s outer edge, in pixels. Must exceed inner_radius. - start_angle (
Float64): Sweep start, radians, 0 pointing along +x. - end_angle (
Float64): Sweep end, radians. Must be >= start_angle. - color (
Color): Fill color.
stroke_path_aa
fn def stroke_path_aa(mut self, path: Path, color: Color, width: Float64 = 1, dashes: List[Float64] = List(), dash_offset: Float64 = 0, cap: LineCap = LineCap.ROUND, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)An anti-aliased stroke of a Path’s outline.
Args:
- self (
_Self) - path (
Path): Path to stroke. - color (
Color): Stroke color. - width (
Float64): Stroke width in pixels. - dashes (
List[Float64]): On/off segment lengths in user-space pixels, cycled along the stroke. Empty (default) draws a solid line. - dash_offset (
Float64): Distance into the dash pattern the stroke starts at. - cap (
LineCap): How an open sub-path’s two ends are finished – see LineCap. - join (
LineJoin): How corners are turned – see LineJoin. - miter_limit (
Float64): Ratio past which a MITER join falls back to BEVEL, as a multiple of half the stroke width.
fill_path_aa
fn def fill_path_aa(mut self, path: Path, color: Color, fill_rule: FillRule = FillRule.EVEN_ODD)An anti-aliased fill of a Path’s interior.
Args:
- self (
_Self) - path (
Path): Path to fill. - color (
Color): Fill color. - fill_rule (
FillRule): EVEN_ODD (default) or NONZERO – see FillRule. The same rule on every backend.
draw_image
fn def draw_image(mut self, image: Canvas, x: Float64, y: Float64, width: Float64 = 0, height: Float64 = 0)Draw a block of pixels with its top-left at (x, y), scaled to width x height in user space (the image’s own pixel size when 0), under the current transform, each image pixel one hard-edged cell of the block.
Args:
- self (
_Self) - image (
Canvas): The pixels to draw. Unchanged. - x (
Float64): Left edge. - y (
Float64): Top edge. - width (
Float64): Drawn width, or 0 forimage.width. - height (
Float64): Drawn height, or 0 forimage.height.
Raises:
Error: Backend-specific; see each implementation.
draw_text
fn def draw_text(mut self, x: Float64, y: Float64, text: String, color: Color, size: Float64, family: String = "Sans", slant: FontSlant = FontSlant.NORMAL, weight: FontWeight = FontWeight.NORMAL, rotation: Float64 = 0, align: TextAlign = TextAlign.LEFT, *, mut cache: FontCache)Draw text, one or more “\n”-separated lines, anchored at (x, y) on the first line’s baseline, under the current transform. align places each line against the anchor and rotation turns the whole block about it, radians, clockwise on screen. The same arguments as canvas.text.render.draw_text less its kerning and ligature switches, so a label laid out for one backend lands at the same anchor on the others.
family is a font-matching query on the raster and PDF
backends and a CSS font-family on SVG; the generic names
"Sans", "Serif" and "Monospace" mean the same thing on
all three. Pass one FontCache to every call in a batch: the
raster backend resolves fonts and caches glyph masks through
it; the vector backends take it for the signature’s sake and
do their own resolution.
Args:
- self (
_Self) - x (
Float64): Anchor x, sub-pixel: the baseline’s left end forTextAlign.LEFT. - y (
Float64): Anchor y, sub-pixel: the first line’s baseline. - text (
String): Text to draw. - color (
Color): Fill color. - size (
Float64): Font size in pixels. - family (
String): Font family name or generic alias. - slant (
FontSlant): Upright, italic or oblique. - weight (
FontWeight): Normal or bold. - rotation (
Float64): Radians about the anchor. - align (
TextAlign): Horizontal alignment of each line. - cache (
FontCache): Shared font and glyph cache.
Raises:
Error: No font could be resolved for family, on the
backends that resolve one.
draw_text_runs
fn def draw_text_runs(mut self, x: Float64, y: Float64, runs: List[TextRun], color: Color, family: String = "Sans", weight: FontWeight = FontWeight.NORMAL, rotation: Float64 = 0, align: TextAlign = TextAlign.LEFT, *, mut cache: FontCache)Draw one label made of several runs, each at its own size, slant and offset (TextRun), anchored at (x, y) on the label’s baseline. What one draw_text cannot say: a variable in italic beside upright text, a superscript at a smaller size raised off the baseline. The runs stay one label – one <text> element of <tspan>s on SVG, so a viewer selects, copies and announces one string – where the same runs as separate draw_text calls are as many elements.
The pen starts at the label’s origin and each run moves it by
its dx, then by its own advance; align places the whole
label by where the pen ends, and rotation turns the whole
label about the anchor. The raster, PDF and bounds backends
draw each run with draw_text at the anchor
canvas.text.render.text_run_anchors computes for it; SVG
writes the offsets into the <tspan>s and the viewer’s own
font metrics resolve the advances and the alignment, as they
do for a single run. A run with no text draws nothing and
moves nothing. No line-break handling: each run is one line.
family, weight and cache mean what they mean for
draw_text, and are shared by every run.
Args:
- self (
_Self) - x (
Float64): Anchor x, sub-pixel: the label’s left end forTextAlign.LEFT. - y (
Float64): Anchor y, sub-pixel: the label’s baseline. - runs (
List[TextRun]): The label’s runs, in reading order. - color (
Color): Fill color. - family (
String): Font family name or generic alias. - weight (
FontWeight): Normal or bold. - rotation (
Float64): Radians about the anchor. - align (
TextAlign): Horizontal alignment of the whole label. - cache (
FontCache): Shared font and glyph cache.
Raises:
Error: No font could be resolved for family, on the
backends that resolve one.
push_clip
fn def push_clip(mut self, x: Int, y: Int, width: Int, height: Int)Restrict drawing to the pixels x through x + width - 1 by y through y + height - 1, until the matching pop_clip.
Intersects with whatever is already clipped, so a nested clip can restrict further but never escape its parent. The rectangle is in user space and takes the current transform.
Args:
- self (
_Self) - x (
Int): Left edge. - y (
Int): Top edge. - width (
Int): Width. - height (
Int): Height.
pop_clip
fn def pop_clip(mut self)Undo the innermost push_clip, reverting to the clip outside it or to no clip at all. A no-op when nothing is pushed, on every backend.
Args:
- self (
_Self)
begin_annotated_group
fn def begin_annotated_group(mut self, title: String)Open a group labeled title, covering every primitive drawn until end_annotated_group. A backend that can carry the label does; one that cannot ignores it.
On SvgCanvas this emits <g><title>...</title>, which is
what a browser shows as a hover tooltip and what a screen
reader announces for the group. On Canvas it does nothing: a
raster image has nowhere to put a name.
Groups do not nest. Opening one while another is open closes the first, so the markup stays well formed however a caller pairs its calls, and a group left open when the document is serialized is closed then.
Args:
- self (
_Self) - title (
String): Human-readable label for the drawing that follows. Escaped by the backend; pass it raw.
end_annotated_group
fn def end_annotated_group(mut self)Close the group opened by begin_annotated_group, a no-op if none is open – matching Canvas.pop_clip, which also treats an unbalanced close as nothing to undo rather than an error.
Args:
- self (
_Self)
begin_batch
fn def begin_batch(mut self)Start deferring anti-aliased shapes so that end_batch can draw them in one parallel pass, in the order they were called. Canvas.begin_batch says which primitives are deferred and what happens to everything else in between; on SvgCanvas and PdfCanvas this does nothing, since every element is written into the document in order regardless.
Calls nest; only the outermost end_batch draws.
Args:
- self (
_Self)
end_batch
fn def end_batch(mut self)Draw everything deferred since the matching begin_batch; a no-op with none open.
Args:
- self (
_Self)
save
fn def save(mut self)Push the current transform (and, on a backend that clips, the clip state) for restore to put back.
Args:
- self (
_Self)
restore
fn def restore(mut self)Pop what save pushed. A no-op with nothing saved.
Args:
- self (
_Self)
translate
fn def translate(mut self, tx: Float64, ty: Float64)Shift subsequent drawing by (tx, ty) in the current user space.
Args:
- self (
_Self) - tx (
Float64): Horizontal shift. - ty (
Float64): Vertical shift.
rotate
fn def rotate(mut self, angle: Float64)Turn subsequent drawing by angle radians about the current origin; positive is clockwise on screen.
Args:
- self (
_Self) - angle (
Float64): Radians.
scale
fn def scale(mut self, sx: Float64, sy: Float64)Scale subsequent drawing about the current origin, each axis by its own factor.
Args:
- self (
_Self) - sx (
Float64): Horizontal factor. - sy (
Float64): Vertical factor.
transform
fn def transform(mut self, matrix: Matrix2D)Compose matrix into the current transform, applied to coordinates before everything already in place.
Args:
- self (
_Self) - matrix (
Matrix2D): The map to apply first.
set_transform
fn def set_transform(mut self, matrix: Matrix2D)Replace the current transform outright.
Args:
- self (
_Self) - matrix (
Matrix2D): The new map from user space to the backend’s own coordinates.
reset_transform
fn def reset_transform(mut self)Back to the identity.
Args:
- self (
_Self)
current_transform
fn def current_transform(self) -> Matrix2DThe map every drawing call currently applies.
Args:
- self (
_Self)
Returns:
Matrix2D: The current transform; the identity if none is set.
has_transform
fn def has_transform(self) -> BoolWhether the current transform is anything but the identity.
Args:
- self (
_Self)
Returns:
Bool: True if drawing is being mapped.
set_blend_mode
fn def set_blend_mode(mut self, mode: BlendMode)Set how later drawing calls combine with what is already there. save/restore carry the mode. A backend that cannot express a mode draws source-over and says so in its docstring (SvgCanvas has no attribute for the Porter-Duff operators).
Args:
- self (
_Self) - mode (
BlendMode): The blend mode later calls use.
blend_mode
fn def blend_mode(self) -> BlendModeThe blend mode later drawing calls will use.
Args:
- self (
_Self)
Returns:
BlendMode: The current mode, BlendMode.SOURCE_OVER until
set_blend_mode says otherwise.
set_color_space
fn def set_color_space(mut self, space: ColorSpace)Set the space later source-over blends mix in (see ColorSpace). save/restore carry it. The raster backend blends in it; SvgCanvas asks the viewer to, with color-interpolation="linearRGB".
Args:
- self (
_Self) - space (
ColorSpace): The color space later calls blend in.
color_space
fn def color_space(self) -> ColorSpaceThe color space later drawing calls will blend in.
Args:
- self (
_Self)
Returns:
ColorSpace: The current space, ColorSpace.SRGB until
set_color_space says otherwise.