Skip to main content

Module drawables

Module drawables 

Source
Expand description

Raylib draw implementations for cotis-defaults render commands and custom drawables.

RaylibDrawable is the extension trait for types that can be drawn by RaylibRender. Built-in impls cover Rectangle, Text, Border, Image, ClipStart/ClipEnd, and RenderTList.

§Custom drawables

use cotis_raylib::drawables::{RaylibDrawable, RaylibDrawContext};

struct CircleDrawable { cx: f32, cy: f32, radius: f32 }

impl RaylibDrawable for CircleDrawable {
    fn draw(self: Box<Self>, ctx: &mut RaylibDrawContext<'_, '_>) {
        // ctx.d.draw_circle(...)
    }
    fn scale_by(&mut self, factor: f32) {
        self.cx *= factor;
        self.cy *= factor;
        self.radius *= factor;
    }
}

§Color conversion

Solid colors are converted by truncating each f32 channel to u8 (expects cotis-defaults 0..=255 range; values outside that range are not clamped).

Structs§

RaylibDrawContext
Per-frame drawing context passed to RaylibDrawable::draw.

Traits§

RaylibDrawable
Types that can be drawn by RaylibRender.