Skip to main content

Module prelude

Module prelude 

Source

Re-exports§

pub use crate::FlakeResult;

Modules§

bounds
cast
flake_image
float
font
identities
int
math
ops
pow
real
rect
sign
span
timer

Macros§

end_frame

Structs§

Camera2D
Color
DrawTextureParams
DrawTextureParams
Image
Image
ParseFloatError
Rect
Rect
RenderTarget
Span
Timer
Timer
WindowButtons

Enums§

CursorIcon
Describes the appearance of the (usually mouse) cursor icon.
FilterType
FilterType
FloatErrorKind
KeyCode
Code representing the location of a physical key
MouseButton
Describes a button of a mouse controller.
WindowLevel
A window level groups windows with respect to their z-position.

Constants§

BLACK
BLUE
CYAN
DARK_BLUE
DARK_CYAN
DARK_GRAY
DARK_GREEN
DARK_MAGENTA
DARK_ORANGE
DARK_PURPLE
DARK_RED
DARK_YELLOW
GRAY
GREEN
LIGHT_BLACK
LIGHT_BLUE
LIGHT_CYAN
LIGHT_GRAY
LIGHT_GREEN
LIGHT_MAGENTA
LIGHT_ORANGE
LIGHT_PURPLE
LIGHT_RED
LIGHT_YELLOW
MAGENTA
ORANGE
PURPLE
RED
TRANSPARENT
WHITE
YELLOW

Traits§

Angle
Angles and their associated trigonometric functions.
Array
An array containing elements of type Element
AsPrimitive
A generic interface for casting between machine scalars with the as operator, which admits narrowing and precision loss. Implementers of this trait AsPrimitive should behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail.
Bounded
Numbers which have upper and lower bounds
CheckedAdd
Performs addition that returns None instead of wrapping around on overflow.
CheckedDiv
Performs division that returns None instead of panicking on division by zero and instead of wrapping around on underflow and overflow.
CheckedEuclid
CheckedMul
Performs multiplication that returns None instead of wrapping around on underflow or overflow.
CheckedNeg
Performs negation that returns None if the result can’t be represented.
CheckedRem
Performs an integral remainder that returns None instead of panicking on division by zero and instead of wrapping around on underflow and overflow.
CheckedShl
Performs a left shift that returns None on shifts larger than or equal to the type width.
CheckedShr
Performs a right shift that returns None on shifts larger than or equal to the type width.
CheckedSub
Performs subtraction that returns None instead of wrapping around on underflow.
ConstOne
Defines an associated constant representing the multiplicative identity element for Self.
ConstZero
Defines an associated constant representing the additive identity element for Self.
ElementWise
Element-wise arithmetic operations. These are supplied for pragmatic reasons, but will usually fall outside of traditional algebraic properties.
Euclid
EuclideanSpace
Points in a Euclidean space with an associated space of displacement vectors.
FlakeMath
FlakeVector2Ext
Float
Generic trait for floating point numbers
FloatConst
FromBytes
FromPrimitive
A generic trait for converting a number to a value.
InnerSpace
Vectors that also have a dot (or inner) product.
Inv
Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.
Matrix
A column-major matrix of arbitrary dimensions.
MetricSpace
A type with a distance function between values.
MulAdd
Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.
MulAddAssign
The fused multiply-add assignment operation *self = (*self * a) + b
Neg
The unary negation operator -.
Num
The base trait for numeric types, covering 0 and 1 values, comparisons, basic numeric operations, and string conversion.
NumAssign
The trait for Num types which also implement assignment operators.
NumAssignOps
Generic trait for types implementing numeric assignment operators (like +=).
NumAssignRef
The trait for NumAssign types which also implement assignment operations taking the second operand by reference.
NumCast
An interface for casting between machine scalars.
NumOps
Generic trait for types implementing basic numeric operations
NumRef
The trait for Num types which also implement numeric operations taking the second operand by reference.
Number
One
Defines a multiplicative identity element for Self.
Pow
Binary operator for raising a value to a power.
PrimInt
Generic trait for primitive integers.
RefNum
The trait for Num references which implement numeric operations, taking the second operand either by value or by reference.
Rotation
A trait for a generic rotation. A rotation is a transformation that creates a circular motion, and preserves at least one point in the space.
Rotation2
A two-dimensional rotation.
Rotation3
A three-dimensional rotation.
Saturating
Saturating math operations. Deprecated, use SaturatingAdd, SaturatingSub and SaturatingMul instead.
SaturatingAdd
Performs addition that saturates at the numeric bounds instead of overflowing.
SaturatingMul
Performs multiplication that saturates at the numeric bounds instead of overflowing.
SaturatingSub
Performs subtraction that saturates at the numeric bounds instead of overflowing.
Signed
Useful functions for signed numbers (i.e. numbers that can be negative).
SquareMatrix
A column-major major matrix where the rows and column vectors are of the same dimensions.
ToBytes
ToPrimitive
A generic trait for converting a value to a number.
Transform
A trait representing an affine transformation that can be applied to points or vectors. An affine transformation is one which
Transform2
Transform3
Unsigned
A trait for values which cannot be negative
VectorSpace
Vectors that can be added together and multiplied by scalars.
WrappingAdd
Performs addition that wraps around on overflow.
WrappingMul
Performs multiplication that wraps around on overflow.
WrappingNeg
Performs a negation that does not panic.
WrappingShl
Performs a left shift that does not panic.
WrappingShr
Performs a right shift that does not panic.
WrappingSub
Performs subtraction that wraps around on overflow.
Zero
Defines an additive identity element for Self.

