Определение позиции дочернего объекта

This commit is contained in:
2026-02-26 21:33:09 +03:00
parent 77604e7b2b
commit 2ab6bcd408
8 changed files with 84 additions and 50 deletions

View File

@@ -13,19 +13,6 @@ const Object = Document.Object;
const DrawContext = pipeline.DrawContext;
const Transform = pipeline.Transform;
fn getLocalTransform(obj: *const Object) Transform {
const pos = if (obj.getProperty(.position)) |p| p.position else basic_models.Point2_f{ .x = 0, .y = 0 };
const angle = if (obj.getProperty(.angle)) |p| p.angle else 0;
const scale = if (obj.getProperty(.scale)) |p| p.scale else basic_models.Scale2_f{ .scale_x = 1, .scale_y = 1 };
const opacity = if (obj.getProperty(.opacity)) |p| p.opacity else 1.0;
return .{
.position = pos,
.angle = angle,
.scale = scale,
.opacity = opacity,
};
}
fn isVisible(obj: *const Object) bool {
return if (obj.getProperty(.visible)) |p| p.visible else true;
}
@@ -37,7 +24,7 @@ fn drawObject(
allocator: std.mem.Allocator,
) !void {
if (!isVisible(obj)) return;
const local = getLocalTransform(obj);
const local = Transform.init(obj);
const world = Transform.compose(parent_transform, local);
ctx.setTransform(world);