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
| Module | Contents |
|---|---|
[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 |
consts | Asset paths, cache magic, version constants |
network | PeerId, 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§
Modules§
Macros§
- log_
color - Print colored output using an
ANSIconstant. - 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§
- Clip
Dist - Near/far clip plane distances for a camera.
- Coord2D
- A 2D point in continuous space.
- Coord
Offset - A 2D vector/displacement.
- Gradient
- A configurable color gradient evaluator.
- Gradient
Stop - A single control point in a gradient.
- HSL
- HSL color.
- HSV
- HSV color.
- Optic
Error - 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§
- ATTR
Type - Vertex attribute data type.
- CamProj
- Camera projection mode.
- Cull
- Face culling direction.
- Draw
Mode - Primitive topology for draw calls.
- Gradient
Color Space - Color space used for interpolation between stops.
- Gradient
Interp - Interpolation mode between gradient stops.
- Gradient
Wrap - 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.
- Optic
Error Kind - Broad category of an error.
- Poly
Mode - 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§
- Channel
Array - Trait for types whose channels can be accessed as a fixed-size float array.
- Color
Info - Trait for computing luminance, contrast, and hex/byte serialization.
- Components
- Trait for types whose components can be accessed as a fixed-size array.
- From
Rgba - 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§
- Optic
Result - Convenience alias for
Result<T, OpticError>.