PlaydateGraphics

Struct PlaydateGraphics 

Source
pub struct PlaydateGraphics {
    pub video: PlaydateVideo,
    /* private fields */
}

Fields§

§video: PlaydateVideo

Implementations§

Source§

impl PlaydateGraphics

Source

pub fn clear(&self, color: impl Into<ColorOrPattern>)

Clears the entire display, filling it with color.

Source

pub fn set_background_color(&self, color: Color)

Sets the background color shown when the display is offset or for clearing dirty areas in the sprite system.

Source

pub fn set_stencil(&self, stencil: impl AsRef<Bitmap>)

Sets the stencil used for drawing. For a tiled stencil, use setStencilImage() instead.

Source

pub fn set_draw_mode(&self, mode: BitmapDrawMode)

Sets the mode used for drawing bitmaps. Note that text drawing uses bitmaps, so this affects how fonts are displayed as well.

Source

pub fn set_draw_offset(&self, delta: Vec2<i32>)

Offsets the origin point for all drawing calls to x, y (can be negative). This is useful, for example, for centering a “camera” on a sprite that is moving around a world larger than the screen.

Source

pub fn set_clip_rect(&self, rect: Rect<i32>)

Sets the current clip rect, using world coordinates—​that is, the given rectangle will be translated by the current drawing offset. The clip rect is cleared at the beginning of each update.

Source

pub fn clear_clip_rect(&self)

Clears the current clip rect.

Source

pub fn set_line_cap_style(&self, end_cap_style: LineCapStyle)

Sets the end cap style used in the line drawing functions.

Source

pub fn set_font(&self, font: &Font)

Sets the font to use in subsequent drawText calls.

Source

pub fn set_text_tracking(&self, tracking: i32)

Sets the tracking to use when drawing text.

Source

pub fn push_context(&self, target: impl AsRef<Bitmap>)

Push a new drawing context for drawing into the given bitmap. If target is nil, the drawing functions will use the display framebuffer.

Source

pub fn pop_context(&self)

Pops a context off the stack (if any are left), restoring the drawing settings from before the context was pushed.

Source

pub fn draw_bitmap( &self, bitmap: impl AsRef<Bitmap>, pos: Vec2<i32>, flip: BitmapFlip, )

Draws the bitmap with its upper-left corner at location x, y, using the given flip orientation.

Source

pub fn tile_bitmap( &self, bitmap: impl AsRef<Bitmap>, rect: Rect<i32>, flip: BitmapFlip, )

Draws the bitmap with its upper-left corner at location x, y tiled inside a width by height rectangle.

Source

pub fn draw_line( &self, start: Vec2<i32>, end: Vec2<i32>, width: i32, color: impl Into<ColorOrPattern>, )

Draws a line from x1, y1 to x2, y2 with a stroke width of width.

Source

pub fn fill_triangle( &self, pos1: Vec2<i32>, pos2: Vec2<i32>, pos3: Vec2<i32>, color: impl Into<ColorOrPattern>, )

Draws a filled triangle with points at x1, y1, x2, y2, and x3, y3.

Source

pub fn draw_pixel(&self, pos: Vec2<i32>, color: Color)

Draws a pixel at x, y.

Source

pub fn draw_rect(&self, rect: Rect<i32>, color: impl Into<ColorOrPattern>)

Draws a width by height rect at x, y.

Source

pub fn fill_rect(&self, rect: Rect<i32>, color: impl Into<ColorOrPattern>)

Draws a filled width by height rect at x, y.

Source

pub fn draw_ellipse( &self, rect: Rect<i32>, line_width: i32, start_angle: f32, end_angle: f32, color: impl Into<ColorOrPattern>, )

Draws an ellipse inside the rectangle {x, y, width, height} of width lineWidth (inset from the rectangle bounds). If startAngle != _endAngle, this draws an arc between the given angles. Angles are given in degrees, clockwise from due north.

Source

pub fn fill_ellipse( &self, rect: Rect<i32>, start_angle: f32, end_angle: f32, color: impl Into<ColorOrPattern>, )

Fills an ellipse inside the rectangle {x, y, width, height}. If startAngle != _endAngle, this draws a wedge/Pacman between the given angles. Angles are given in degrees, clockwise from due north.

Source

pub fn draw_scaled_bitmap( &self, bitmap: impl AsRef<Bitmap>, pos: Vec2<i32>, scale: Vec2<f32>, )

Draws the bitmap scaled to xscale and yscale with its upper-left corner at location x, y. Note that flip is not available when drawing scaled bitmaps but negative scale values will achieve the same effect.

Source

pub fn draw_text(&self, text: impl AsRef<str>, pos: Vec2<i32>) -> i32

