Module: graphics.core

Source: ./graphics/core.reef


Overview

graphics/core.reef - Core types for 2D graphics Part of reef-stdlib graphics module


Types

CoordinateSystem (enum)

Variants:

  • TopLeft
  • BottomLeft

Color

Fields:

Name Type
r uint8
g uint8
b uint8
a uint8

Point

Fields:

Name Type
x float
y float

Size

Fields:

Name Type
width float
height float

Rect

Fields:

Name Type
x float
y float
width float
height float

Edges

Fields:

Name Type
top float
right float
bottom float
left float

Functions

fn min_f(a: float, b: float): float

fn max_f(a: float, b: float): float

fn clamp_f(x: float, lo: float, hi: float): float

fn sqrt_f(x: float): float

Simple square root using Newton-Raphson

fn rgba(r: uint8, g: uint8, b: uint8, a: uint8): Color

Construct color from RGBA components

fn rgb(r: uint8, g: uint8, b: uint8): Color

Construct opaque color from RGB components

fn with_alpha(c: Color, a: uint8): Color

Return color with modified alpha

fn white(): Color

Predefined colors

fn black(): Color

fn transparent(): Color

fn red(): Color

fn green(): Color

fn blue(): Color

fn gray(value: uint8): Color

fn yellow(): Color

fn cyan(): Color

fn magenta(): Color

fn orange(): Color

fn purple(): Color

fn point(x: float, y: float): Point

fn point_zero(): Point

fn distance(p1: Point, p2: Point): float

fn lerp_point(p1: Point, p2: Point, t: float): Point

fn size(w: float, h: float): Size

fn size_zero(): Size

fn rect(x: float, y: float, w: float, h: float): Rect

fn rect_from_points(p1: Point, p2: Point): Rect

fn rect_from_center(c: Point, s: Size): Rect

fn rect_width(r: Rect): float

fn rect_height(r: Rect): float

fn contains(r: Rect, p: Point): bool

Check if rect contains point

fn contains_rect(r1: Rect, r2: Rect): bool

Check if r1 completely contains r2

fn intersects(r1: Rect, r2: Rect): bool

Check if two rects intersect

fn intersection(r1: Rect, r2: Rect): Rect

Return intersection of two rects (empty rect if no intersection)

fn union_rect(r1: Rect, r2: Rect): Rect

Return bounding rect containing both rects

fn inset(r: Rect, dx: float, dy: float): Rect

Return rect inset by dx, dy on each side

fn offset(r: Rect, dx: float, dy: float): Rect

Return rect offset by dx, dy

fn center(r: Rect): Point

Return center point of rect

fn top_left(r: Rect): Point

Return top-left corner of rect

fn bottom_right(r: Rect): Point

Return bottom-right corner of rect

fn edges(top: float, right: float, bottom: float, left: float): Edges

fn edges_all(value: float): Edges

fn edges_symmetric(vertical: float, horizontal: float): Edges

fn edges_zero(): Edges


Generated by reefc doc