Surfaces, as GameMaker's surface_* functions make them: rasters code draws onto,
kept in the world by id until freed, across rooms.
{world, canvas} = Surfaces.create(world, 320, 200)
world = Surfaces.draw(world, canvas, [%{picture: {:sprite, 3, 0}, position: {10, 10}}])
world = Draw.item(world, Surfaces.item(world, canvas, {x, y}))Drawing onto a surface renders at once, as surface_set_target does: draw/3 takes
draw list items in the surface's own pixels and draws them over what is there, with
the world's pictures lookup, and {:surface, id} naming another surface, each blended
as GameMaker blends onto a surface — its blend factors applied to the alpha channel as
well as the colours (Cauldron2D.Blend's {:gamemaker, mode}). item/4
is a draw list item showing a surface; a frame shows it by looking {:surface, id}
up in the world's surfaces (lookup/2). draw/4 takes :write, the channels
drawing may change, as draw_set_colour_write_enable sets them.
lookup/2 also gives Cauldron2D.GameMaker.Shapes' pictures, such as
{:ellipse, {width, height}, :filled}, and a tile layer's picture
(Cauldron2D.GameMaker.TileLayers).
Summary
Functions
The world with surface id filled with colour {r, g, b} at alpha (draw_clear_alpha).
The world with surface source's pixels put on surface destination with their
top-left corner at {x, y}, replacing what was there, colour and alpha alike
(surface_copy(destination, x, y, source)); what falls outside destination is
left out.
The world with a new surface width × height, clear; {world, id}.
The world with items, in surface id's pixels, drawn over surface id. Option
:write {red, green, blue, alpha}, each true or false, names the channels the
drawing changes; the others keep what the surface held
(draw_set_colour_write_enable). Default: all four.
Whether surface id exists.
The world without surface id.
A draw list item showing surface id with its top-left corner at {x, y}. Options:
those of a draw list item (:scale, :angle, :blend, :alpha, :mode, :depth)
and :origin.
The raster for draw list picture key: a surface of the world's or part of one, a shape, or the world's own pictures.
A draw list item showing the part {left, top, width, height} of surface id, its
top-left corner at {x, y} (draw_surface_part_ext): the part is clipped to the
surface, and what is clipped from its left and top moves the corner by as much, scaled.
Options as item/4's. nil when nothing of the part lies on the surface.
Every surface's raster, by id.
Surface id's size {width, height}.
Types
@type id() :: non_neg_integer()
Functions
@spec clear(Cauldron2D.GameMaker.World.t(), id(), {byte(), byte(), byte()}, number()) :: Cauldron2D.GameMaker.World.t()
The world with surface id filled with colour {r, g, b} at alpha (draw_clear_alpha).
@spec copy(Cauldron2D.GameMaker.World.t(), id(), {integer(), integer()}, id()) :: Cauldron2D.GameMaker.World.t()
The world with surface source's pixels put on surface destination with their
top-left corner at {x, y}, replacing what was there, colour and alpha alike
(surface_copy(destination, x, y, source)); what falls outside destination is
left out.
@spec create(Cauldron2D.GameMaker.World.t(), pos_integer(), pos_integer()) :: {Cauldron2D.GameMaker.World.t(), id()}
The world with a new surface width × height, clear; {world, id}.
@spec draw( Cauldron2D.GameMaker.World.t(), id(), [Cauldron2D.DrawList.item()], keyword() ) :: Cauldron2D.GameMaker.World.t()
The world with items, in surface id's pixels, drawn over surface id. Option
:write {red, green, blue, alpha}, each true or false, names the channels the
drawing changes; the others keep what the surface held
(draw_set_colour_write_enable). Default: all four.
@spec exists?(Cauldron2D.GameMaker.World.t(), id() | nil) :: boolean()
Whether surface id exists.
@spec free(Cauldron2D.GameMaker.World.t(), id()) :: Cauldron2D.GameMaker.World.t()
The world without surface id.
A draw list item showing surface id with its top-left corner at {x, y}. Options:
those of a draw list item (:scale, :angle, :blend, :alpha, :mode, :depth)
and :origin.
@spec lookup(Cauldron2D.GameMaker.World.t(), term()) :: FrenchCurve.Raster.t() | nil
The raster for draw list picture key: a surface of the world's or part of one, a shape, or the world's own pictures.
@spec part_item( Cauldron2D.GameMaker.World.t(), id(), {number(), number(), number(), number()}, {number(), number()}, keyword() ) :: map() | nil
A draw list item showing the part {left, top, width, height} of surface id, its
top-left corner at {x, y} (draw_surface_part_ext): the part is clipped to the
surface, and what is clipped from its left and top moves the corner by as much, scaled.
Options as item/4's. nil when nothing of the part lies on the surface.
@spec rasters(Cauldron2D.GameMaker.World.t()) :: %{ required(id()) => FrenchCurve.Raster.t() }
Every surface's raster, by id.
@spec size(Cauldron2D.GameMaker.World.t(), id()) :: {pos_integer(), pos_integer()}
Surface id's size {width, height}.