Определение позиции дочернего объекта
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user