Struct ggez::graphics::CanvasGeneric [−][src]
pub struct CanvasGeneric<Spec> where
Spec: BackendSpec, { /* fields omitted */ }
Expand description
A generic canvas independent of graphics backend. This type should
never need to be used directly; use graphics::Canvas
instead.
Implementations
Gets the backend Image
that is being rendered to.
Note that this will be flipped but otherwise the same, use the to_image
function for the unflipped version.
Gets the backend Target
that is being rendered to.
Returns the dimensions of the canvas.
Get the filter mode for the canvas.
Set the filter mode for the canvas.
pub fn new(
ctx: &mut Context,
width: u16,
height: u16,
samples: NumSamples,
color_format: Format
) -> GameResult<Canvas>
pub fn new(
ctx: &mut Context,
width: u16,
height: u16,
samples: NumSamples,
color_format: Format
) -> GameResult<Canvas>
Create a new Canvas
with the given size and number of samples.
Create a new Canvas
with the current window dimensions.
Creates an Image
with the content of its raw counterpart but transformed to behave like a normal Image
.
Dumps the flipped Canvas
’s data to a Vec
of u8
RBGA8 values.
pub fn encode<P: AsRef<Path>>(
&self,
ctx: &mut Context,
format: ImageFormat,
path: P
) -> GameResult
pub fn encode<P: AsRef<Path>>(
&self,
ctx: &mut Context,
format: ImageFormat,
path: P
) -> GameResult
Encode the Canvas
’s content to the given file format and
write it out to the given path.
See the filesystem
module docs for where exactly
the file will end up.
If the canvas is multi-sampled this function resolves the internal multi-sampled texture into a non-multi-sampled texture that can actually be drawn.
ggez
calls this automatically when you try to draw the canvas onto another target, or when
you copy the underlying image using to_image()
, to_rgba8()
or encode()
.
You shouldn’t need to call this manually, unless you want to access the raw image after something has been drawn on the canvas, but before the canvas has been drawn onto another target itself.