module: write components using a struct pattern

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-05 05:35:58 -07:00 committed by Stephen Gutekanst
parent 17db5498ee
commit 2115f5832a
8 changed files with 45 additions and 62 deletions

View file

@ -28,52 +28,52 @@ pub const Mod = mach.Mod(@This());
// TODO: allow user to specify projection matrix (3d-space flat text etc.)
pub const components = .{
.{ .name = .pipeline, .type = u8, .description =
.pipeline = .{ .type = u8, .description =
\\ The ID of the pipeline this text belongs to. By default, zero.
\\
\\ This determines which shader, textures, etc. are used for rendering the text.
},
.{ .name = .transform, .type = Mat4x4, .description =
.transform = .{ .type = Mat4x4, .description =
\\ The text model transformation matrix. Text is measured in pixel units, starting from
\\ (0, 0) at the top-left corner and extending to the size of the text. By default, the world
\\ origin (0, 0) lives at the center of the window.
},
.{ .name = .text, .type = []const []const u8, .description =
.text = .{ .type = []const []const u8, .description =
\\ String segments of UTF-8 encoded text to render.
\\
\\ Expected to match the length of the style component.
},
.{ .name = .style, .type = []const mach.ecs.EntityID, .description =
.style = .{ .type = []const mach.ecs.EntityID, .description =
\\ The style to apply to each segment of text.
\\
\\ Expected to match the length of the text component.
},
// TODO: ship a default font
.{ .name = .font_name, .type = []const u8, .description =
.font_name = .{ .type = []const u8, .description =
\\ Style component: desired font to render text with.
},
// e.g. 12 * mach.gfx.px_per_pt // 12pt
.{ .name = .font_size, .type = f32, .description =
.font_size = .{ .type = f32, .description =
\\ Style component: font size in pixels
},
// e.g. mach.gfx.font_weight_normal
.{ .name = .font_weight, .type = u16, .description =
.font_weight = .{ .type = u16, .description =
\\ Style component: font weight
},
// e.g. false
.{ .name = .italic, .type = bool, .description =
.italic = .{ .type = bool, .description =
\\ Style component: italic text
},
// e.g. vec4(0, 0, 0, 1.0)
.{ .name = .color, .type = Vec4, .description =
.color = .{ .type = Vec4, .description =
\\ Style component: fill color
},
};