struct MouseState {
pos: Point,
pressed_btns: HashSet<MouseButton>,
}
impl MouseState {
fn is_pressed(&self) -> bool {
!self.pressed_btns.is_empty()
}
fn is_down(&self, btn: MouseButton) -> bool {
self.pressed_btns.contains(btn)
}
}
struct KeyState {
pressed_keys: HashSet<Key>
}
impl KeyState {
fn is_pressed(&self) -> bool {
!self.pressed_keys.is_empty()
}
fn is_down(&self, key: Key) -> bool {
self.pressed_keys.contains(key)
}
}
State {
mouse_state: MouseState,
pmouse_state: MouseState,
key_state: KeyState,
elements: Vec<Element>,??
loaded_fonts: Vec<>,??
}
Color:
hsb(hue: u8, saturation: u8, brightness: u8) -> Color
hsl(hue: u8, saturation: u8, lightness: u8) -> Color
Color.hue() -> u16
Color.set_hue(val: u16)
Color.saturation() -> u8
Color.set_saturation(val: u8)
Color.brightness() -> u8
Color.set_brightness(val: u8)
Color.lightness() -> u8
Color.set_lightness(val: u8)
Shapes:
State::point(p: Vector)
State::line(p1: Vector, p2: Vector)
State::arc(p: Vector, w: Num, h: Num, start: Float, stop: Float)
State::circle(c: Vector, d: Num);
State::ellipse(c: Vector, w: Num, h: Num);
State::quad(p1: Vector, p2: Vector, p3: Vector, p4: Vector)
State::square(p: Vector, s: Num)
State::square_rounded(p: Vector, s: Num, r: Num)
State::rect(p: Vector, w: Num, h: Num)
State::rect_rounded(p: Vector, w: Num, h: Num, r: Num)
State::triangle(p1: Vector, p2: Vector, p3: Vector)
State::geometry_detail(x_count: Num, y_count: Num)
State::point(p: Vector)
State::line(p1: Vector, p2: Vector)
State::plane(p1: Vector, p2: Vector)
State::sphere(c: Vector, d: Num)
State::ellipsoid(rx: Num, ry: Num, rz: Num)
State::box_(p: Vector, w: Num, h: Num, d: Num)
ShapeCap { Both, Top, Bottom }
State::cylinder(c: Vector, d: Num, h: Num)
State::cone(c: Vector, d: Num, h: Num)
State::torus(c: Vector, r: Num, tr: Num)
Math:
create_vector!(vector)
create_vector!(x, y)
create_vector!(x, y, z)
struct Vector<T>
where T: Num {
x: T,
y: T,
z: T,
}
Vertex:
struct Vertex<T>
where T: Num {
x: T,
y: T,
z: T,
u: T,
v: T,
}
Environment:
State::display_width() -> u32
State::display_height() -> u32
State::focused() -> bool State::scale() -> u32
State::fullscreen(val: bool)
State::is_fullscreen() -> bool
State::screen_width(id: WindowId) -> u32
State::screen_height(id: WindowId) -> u32
Structure:
Rendering:
UI:
Element trait:
position(x: i32, y: i32)
changed() input() mouse_pressed()
State::create_slider(min: u32, max: u32, value: u32, step: u32) -> Slider
State::create_button(label: &str, value: &str) -> Button
State::create_checkbox(label: &str, value: bool) -> Checkbox
State::create_selectbox(multiple: bool) -> SelectBox
- add_option(option: &str)
- selected() -> usize
- set_selected(index: usize)
- enable_option(index: usize)
- disable_option(index: usize)
- disable() State::create_radio() -> Radio
- add_option(option: &str)
- selected() -> usize
- set_selected(index: usize)
- enable_option(index: usize)
- disable_option(index: usize)
- disable() InputType { Text, Password } State::create_input(value: &str, type: InputType) -> Input
Transformations:
State::apply_matrix(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32)
State::reset_matrix()
State::rotate(angle: f32)
State::scale(s: f32) State::scale_x(s: f32)
State::scale_y(s: f32)
State::shear_x(angle: f32)
State::shear_y(angle: f32)
State::translate(x: i32, y: i32)
State::rotate_3d(angle: f32, axis: Vector)
State::rotateX(angle: f32)
State::rotateY(angle: f32)
State::rotateZ(angle: f32)
State::scale_z(s: f32)
State::translate_3d(x: i32, y: i32, z: i32)
State Trait:
on_start(&mut self, data: &mut State) -> PixEngineResult<bool>
on_update(&mut self, data: &mut State) -> PixEngineResult<bool>
on_stop(&mut self, data: &mut State) -> PixEngineResult<bool>
Image:
struct Texture {
id: usize,
image: Image,
quad: [Vec2f; 4],
uv: [Vec2f; 4],
uv_scale: Vec2f,
w: [f64; 4],
tint: Color,
}
Renderer:
fn new(title: &str, width: Num, height: Num, fullscreen: bool, vsync: bool)
fn present()
fn clear(color: Color)
fn draw_texture(texture: &Texture)
fn create_texture(width: Num, height: Num)
fn update_texture(id: usize, image: Image)
fn delete_texture(id: usize)
fn update_viewport(pos: Vec2i, size: Vec2i)
Events:
impl State {
pub fn mouse_is_down(&self, btn: MouseButton) -> bool {
self.mouse_state.is_down(btn)
}
pub fn key_is_pressed(&self) -> bool {
self.key_state.is_pressed()
}
pub fn key_is_down(&self, key: Key) -> bool {
self.key_state.is_down(key)
}
}
trait PixApp {
fn on_mouse_moved(&mut self, s: &mut State) {}
fn on_mouse_clicked(&mut self, s: &mut State) {} fn on_mouse_dbl_clicked(&mut self, s: &mut State) {} fn on_mouse_wheel(&self, s: &mut State, delta: i32) {}
fn on_key_pressed(&mut self, s: &mut State) {}
fn on_key_released(&mut self, s: &mut State) {}
}
Typography:
Text {
x: i32,
y: i32,
w: u32,
h: u32,
text: String,
}
- Text.new(text: &str, x: i32, y: i32) -> Self
- Text.with_size(text: &str, x: i32, y: i32, w: u32, h: u32) -> Self
- textBounds() -> Rect
TextAlignHori { Left, Center, Right }
State::text_align_hori() -> TextAlignHori
State::set_text_align_hori(align: TextAlignHori)
TextAlignVert { Top, Center, Bottom, Baseline }
State::text_align_vert() -> TextAlignVert
State::set_text_align_vert(align: TextAlignVert)
State::text_leading() -> u32
State::set_text_leading(size: u32)
State::text_size() -> u32
State::set_text_size(size: u32)
TextStyle { Normal, Italic, Bold, BoldItalic }
State::text_style() -> TextStyle
State::set_text_style(style: TextStyle)
State::text_width(str: &str) -> u32
Font { Arial, Custom(String, PathBuf) }
State::text_font() -> Font
State::set_text_font(font: Font)
State::load_font<P: AsRef<Path>>(name: &str, path: P)