Draws the given text using the provided options. If no font has been set with setFont, the default system font Asheville Sans 14 Light is used.

Source

pub fn new_bitmap( &self, width: i32, height: i32, bgcolor: impl Into<ColorOrPattern>, ) -> Bitmap

Allocates and returns a new width by height LCDBitmap filled with bgcolor.

Source

pub fn load_bitmap(&self, path: impl AsRef<str>) -> Result<Bitmap, Error>

Allocates and returns a new LCDBitmap from the file at path. If there is no file at path, the function returns null.

Source

pub fn new_bitmap_table( &self, count: i32, width: i32, height: i32, ) -> BitmapTable

Allocates and returns a new LCDBitmapTable that can hold count width by height LCDBitmaps.

Source

pub fn load_bitmap_table( &self, path: impl AsRef<str>, ) -> Result<BitmapTable, Error>

Allocates and returns a new LCDBitmap from the file at path. If there is no file at path, the function returns null.

Source

pub fn load_font(&self, path: impl AsRef<str>) -> Result<Font, Error>

Returns the LCDFont object for the font file at path. In case of error, outErr points to a string describing the error.

Source

pub fn get_frame(&self) -> *mut u8

Returns the current display frame buffer. Rows are 32-bit aligned, so the row stride is 52 bytes, with the extra 2 bytes per row ignored. Bytes are MSB-ordered; i.e., the pixel in column 0 is the 0x80 bit of the first byte of the row.

Source

pub fn get_display_frame(&self) -> *mut u8

Returns the current display frame buffer. Rows are 32-bit aligned, so the row stride is 52 bytes, with the extra 2 bytes per row ignored. Bytes are MSB-ordered; i.e., the pixel in column 0 is the 0x80 bit of the first byte of the row.

Source

pub fn get_debug_bitmap(&self) -> Option<Ref<'_, Bitmap>>

Only valid in the Simulator, returns the debug framebuffer as a bitmap. Function is NULL on device.

Source

pub fn copy_frame_buffer_bitmap(&self) -> Bitmap

Returns a copy the contents of the working frame buffer as a bitmap. The caller is responsible for freeing the returned bitmap with playdate->graphics->freeBitmap().

Source

pub fn mark_updated_rows(&self, start: i32, end: i32)

After updating pixels in the buffer returned by getFrame(), you must tell the graphics system which rows were updated. This function marks a contiguous range of rows as updated (e.g., markUpdatedRows(0,LCD_ROWS-1) tells the system to update the entire display). Both “start” and “end” are included in the range.

Source

pub fn display(&self)

Manually flushes the current frame buffer out to the display. This function is automatically called after each pass through the run loop, so there shouldn’t be any need to call it yourself.

Source

pub fn set_screen_clip_rect(&self, rect: Rect<i32>)

Sets the current clip rect in screen coordinates.

Source

pub fn fill_polygon( &self, n_points: i32, coords: impl AsRef<[i32]>, color: impl Into<ColorOrPattern>, fillrule: PolygonFillRule, )

Fills the polygon with vertices at the given coordinates (an array of 2*nPoints ints containing alternating x and y values) using the given color and fill, or winding, rule. See Nonzero-rule for an explanation of the winding rule.

Source

pub fn get_display_buffer_bitmap(&self) -> Ref<'_, Bitmap>

Returns a bitmap containing the contents of the display buffer. The system owns this bitmap—​do not free it!

Source

pub fn draw_rotated_bitmap( &self, bitmap: impl AsRef<Bitmap>, pos: Vec2<i32>, rotation: f32, center_pos: Vec2<f32>, scale: Vec2<f32>, )

Draws the bitmap scaled to xscale and yscale then rotated by degrees with its center as given by proportions centerx and centery at x, y; that is: if centerx and centery are both 0.5 the center of the image is at (x,y), if centerx and centery are both 0 the top left corner of the image (before rotation) is at (x,y), etc.

Source

pub fn set_text_leading(&self, leading: i32)

Sets the leading adjustment (added to the leading specified in the font) to use when drawing text.

Source

pub fn set_stencil_image(&self, stencil: impl AsRef<Bitmap>, tile: i32)

Sets the stencil used for drawing. If the tile flag is set the stencil image will be tiled. Tiled stencils must have width equal to a multiple of 32 pixels.

Source

pub unsafe fn make_font_from_data( &self, data: *mut LCDFontData, wide: i32, ) -> Font

Returns an LCDFont object wrapping the LCDFontData data comprising the contents (minus 16-byte header) of an uncompressed pft file. wide corresponds to the flag in the header indicating whether the font contains glyphs at codepoints above U+1FFFF.

§Safety

Assumes that the LCDFontData is valid.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.