tiny.zen.diagram.space
Defined in diagram.
API (5)
Actions
Public operations.
Source
Source: lib/zen/src/diagram/root.zig:10
zig
pub const space = @import("space.zig");Source: lib/zen/src/diagram/space.zig
zig
const category = @import("category.zig");const domain = @import("domain.zig");const model = @import("model.zig");const root = @import("root.zig");const spec = root.spec;const Bounds = model.Bounds;pub fn xCoordinate(value: spec.XValue, bounds: Bounds, left: f64, right: f64) !f64 { if (bounds.categorical) { var buffer: [category.label_buffer_bytes]u8 = undefined; const label_value = category.label(&buffer, value); return category.coordinate(label_value, bounds, left, right); } return xNumberCoordinate(value.number, bounds, left, right);}pub fn xNumberCoordinate(value: f64, bounds: Bounds, left: f64, right: f64) !f64 { return left + try domain.ratio(value, bounds.x_min, bounds.x_max, bounds.x_kind, bounds.x_base) * (right - left);}pub fn yCoordinate(value: f64, bounds: Bounds, bottom: f64, top: f64) !f64 { return bottom - try domain.ratio(value, bounds.y_min, bounds.y_max, bounds.y_kind, bounds.y_base) * (bottom - top);}pub fn xDistance(value: f64, bounds: Bounds, left: f64, right: f64) f64 { return value / (bounds.x_max - bounds.x_min) * (right - left);}pub fn yDistance(value: f64, bounds: Bounds, bottom: f64, top: f64) f64 { return value / (bounds.y_max - bounds.y_min) * (bottom - top);}Audit
| Definitions | 6 |
|---|---|
| Public names | 6 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |