Skip to main content

Window

Struct Window 

Source
pub struct Window {
    pub window: Window,
    pub width: usize,
    pub height: usize,
    pub framebuffer_raw: Vec<u32>,
    pub is_fullscreen: bool,
    pub aa: f32,
    /* private fields */
}
Expand description

Owns the window and the raw flat framebuffer to be rendered.

Fields§

§window: Window§width: usize§height: usize§framebuffer_raw: Vec<u32>§is_fullscreen: bool§aa: f32

Anti-aliasing softness in pixels. 0.0 = hard edges (no AA), 1.0 = standard AA. Higher values produce softer/blurrier edges.

Implementations§

Source§

impl Window

Source

pub fn default() -> Self

Creates a non-resizable window with a resolution of 1280 by 720 pixels

Source

pub fn custom( name: &str, width: usize, height: usize, borders: bool, resizable: bool, ) -> Self

Creates a window with custom resolution, can be borderless and resizable

Source

pub fn get_typed_chars(&self) -> Vec<char>

Drains and returns all characters typed since the last call.

Source

pub fn draw_pixel(&mut self, x: usize, y: usize, color: &Color)

Draws a single pixel at given coordinates with color, respecting alpha

Source

pub fn get_pixel(&self, x: usize, y: usize) -> u32

Source

pub fn clear(&mut self, color: &Color)

Source

pub fn draw_line( &mut self, x0: isize, y0: isize, x1: isize, y1: isize, th: usize, color: Color, )

Draws a straight line. Uses AA when self.aa > 0.

Source

pub fn draw_line_dashed( &mut self, x0: isize, y0: isize, x1: isize, y1: isize, th: usize, dash_len: usize, gap_len: usize, color: Color, )

Draws a dashed line. dash_len is pixels on, gap_len is pixels off.

Source

pub fn draw_line_dotted( &mut self, x0: isize, y0: isize, x1: isize, y1: isize, th: usize, spacing: usize, color: Color, )

Draws a dotted line (dash=1, gap=spacing)

Source

pub fn draw_rect_f( &mut self, x: usize, y: usize, w: usize, h: usize, radius: usize, color: &Color, blur: usize, )

Draws a filled rectangle with optional rounded corners, alpha blending, and background blur. Pass radius: 0 for sharp corners, blur: 0 for no blur.

Source

pub fn draw_rect( &mut self, x: usize, y: usize, w: usize, h: usize, radius: usize, color: &Color, )

Draws a hollow rectangle with optional rounded corners. Pass radius: 0 for sharp corners.

Source

pub fn draw_ellipse_f( &mut self, cx: isize, cy: isize, rx: usize, ry: usize, color: &Color, blur: usize, )

Draws a filled ellipse with alpha blending and optional background blur. For circles, pass rx == ry. Pass blur: 0 for no blur.

Source

pub fn draw_ellipse( &mut self, cx: isize, cy: isize, rx: usize, ry: usize, color: &Color, )

Draws a hollow ellipse. For circles, pass rx == ry.

Source

pub fn draw_gradient_h( &mut self, x: usize, y: usize, w: usize, h: usize, radius: usize, color_left: &Color, color_right: &Color, )

Draws a filled rectangle with a horizontal linear gradient (left to right) Draws a filled rectangle with a horizontal linear gradient (left to right). Pass radius: 0 for sharp corners.

Source

pub fn draw_gradient_v( &mut self, x: usize, y: usize, w: usize, h: usize, radius: usize, color_top: &Color, color_bottom: &Color, )

Draws a filled rectangle with a vertical linear gradient (top to bottom). Pass radius: 0 for sharp corners.

Source

pub fn draw_box_shadow( &mut self, x: isize, y: isize, w: usize, h: usize, radius: usize, offset_x: isize, offset_y: isize, spread: isize, blur: usize, color: &Color, )

Draws a rectangular drop shadow. Draws a drop shadow with optional rounded corners using SDF distance falloff. Pass radius: 0 for sharp corners.

Source

pub fn draw_bezier_quad( &mut self, x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32, th: usize, color: &Color, )

Draws a quadratic bezier curve from p0 to p2 with control point p1

Source

pub fn draw_bezier_cubic( &mut self, x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32, th: usize, color: &Color, )

Draws a cubic bezier curve from p0 to p3 with control points p1 and p2

Source

pub fn draw_text( &mut self, x: usize, y: usize, text: &Text, size: f32, color: &Color, )

Draws text using the passed font

Source

pub fn update(&mut self)

Updates the window. Should be called in a loop until the window is to be closed

Source

pub fn get_mouse_state(&self) -> MouseState

Source

pub fn draw_text_centered( &mut self, x: usize, y: usize, w: usize, h: usize, text: &Text, size: f32, color: &Color, )

Draws text centered both horizontally and vertically within a bounding box

Source

pub fn blur_region( &mut self, rx: usize, ry: usize, rw: usize, rh: usize, radius: usize, )

Applies a separable box blur to a rectangular region of the framebuffer. Uses an O(n) sliding window — performance is independent of blur radius.

Source

pub fn blur_region_rounded( &mut self, rx: usize, ry: usize, rw: usize, rh: usize, corner_radius: usize, blur_radius: usize, )

Applies a box blur to a region, preserving pixels outside rounded corners. This prevents the rectangular blur from leaking past rounded card edges.

Source

pub fn push_clip(&mut self, x: usize, y: usize, w: usize, h: usize)

Pushes a clipping rectangle. Drawing outside this region is discarded. Nested clips are intersected.

Source

pub fn pop_clip(&mut self)

Pops the most recent clipping rectangle

Source

pub fn current_clip(&self) -> Option<(usize, usize, usize, usize)>

Returns the current clip bounds, or None if no clip is active

Source

pub fn draw_text_wrapped( &mut self, x: usize, y: usize, text: &Text, size: f32, color: &Color, max_width: usize, ) -> usize

Draws text with word wrapping within max_width pixels. Returns the total height used.

Auto Trait Implementations§

§

impl Freeze for Window

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

§

impl !UnwindSafe for Window

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.