Functions§

abs
Computes the absolute value.
abs_sub
The positive difference of two numbers.
add_timer
Creates a Timer whose time goes down each frame. Can be paused. Check Timer docs for more info.
cast
Cast from one machine scalar to another.
checked_pow
Raises a value to the power of exp, returning None if an overflow occurred.
clamp
A value bounded by a minimum and a maximum
clamp_max
A value bounded by a maximum value
clamp_min
A value bounded by a minimum value
clear_background
Clears the background using a color.
create_empty_texture
Creates an empty texture of the given size. Fill it with update_texture.
draw_arrow
Draws a line from (x1, y1) to (x2, y2) with a triangular head at the end. The tip extends head_size past (x2, y2).
draw_circle
Draws a filled circle centered at (x, y) with radius r.
draw_circle_lines
Draws the outline of a circle centered at (x, y) with radius r.
draw_line
Draws a line segment from (x1, y1) to (x2, y2).
draw_poly_line
Draws connected line segments through points with mitered joins. If closed is true, the last point connects back to the first.
draw_poly_line_rounded
Draws connected line segments through points with rounded joints and caps. If closed is true, the last point connects back to the first.
draw_polygon
Draws a filled convex polygon from points as a triangle fan. Fewer than 3 points draws nothing. Use draw_polygon_concave for concave shapes.
draw_polygon_concave
Draws a filled polygon that may be concave, using ear clipping. Self-intersecting polygons may not render correctly.
draw_rectangle
Draws a filled rectangle with its top-left corner at (x, y).
draw_rectangle_from_rect
Draws a filled rectangle using a Rect.
draw_rectangle_lines
Draws the outline of a rectangle with its top-left corner at (x, y).
draw_rectangle_lines_from_rect
Draws the outline of a rectangle using a Rect.
draw_rectangle_lines_rotated
Draws the outline of a rectangle with its top-left corner at (x, y) (before rotation), rotated by rotation radians around its center.
draw_rectangle_lines_rounded
Draws the outline of a rounded rectangle with its top-left corner at (x, y). All corners have the same radius. The stroke is centered on the rectangle’s edge. Use draw_rectangle_lines_rounded_ex() to set each corner’s radius separately.
draw_rectangle_lines_rounded_ex
Draws the outline of a rounded rectangle with its top-left corner at (x, y), with the ability to set each corner’s radius separately. Radii are clamped to half the shorter side.
draw_rectangle_lines_rounded_from_rect
Draws rounded, outlines of a rectangle using a Rect where all corners have the same radius. Use draw_rectangle_lines_rounded_from_rect_ex() to set all radii separately.
draw_rectangle_lines_rounded_from_rect_ex
Draws rounded, outlines of a rectangle using a Rect where all corners have the same radius. Use draw_rectangle_lines_rounded_from_rect_ex() to set all radii separately.
draw_rectangle_lines_rounded_rotated
Draws the outline of a rounded rectangle centered at (x, y), rotated by rotation radians around that center. All corners have the same radius.
draw_rectangle_lines_rounded_rotated_ex
Draws the outline of a rounded rectangle centered at (x, y), rotated by rotation radians around that center. Can set each corner’s radius separately.
draw_rectangle_rotated
Draws a filled rectangle of size w x h centered at (x, y), rotated by rotation radians around that center.
draw_rectangle_rounded
Draws a rounded, filled rectangle with its top-left corner at (x, y). All corners have the same radius. Use draw_rectangle_rounded_ex() to set all the radii separately.
draw_rectangle_rounded_ex
Draws a rounded, filled rectangle with its top-left corner at (x, y) with the ability to set each corner’s radius manually.
draw_rectangle_rounded_from_rect
Draws a rounded, filled rectangle using a Rect where all corners have the same radius. Use draw_rectangle_rounded_from_rect_ex() to set all radii separately.
draw_rectangle_rounded_from_rect_ex
Draws a rounded, filled rectangle using a Rect, with the ability to set each corner’s radius separately.
draw_rectangle_rounded_rotated
Draws a rounded, filled rectangle centered at (x, y), rotated by rotation radians around that center. All corners have the same radius.
draw_rectangle_rounded_rotated_ex
draw_rich_text
Draws a collection of Spans in sequence where each Span can have different properties such as
draw_text
Draws text with its top-left corner at (x, y) with the given font, size, and color.
draw_texture
Draws a texture stretched to w x h with its top-left at (x, y). tint multiplies the texture color (use WHITE for none).
draw_texture_ex
Draws a texture with extra options from DrawTextureParams: destination size, source rect, horizontal/vertical flip, rotation (radians), pivot, and tint.
draw_triangle
Draws a filled triangle from three points.
draw_triangle_lines
Draws the outline of a triangle from three points.
flake_quit
Exits the running application, must be called while running.
flake_sleep
Sleeps (waits) for a set amount of seconds. (Will pause the window thread as well) App may become “not responding” if time is too high. Good for games like tetris/snake.
focus_window
Requests keyboard focus for the window.
get_axis
Returns -1.0 if only left is held, 1.0 if only right is held, otherwise 0.0.
get_fps
Gets the frames per second of the application. (Limited by target framerate & fps cap). Uncap the FPS using set_fps_capped(false).
get_frame_time
Gets the time taken since last frame in seconds.
get_frames
Gets the amount of frames that have gone by since the start of the application.
get_vector
Returns a direction from four keys. Up is -1.0 on Y (screen coordinates). The result is not normalized, so diagonals have length √2.
get_window
Gets the winit window used by the application
is_key_down
Checks if a key on the keyboard is being held.
is_key_pressed
Checks if a key on the keyboard was just clicked.
is_key_released
Checks if a key on the keyboard was just released.
is_mouse_button_down
Checks if a MouseButton is being held.
is_mouse_button_pressed
Checks if a MouseButton was just clicked this frame.
is_mouse_button_released
Checks if a MouseButton was just released this frame.
lerp
load_font_from_bytes
Loads a .ttf/.otf font from bytes and returns the Font object. (Do not load the font every frame, it will lag)
load_font_from_path
Loads a .ttf/.otf font from path and returns the Font object. (Do not load the font every frame, it will lag)
load_texture
Loads a texture from an image file using linear filtering. Panics if the file can’t be read or decoded.
load_texture_from_bytes
Loads a texture from encoded image bytes (e.g. include_bytes!) using linear filtering.
load_texture_from_bytes_with_filter_type
Loads a texture from raw RGBA f32 pixels. data.len() must equal width * height * 4, otherwise this panics.
load_texture_from_data
Loads a texture from raw RGBA f32 pixels. data.len() must equal width * height * 4, otherwise this panics.
load_texture_from_data_with_filter_type
Loads a texture from raw RGBA f32 pixels. data.len() must equal width * height * 4, otherwise this panics. (Use nearest for pixel art)
load_texture_from_image
Creates a texture from an Image.
load_texture_with_filter_type
Same as load_texture, with an explicit FilterType (e.g. nearest for pixel art).
measure_text
Returns the (width, height) of text when drawn with draw_text at this size.
mouse_position
Returns the window-relative mouse x and y position in a tuple.
mouse_position_vec2
Returns the window-relative mouse x and y position in a Vector2.
mouse_screen_position
Returns the mouse x and y position on the screen instead of window-relative.
mouse_screen_position_vec2
Returns the mouse x and y position on the screen instead of window-relative as Vector2.
mouse_wheel
Returns the mouse scroll direction this frame (line delta). (You might need to multiply this by something like 20).
next_frame
one
Returns the multiplicative identity, 1.
pow
Raises a value to the power of exp, using exponentiation by squaring.
quat
rect
render_target
Creates a new RenderTarget.
screen_height
screen_size
Returns the size of the monitor the window is on, or the window size if it can’t be determined.
screen_width
set_camera
Sets the currently active camera being used to draw on.
set_default_camera
Resets the camera to the default screen one.
set_fps_capped
Caps/unlocks the FPS of the application. (Capped by default)
set_mouse_icon
Set the mouse cursor icon.
set_skip_taskbar
Sets whether the app is shown or not shown (skipped) in the taskbar
set_target_fps
Sets target FPS of the application (Uses screen refresh rate by default).
set_window_decorations
Sets whether the window decorations (titlebar, border, etc.) are enabled
set_window_enabled_buttons
Sets which window buttons are enabled. Any button not included is disabled (e.g. WindowButtons::CLOSE leaves only the close button).
set_window_height
Sets height of the window.
set_window_icon
Sets the icon of the window.
set_window_icon_bytes
Sets the window icon from encoded image bytes (PNG, etc.). Panics if the bytes aren’t a valid image.
set_window_level
Sets whether the window is AlwaysOnTop, AlwaysOnBottom, or Normal
set_window_passthrough
Sets whether window catches mouse events.
set_window_position
Sets position of the window.
set_window_resizable
Sets whether the window can be resized using the resize handles.
set_window_size
Sets size of the window.
set_window_title
Sets the title of the window.
set_window_transparent
Sets whether the window is transparent. Run this before flake::run() as it might not work after the window has been created.
set_window_visible
Sets whether the window is visible or not.
set_window_width
Sets width of the window.
set_window_x
Sets position X of the window.
set_window_y
Sets position Y of the window.
signum
Returns the sign of the number.
span
timer
timer_repeating
update_texture
Replaces the pixels of an existing texture with those from image.
vec2
vec3
vec4
window_height
Gets height of the window
window_position
Gets position of the window
window_position_vec2
Gets position of the window as Vector2
window_size
Gets size of the window
window_width
Gets width of the window
window_x
Gets X position of the window
window_y
Gets Y position of the window
zero
Returns the additive identity, 0.

Type Aliases§

Quaternion
Vector2
Vector3
Vector4

Attribute Macros§

flake
Flake Main Function