Skip to main content

Crate optic_core

Crate optic_core 

Source
Expand description

Shared types, geometry, errors, constants, and logging for the Optic engine.

This crate is the foundation of the engine. Every other crate depends on it. It re-exports optic_color and cgmath, so downstream crates get math and color types through a single dependency.

§Organization

ModuleContents
[geometry]Size2D, Size3D, ClipDist, CamProj, Components trait
[coord]Coord2D (point), CoordOffset (vector/displacement)
[enums]PolyMode, Cull, DrawMode, ImgFormat, ImgFilter, ImgWrap, ATTRType
[error]OpticError, OpticErrorKind, OpticResult
ansi[ANSI] color codes for terminal output
constsAsset paths, cache magic, version constants
networkPeerId, NetworkMode, NetworkConfig, NetworkEvents
[proc]end, end_success, end_error process helpers

§Logging macros

The crate provides color-coded logging via macro:

use optic_core::*;

log_info!("hello world");
log_warn!("value is {}", 42);
log_error!("something broke");
log_color!("custom format", RED, "arg {}", 1);

Re-exports§

pub use cgmath;
pub use network::*;

Modules§

ansi
consts
Constants for asset paths, cache magic, shader/mesh metadata.
network

Macros§

log_color
Print colored output using an ANSI constant.
log_error
Print a bold-red [ERROR] message.
log_event
Print a bold-blue [EVENT] message.
log_fatal
Print a bold-red [FATAL] message, then abort the process.
log_info
Print a bold-green [INFO] message.
log_warn
Print a bold-yellow [WARN] message.

Structs§

ClipDist
Near/far clip plane distances for a camera.
Coord2D
A 2D point in continuous space.
CoordOffset
A 2D vector/displacement.
Gradient
A configurable color gradient evaluator.
GradientStop
A single control point in a gradient.
HSL
HSL color.
HSV
HSV color.
OpticError
The primary error type for the Optic engine.
RGB
RGB color with three 0..1 float channels.
RGBA
RGBA color with four 0..1 float channels.
Size2D
A 2D size with non-negative integer dimensions.
Size3D
A 3D size with non-negative integer dimensions.

Enums§

ATTRType
Vertex attribute data type.
CamProj
Camera projection mode.
Cull
Face culling direction.
DrawMode
Primitive topology for draw calls.
GradientColorSpace
Color space used for interpolation between stops.
GradientInterp
Interpolation mode between gradient stops.
GradientWrap
Wrap mode for positions outside 0..1.
ImgFilter
Texture filter (minification/magnification) mode.
ImgFormat
Texture image format, encoding channel count and bit depth.
ImgWrap
Texture wrap (addressing) mode.
OpticErrorKind
Broad category of an error.
PolyMode
Polygon rasterization mode.

Constants§

ALABASTER
AMBER
APRICOT
AQUA
BEIGE
BLACK
BLUE
BLUSH
BRONZE
BROWN
BURGUNDY
CELADON
CHARCOAL
COBALT
COPPER
CORAL
CRIMSON
CYAN
DUSK
ERROR
Error exit code (1).
FERN
FOREST
GOLD
GRAY
GREEN
INDIGO
IVORY
KHAKI
LAPIS
LAVENDER
LIME
MAGENTA
MAHOGANY
MANGO
MAROON
MIDNIGHT
MINT
MULBERRY
MUSTARD
NAVY
OBSIDIAN
OLIVE
ORANGE
PEACH
PINK
PLUM
PURPLE
RED
ROSEWOOD
SALMON
SAND
SCARLET
SEA
SILVER
SKY
SLATE
SNOW
SPRING
SUCCESS
Success exit code (0).
TANGERINE
TEAL
TURQUOISE
VIOLET
WHITE
WISTERIA
YELLOW

Traits§

ChannelArray
Trait for types whose channels can be accessed as a fixed-size float array.
ColorInfo
Trait for computing luminance, contrast, and hex/byte serialization.
Components
Trait for types whose components can be accessed as a fixed-size array.
FromRgba
Trait for types that can be constructed from RGBA.
ToRgba
Trait for types that can be converted to RGBA losslessly.

Functions§

channel_add
Channel-wise addition of two colors.
channel_div_scalar
Divide all channels by a scalar.
channel_lerp
Linearly interpolate between two colors channel by channel.
channel_mul
Channel-wise multiplication of two colors.
channel_mul_scalar
Multiply all channels by a scalar.
channel_sub
Channel-wise subtraction of two colors.
componentwise_max
Componentwise maximum of two values.
componentwise_min
Componentwise minimum of two values.
end
Terminate the process with the given exit code.
end_error
Print a fatal error message and exit with code 1.
end_success
Print a success message and exit with code 0.

Type Aliases§

OpticResult
Convenience alias for Result<T, OpticError>.