Дополнительный буфер для отрисовки broken line
This commit is contained in:
@@ -30,7 +30,12 @@ fn isVisible(obj: *const Object) bool {
|
||||
return if (obj.getProperty(.visible)) |p| p.visible else true;
|
||||
}
|
||||
|
||||
fn drawObject(ctx: *DrawContext, obj: *const Object, parent_transform: Transform) void {
|
||||
fn drawObject(
|
||||
ctx: *DrawContext,
|
||||
obj: *const Object,
|
||||
parent_transform: Transform,
|
||||
allocator: std.mem.Allocator,
|
||||
) !void {
|
||||
if (!isVisible(obj)) return;
|
||||
const local = getLocalTransform(obj);
|
||||
const world = Transform.compose(parent_transform, local);
|
||||
@@ -39,16 +44,17 @@ fn drawObject(ctx: *DrawContext, obj: *const Object, parent_transform: Transform
|
||||
switch (obj.shape) {
|
||||
.line => line.draw(ctx, obj),
|
||||
.ellipse => ellipse.draw(ctx, obj),
|
||||
.broken => broken.draw(ctx, obj),
|
||||
.broken => try broken.draw(ctx, obj, allocator),
|
||||
.arc => arc.draw(ctx, obj),
|
||||
}
|
||||
|
||||
for (obj.children.items) |*child| {
|
||||
drawObject(ctx, child, world);
|
||||
try drawObject(ctx, child, world, allocator);
|
||||
}
|
||||
}
|
||||
|
||||
/// Рекурсивно рисует документ в буфер (объекты и потомки по порядку).
|
||||
/// allocator опционален; если передан, ломаные рисуются через слой (без двойного наложения при alpha < 1).
|
||||
pub fn drawDocument(
|
||||
pixels: []@import("dvui").Color.PMA,
|
||||
buf_width: u32,
|
||||
@@ -56,7 +62,8 @@ pub fn drawDocument(
|
||||
visible_rect: Rect_i,
|
||||
document: *const Document,
|
||||
canvas_size: Size_i,
|
||||
) void {
|
||||
allocator: std.mem.Allocator,
|
||||
) !void {
|
||||
const scale_x: f32 = if (document.size.w > 0) @as(f32, @floatFromInt(canvas_size.w)) / document.size.w else 0;
|
||||
const scale_y: f32 = if (document.size.h > 0) @as(f32, @floatFromInt(canvas_size.h)) / document.size.h else 0;
|
||||
|
||||
@@ -70,6 +77,6 @@ pub fn drawDocument(
|
||||
};
|
||||
const identity = Transform{};
|
||||
for (document.objects.items) |*obj| {
|
||||
drawObject(&ctx, obj, identity);
|
||||
try drawObject(&ctx, obj, identity, allocator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user