Compare commits
16 Commits
b1177265ea
...
review
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6c8a062cd | ||
|
|
045624beac | ||
|
|
b0259c5788 | ||
|
|
0a47ea1e43 | ||
|
|
cc10d806fe | ||
|
|
e3a4506194 | ||
|
|
3348b2e91c | ||
|
|
9ca360c6b3 | ||
| 2e2c140d5b | |||
| 129206ce4f | |||
| 446cd80616 | |||
| 9a795c22f1 | |||
| 84c9a55ee5 | |||
| 4bb98f1f41 | |||
| d6d41388b3 | |||
| 4bf92356af |
@@ -8,8 +8,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "Zivro",
|
.name = "Zivro",
|
||||||
.use_llvm = true,
|
// .use_llvm = true,
|
||||||
.use_lld = true,
|
// .use_lld = true,
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|||||||
@@ -33,8 +33,8 @@
|
|||||||
// internet connectivity.
|
// internet connectivity.
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.dvui = .{
|
.dvui = .{
|
||||||
.url = "https://github.com/david-vanderson/dvui/archive/main.tar.gz",
|
.url = "git+https://github.com/david-vanderson/dvui#edb2d5a4cd2981fca74ee5f096277b91333c1316",
|
||||||
.hash = "dvui-0.4.0-dev-AQFJmev72QC6e0ojhnW8a_wRhZDgzWWLgeyoNuIPZc2m",
|
.hash = "dvui-0.4.0-dev-AQFJmeGB3QAwun9qF76CDE5IopA4nUVRgD-IwwTsOo4H",
|
||||||
},
|
},
|
||||||
|
|
||||||
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
|
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
|
||||||
|
|||||||
0
review.txt
Normal file
0
review.txt
Normal file
@@ -116,6 +116,7 @@ fn redraw(self: *Canvas) !void {
|
|||||||
}
|
}
|
||||||
self._last_redraw_time_ms = std.time.milliTimestamp();
|
self._last_redraw_time_ms = std.time.milliTimestamp();
|
||||||
self.frame_index += 1;
|
self.frame_index += 1;
|
||||||
|
self.redraw_throttle_ms = @max(1, @as(u32, @intCast(self.render_engine.getStats().render_time_ns / std.time.ns_per_ms / 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exampleReset(self: *Canvas) !void {
|
pub fn exampleReset(self: *Canvas) !void {
|
||||||
|
|||||||
@@ -16,15 +16,10 @@ pub const OpenDocument = struct {
|
|||||||
selected_object_id: ?u64 = null,
|
selected_object_id: ?u64 = null,
|
||||||
|
|
||||||
pub fn init(allocator: std.mem.Allocator, self: *OpenDocument) void {
|
pub fn init(allocator: std.mem.Allocator, self: *OpenDocument) void {
|
||||||
const default_size = basic_models.Size_f{ .w = 800, .h = 600 };
|
initWithDocument(allocator, self, .init(.{
|
||||||
self.document = Document.init(default_size);
|
.w = 800,
|
||||||
self.cpu_render = CpuRenderEngine.init(allocator, .Squares);
|
.h = 600,
|
||||||
self.canvas = Canvas.init(
|
}));
|
||||||
allocator,
|
|
||||||
&self.document,
|
|
||||||
(&self.cpu_render).renderEngine(),
|
|
||||||
);
|
|
||||||
self.selected_object_id = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initWithDocument(allocator: std.mem.Allocator, self: *OpenDocument, doc: Document) void {
|
pub fn initWithDocument(allocator: std.mem.Allocator, self: *OpenDocument, doc: Document) void {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
const dvui = @import("dvui");
|
const dvui = @import("dvui");
|
||||||
|
|
||||||
pub const line = dvui.entypo.line_graph;
|
pub const line = dvui.entypo.flow_line;
|
||||||
pub const ellipse = dvui.entypo.circle;
|
pub const ellipse = dvui.entypo.circle;
|
||||||
pub const arc = dvui.entypo.loop;
|
pub const broken = dvui.entypo.line_graph;
|
||||||
pub const broken = dvui.entypo.flow_line;
|
|
||||||
pub const trash = dvui.entypo.trash;
|
pub const trash = dvui.entypo.trash;
|
||||||
pub const cross = dvui.entypo.cross;
|
pub const cross = dvui.entypo.cross;
|
||||||
pub const plus = dvui.entypo.plus;
|
pub const plus = dvui.entypo.plus;
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ const WindowContext = @import("WindowContext.zig");
|
|||||||
const ui = @import("ui/frame.zig");
|
const ui = @import("ui/frame.zig");
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
// std.heap.GeneralPurposeAllocator was renamed to DebugAllocator recently.
|
||||||
|
var gpa: std.heap.DebugAllocator(.{}) = .init;
|
||||||
|
defer _ = gpa.deinit();
|
||||||
|
|
||||||
const allocator = gpa.allocator();
|
const allocator = gpa.allocator();
|
||||||
|
|
||||||
var backend = try SDLBackend.initWindow(.{
|
var backend = try SDLBackend.initWindow(.{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const Object = @This();
|
|||||||
pub const ShapeKind = enum {
|
pub const ShapeKind = enum {
|
||||||
line,
|
line,
|
||||||
ellipse,
|
ellipse,
|
||||||
arc,
|
|
||||||
broken,
|
broken,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,9 +33,9 @@ shape: ShapeKind,
|
|||||||
properties: std.ArrayList(Property),
|
properties: std.ArrayList(Property),
|
||||||
children: std.ArrayList(Object),
|
children: std.ArrayList(Object),
|
||||||
|
|
||||||
pub fn getProperty(self: Object, tag: std.meta.Tag(PropertyData)) ?*const PropertyData {
|
pub fn getProperty(self: Object, comptime tag: std.meta.Tag(PropertyData)) ?@FieldType(PropertyData, @tagName(tag)) {
|
||||||
for (self.properties.items) |*prop| {
|
for (self.properties.items) |*prop| {
|
||||||
if (std.meta.activeTag(prop.data) == tag) return &prop.data;
|
if (std.meta.activeTag(prop.data) == tag) return @field(prop.data, @tagName(tag));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -45,7 +44,7 @@ pub fn getProperty(self: Object, tag: std.meta.Tag(PropertyData)) ?*const Proper
|
|||||||
pub fn setProperty(self: *Object, allocator: std.mem.Allocator, prop: Property) !void {
|
pub fn setProperty(self: *Object, allocator: std.mem.Allocator, prop: Property) !void {
|
||||||
for (self.properties.items, 0..) |*p, i| {
|
for (self.properties.items, 0..) |*p, i| {
|
||||||
if (std.meta.activeTag(p.data) == std.meta.activeTag(prop.data)) {
|
if (std.meta.activeTag(p.data) == std.meta.activeTag(prop.data)) {
|
||||||
if (p.data == .points) p.data.points.deinit(allocator);
|
if (p.data == .points) allocator.free(p.data.points);
|
||||||
self.properties.items[i] = prop;
|
self.properties.items[i] = prop;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,12 @@ pub const Data = union(enum) {
|
|||||||
|
|
||||||
size: Size_f,
|
size: Size_f,
|
||||||
radii: Radii_f,
|
radii: Radii_f,
|
||||||
|
/// Процент дуги эллипса: 100 — полный эллипс, 50 — полуэллипс (0..100).
|
||||||
|
arc_percent: f32,
|
||||||
end_point: Point2_f,
|
end_point: Point2_f,
|
||||||
|
|
||||||
points: std.ArrayList(Point2_f),
|
/// Владеет памятью; при deinit/clone — free/duplicate.
|
||||||
|
points: []const Point2_f,
|
||||||
/// Замкнутый контур (для ломаной: отрезок последняя–первая точка + заливка).
|
/// Замкнутый контур (для ломаной: отрезок последняя–первая точка + заливка).
|
||||||
closed: bool,
|
closed: bool,
|
||||||
|
|
||||||
@@ -37,7 +40,7 @@ pub const Property = struct {
|
|||||||
|
|
||||||
pub fn deinit(self: *Property, allocator: std.mem.Allocator) void {
|
pub fn deinit(self: *Property, allocator: std.mem.Allocator) void {
|
||||||
switch (self.data) {
|
switch (self.data) {
|
||||||
.points => |*list| list.deinit(allocator),
|
.points => |slice| allocator.free(slice),
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
self.* = undefined;
|
self.* = undefined;
|
||||||
@@ -45,9 +48,12 @@ pub const Property = struct {
|
|||||||
|
|
||||||
pub fn clone(self: Property, allocator: std.mem.Allocator) !Property {
|
pub fn clone(self: Property, allocator: std.mem.Allocator) !Property {
|
||||||
return switch (self.data) {
|
return switch (self.data) {
|
||||||
.points => |list| .{
|
.points => |slice| .{
|
||||||
.data = .{
|
.data = .{
|
||||||
.points = try list.clone(allocator),
|
.points = blk: {
|
||||||
|
const copy = try allocator.dupe(Point2_f, slice);
|
||||||
|
break :blk copy;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
else => .{ .data = self.data },
|
else => .{ .data = self.data },
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
const Object = @import("../Object.zig");
|
|
||||||
const PropertyData = @import("../Property.zig").Data;
|
|
||||||
const Rect_f = @import("../basic_models.zig").Rect_f;
|
|
||||||
const shape_mod = @import("shape.zig");
|
|
||||||
|
|
||||||
/// Теги обязательных свойств (arc не реализован).
|
|
||||||
pub fn getRequiredTags() []const std.meta.Tag(PropertyData) {
|
|
||||||
return &[_]std.meta.Tag(PropertyData){};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Добавляет свойства по умолчанию для дуги.
|
|
||||||
pub fn appendDefaultShapeProperties(allocator: std.mem.Allocator, obj: *Object) !void {
|
|
||||||
_ = allocator;
|
|
||||||
_ = obj;
|
|
||||||
return error.ArcNotImplemented;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Локальные границы дуги (не реализовано).
|
|
||||||
pub fn getLocalBounds(obj: *const Object) !Rect_f {
|
|
||||||
try shape_mod.ensure(obj, .arc);
|
|
||||||
return error.ArcNotImplemented;
|
|
||||||
}
|
|
||||||
@@ -6,49 +6,15 @@ const Point2_f = @import("../basic_models.zig").Point2_f;
|
|||||||
const Rect_f = @import("../basic_models.zig").Rect_f;
|
const Rect_f = @import("../basic_models.zig").Rect_f;
|
||||||
const shape_mod = @import("shape.zig");
|
const shape_mod = @import("shape.zig");
|
||||||
|
|
||||||
/// Точки ломаной по умолчанию.
|
/// Свойства фигуры по умолчанию (добавляются к общим). points — слайс на статический массив.
|
||||||
pub const default_points = [_]Point2_f{
|
pub const default_shape_properties_points = [_]Point2_f{
|
||||||
.{ .x = 0, .y = 0 },
|
.{ .x = 0, .y = 0 },
|
||||||
.{ .x = 80, .y = 0 },
|
.{ .x = 80, .y = 0 },
|
||||||
.{ .x = 80, .y = 60 },
|
.{ .x = 80, .y = 60 },
|
||||||
};
|
};
|
||||||
|
pub const default_shape_properties = [_]Property{
|
||||||
/// Теги обязательных свойств.
|
.{ .data = .{ .points = &default_shape_properties_points } },
|
||||||
pub fn getRequiredTags() []const std.meta.Tag(PropertyData) {
|
.{ .data = .{ .closed = false } },
|
||||||
return &[_]std.meta.Tag(PropertyData){
|
.{ .data = .{ .filled = true } },
|
||||||
.points,
|
.{ .data = .{ .fill_rgba = 0x000000FF } },
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
/// Добавляет к объекту свойства по умолчанию для ломаной.
|
|
||||||
pub fn appendDefaultShapeProperties(allocator: std.mem.Allocator, obj: *Object) !void {
|
|
||||||
var points = std.ArrayList(Point2_f).empty;
|
|
||||||
try points.appendSlice(allocator, &default_points);
|
|
||||||
try obj.properties.append(allocator, .{ .data = .{ .points = points } });
|
|
||||||
try obj.properties.append(allocator, .{ .data = .{ .closed = false } });
|
|
||||||
try obj.properties.append(allocator, .{ .data = .{ .filled = true } });
|
|
||||||
try obj.properties.append(allocator, .{ .data = .{ .fill_rgba = obj.getProperty(.stroke_rgba).?.stroke_rgba } });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Локальные границы: AABB по точкам.
|
|
||||||
pub fn getLocalBounds(obj: *const Object) !Rect_f {
|
|
||||||
try shape_mod.ensure(obj, .broken);
|
|
||||||
const p = obj.getProperty(.points).?;
|
|
||||||
if (p.points.items.len == 0) return error.EmptyPoints;
|
|
||||||
var min_x: f32 = p.points.items[0].x;
|
|
||||||
var max_x: f32 = min_x;
|
|
||||||
var min_y: f32 = p.points.items[0].y;
|
|
||||||
var max_y: f32 = min_y;
|
|
||||||
for (p.points.items[1..]) |pt| {
|
|
||||||
min_x = @min(min_x, pt.x);
|
|
||||||
max_x = @max(max_x, pt.x);
|
|
||||||
min_y = @min(min_y, pt.y);
|
|
||||||
max_y = @max(max_y, pt.y);
|
|
||||||
}
|
|
||||||
return .{
|
|
||||||
.x = min_x,
|
|
||||||
.y = min_y,
|
|
||||||
.w = max_x - min_x,
|
|
||||||
.h = max_y - min_y,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +1,14 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Object = @import("../Object.zig");
|
const Object = @import("../Object.zig");
|
||||||
const Property = @import("../Property.zig").Property;
|
const Property = @import("../Property.zig").Property;
|
||||||
const PropertyData = @import("../Property.zig").Data;
|
|
||||||
const Rect_f = @import("../basic_models.zig").Rect_f;
|
const Rect_f = @import("../basic_models.zig").Rect_f;
|
||||||
const shape_mod = @import("shape.zig");
|
const shape_mod = @import("shape.zig");
|
||||||
|
|
||||||
/// Свойства фигуры по умолчанию.
|
/// Свойства фигуры по умолчанию (добавляются к общим).
|
||||||
pub const default_shape_properties = [_]Property{
|
pub const default_shape_properties = [_]Property{
|
||||||
.{ .data = .{ .radii = .{ .x = 50, .y = 50 } } },
|
.{ .data = .{ .radii = .{ .x = 50, .y = 50 } } },
|
||||||
|
.{ .data = .{ .arc_percent = 100.0 } },
|
||||||
|
.{ .data = .{ .closed = true } },
|
||||||
|
.{ .data = .{ .filled = false } },
|
||||||
|
.{ .data = .{ .fill_rgba = 0x000000FF } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Теги обязательных свойств.
|
|
||||||
pub fn getRequiredTags() []const std.meta.Tag(PropertyData) {
|
|
||||||
return &([_]std.meta.Tag(PropertyData){std.meta.activeTag(default_shape_properties[0].data)});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Добавляет к объекту свойства по умолчанию для эллипса.
|
|
||||||
pub fn appendDefaultShapeProperties(allocator: std.mem.Allocator, obj: *Object) !void {
|
|
||||||
for (default_shape_properties) |prop| try obj.properties.append(allocator, prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Локальные границы эллипса: [-radii.x, -radii.y] .. [radii.x, radii.y].
|
|
||||||
pub fn getLocalBounds(obj: *const Object) !Rect_f {
|
|
||||||
try shape_mod.ensure(obj, .ellipse);
|
|
||||||
const r = obj.getProperty(.radii).?;
|
|
||||||
return .{
|
|
||||||
.x = -r.radii.x,
|
|
||||||
.y = -r.radii.y,
|
|
||||||
.w = 2 * r.radii.x,
|
|
||||||
.h = 2 * r.radii.y,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,37 +1,10 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Object = @import("../Object.zig");
|
const Object = @import("../Object.zig");
|
||||||
const Property = @import("../Property.zig").Property;
|
const Property = @import("../Property.zig").Property;
|
||||||
const PropertyData = @import("../Property.zig").Data;
|
|
||||||
const Rect_f = @import("../basic_models.zig").Rect_f;
|
const Rect_f = @import("../basic_models.zig").Rect_f;
|
||||||
const shape_mod = @import("shape.zig");
|
const shape_mod = @import("shape.zig");
|
||||||
|
|
||||||
/// Свойства фигуры по умолчанию.
|
/// Свойства фигуры по умолчанию (добавляются к общим).
|
||||||
pub const default_shape_properties = [_]Property{
|
pub const default_shape_properties = [_]Property{
|
||||||
.{ .data = .{ .end_point = .{ .x = 100, .y = 200 } } },
|
.{ .data = .{ .end_point = .{ .x = 100, .y = 200 } } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Теги обязательных свойств.
|
|
||||||
pub fn getRequiredTags() []const std.meta.Tag(PropertyData) {
|
|
||||||
return &([_]std.meta.Tag(PropertyData){std.meta.activeTag(default_shape_properties[0].data)});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Добавляет к объекту свойства по умолчанию для линии.
|
|
||||||
pub fn appendDefaultShapeProperties(allocator: std.mem.Allocator, obj: *Object) !void {
|
|
||||||
for (default_shape_properties) |prop| try obj.properties.append(allocator, prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Локальные границы: от (0,0) до end_point.
|
|
||||||
pub fn getLocalBounds(obj: *const Object) !Rect_f {
|
|
||||||
try shape_mod.ensure(obj, .line);
|
|
||||||
const ep = obj.getProperty(.end_point).?;
|
|
||||||
const min_x = @min(0, ep.end_point.x);
|
|
||||||
const max_x = @max(0, ep.end_point.x);
|
|
||||||
const min_y = @min(0, ep.end_point.y);
|
|
||||||
const max_y = @max(0, ep.end_point.y);
|
|
||||||
return .{
|
|
||||||
.x = min_x,
|
|
||||||
.y = min_y,
|
|
||||||
.w = max_x - min_x,
|
|
||||||
.h = max_y - min_y,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,22 +4,36 @@ const Property = @import("../Property.zig").Property;
|
|||||||
const PropertyData = @import("../Property.zig").Data;
|
const PropertyData = @import("../Property.zig").Data;
|
||||||
const defaultCommonProperties = Object.defaultCommonProperties;
|
const defaultCommonProperties = Object.defaultCommonProperties;
|
||||||
const basic_models = @import("../basic_models.zig");
|
const basic_models = @import("../basic_models.zig");
|
||||||
|
const Point2_f = basic_models.Point2_f;
|
||||||
const line = @import("line.zig");
|
const line = @import("line.zig");
|
||||||
const ellipse = @import("ellipse.zig");
|
const ellipse = @import("ellipse.zig");
|
||||||
const broken = @import("broken.zig");
|
const broken = @import("broken.zig");
|
||||||
const arc = @import("arc.zig");
|
pub const Rect = basic_models.Rect_f;
|
||||||
|
|
||||||
pub const Rect = basic_models.Rectf;
|
/// Добавляет к объекту список свойств фигуры. Для .points дублирует слайс (объект владеет).
|
||||||
|
fn appendShapeProperties(allocator: std.mem.Allocator, obj: *Object, props: []const Property) !void {
|
||||||
|
for (props) |prop| {
|
||||||
|
if (prop.data == .points) {
|
||||||
|
const pts = prop.data.points;
|
||||||
|
const copy = try allocator.dupe(Point2_f, pts);
|
||||||
|
try obj.properties.append(allocator, .{ .data = .{ .points = copy } });
|
||||||
|
} else {
|
||||||
|
try obj.properties.append(allocator, prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Создаёт объект с дефолтными общими и фигурными свойствами.
|
/// Создаёт объект с дефолтными общими и фигурными свойствами.
|
||||||
pub fn createObject(allocator: std.mem.Allocator, shape_kind: Object.ShapeKind) !Object {
|
pub fn createObject(allocator: std.mem.Allocator, shape_kind: Object.ShapeKind) !Object {
|
||||||
var obj = try createWithCommonProperties(allocator, shape_kind);
|
var obj = try createWithCommonProperties(allocator, shape_kind);
|
||||||
errdefer obj.deinit(allocator);
|
errdefer obj.deinit(allocator);
|
||||||
switch (shape_kind) {
|
switch (shape_kind) {
|
||||||
.line => try line.appendDefaultShapeProperties(allocator, &obj),
|
.line => try appendShapeProperties(allocator, &obj, &line.default_shape_properties),
|
||||||
.ellipse => try ellipse.appendDefaultShapeProperties(allocator, &obj),
|
.ellipse => try appendShapeProperties(allocator, &obj, &ellipse.default_shape_properties),
|
||||||
.broken => try broken.appendDefaultShapeProperties(allocator, &obj),
|
.broken => {
|
||||||
.arc => try arc.appendDefaultShapeProperties(allocator, &obj),
|
try appendShapeProperties(allocator, &obj, &broken.default_shape_properties);
|
||||||
|
try obj.setProperty(allocator, .{ .data = .{ .fill_rgba = obj.getProperty(.stroke_rgba).? } });
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -35,62 +49,3 @@ fn createWithCommonProperties(allocator: std.mem.Allocator, shape_kind: Object.S
|
|||||||
.children = std.ArrayList(Object).empty,
|
.children = std.ArrayList(Object).empty,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Проверяет тип объекта и наличие обязательных свойств.
|
|
||||||
pub fn ensure(obj: *const Object, expected_kind: Object.ShapeKind) !void {
|
|
||||||
if (obj.shape != expected_kind) return error.WrongShapeKind;
|
|
||||||
const tags = requiredTagsFor(expected_kind);
|
|
||||||
for (tags) |tag| {
|
|
||||||
if (obj.getProperty(tag) == null) return error.MissingRequiredProperty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requiredTagsFor(kind: Object.ShapeKind) []const std.meta.Tag(PropertyData) {
|
|
||||||
return switch (kind) {
|
|
||||||
.line => line.getRequiredTags(),
|
|
||||||
.ellipse => ellipse.getRequiredTags(),
|
|
||||||
.broken => broken.getRequiredTags(),
|
|
||||||
.arc => arc.getRequiredTags(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Локальные границы (AABB).
|
|
||||||
pub fn getLocalBounds(obj: *const Object) !Rect {
|
|
||||||
return switch (obj.shape) {
|
|
||||||
.line => line.getLocalBounds(obj),
|
|
||||||
.ellipse => ellipse.getLocalBounds(obj),
|
|
||||||
.broken => broken.getLocalBounds(obj),
|
|
||||||
.arc => arc.getLocalBounds(obj),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
test "getLocalBounds" {
|
|
||||||
const shape = @This();
|
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
||||||
defer _ = gpa.deinit();
|
|
||||||
const allocator = gpa.allocator();
|
|
||||||
|
|
||||||
var line_obj = try shape.createObject(allocator, .line);
|
|
||||||
defer line_obj.deinit(allocator);
|
|
||||||
const line_bounds = try getLocalBounds(&line_obj);
|
|
||||||
try std.testing.expect(line_bounds.x == 0);
|
|
||||||
try std.testing.expect(line_bounds.y == 0);
|
|
||||||
try std.testing.expect(line_bounds.w == 100);
|
|
||||||
try std.testing.expect(line_bounds.h == 0);
|
|
||||||
|
|
||||||
var ellipse_obj = try shape.createObject(allocator, .ellipse);
|
|
||||||
defer ellipse_obj.deinit(allocator);
|
|
||||||
const ellipse_bounds = try getLocalBounds(&ellipse_obj);
|
|
||||||
try std.testing.expect(ellipse_bounds.x == -50);
|
|
||||||
try std.testing.expect(ellipse_bounds.y == -50);
|
|
||||||
try std.testing.expect(ellipse_bounds.w == 100);
|
|
||||||
try std.testing.expect(ellipse_bounds.h == 100);
|
|
||||||
|
|
||||||
var broken_obj = try shape.createObject(allocator, .broken);
|
|
||||||
defer broken_obj.deinit(allocator);
|
|
||||||
const broken_bounds = try getLocalBounds(&broken_obj);
|
|
||||||
try std.testing.expect(broken_bounds.x == 0);
|
|
||||||
try std.testing.expect(broken_bounds.y == 0);
|
|
||||||
try std.testing.expect(broken_bounds.w == 80);
|
|
||||||
try std.testing.expect(broken_bounds.h == 60);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -74,18 +74,20 @@ fn randomizeObjectProperties(allocator: std.mem.Allocator, doc_size: *const Size
|
|||||||
} });
|
} });
|
||||||
},
|
},
|
||||||
.broken => {
|
.broken => {
|
||||||
var points = std.ArrayList(Point2_f).empty;
|
var list = std.ArrayList(Point2_f).empty;
|
||||||
|
defer list.deinit(allocator);
|
||||||
const n = rng.intRangeLessThan(usize, 2, 9);
|
const n = rng.intRangeLessThan(usize, 2, 9);
|
||||||
var x: f32 = 0;
|
var x: f32 = 0;
|
||||||
var y: f32 = 0;
|
var y: f32 = 0;
|
||||||
for (0..n) |_| {
|
for (0..n) |_| {
|
||||||
try points.append(allocator, .{ .x = x, .y = y });
|
try list.append(allocator, .{ .x = x, .y = y });
|
||||||
x += randFloat(rng, -40, 80);
|
x += randFloat(rng, -40, 80);
|
||||||
y += randFloat(rng, -30, 60);
|
y += randFloat(rng, -30, 60);
|
||||||
}
|
}
|
||||||
try obj.setProperty(allocator, .{ .data = .{ .points = points } });
|
const slice = try allocator.dupe(Point2_f, list.items);
|
||||||
|
errdefer allocator.free(slice);
|
||||||
|
try obj.setProperty(allocator, .{ .data = .{ .points = slice } });
|
||||||
},
|
},
|
||||||
.arc => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +100,7 @@ pub fn addRandomShapes(doc: *Document, allocator: std.mem.Allocator, rng: std.Ra
|
|||||||
for (0..n_root) |_| {
|
for (0..n_root) |_| {
|
||||||
if (total_count >= max_total) break;
|
if (total_count >= max_total) break;
|
||||||
var obj = try shape.createObject(allocator, randomShapeKind(rng));
|
var obj = try shape.createObject(allocator, randomShapeKind(rng));
|
||||||
|
defer obj.deinit(allocator);
|
||||||
try randomizeObjectProperties(allocator, &doc.size, &obj, rng);
|
try randomizeObjectProperties(allocator, &doc.size, &obj, rng);
|
||||||
try doc.addObject(allocator, obj);
|
try doc.addObject(allocator, obj);
|
||||||
total_count += 1;
|
total_count += 1;
|
||||||
@@ -115,6 +118,7 @@ pub fn addRandomShapes(doc: *Document, allocator: std.mem.Allocator, rng: std.Ra
|
|||||||
for (0..n_children) |_| {
|
for (0..n_children) |_| {
|
||||||
if (total_count >= max_total) break;
|
if (total_count >= max_total) break;
|
||||||
var child = try shape.createObject(allocator, randomShapeKind(rng));
|
var child = try shape.createObject(allocator, randomShapeKind(rng));
|
||||||
|
defer child.deinit(allocator);
|
||||||
try randomizeObjectProperties(allocator, &doc.size, &child, rng);
|
try randomizeObjectProperties(allocator, &doc.size, &child, rng);
|
||||||
try obj.addChild(allocator, child, &doc.next_object_id);
|
try obj.addChild(allocator, child, &doc.next_object_id);
|
||||||
total_count += 1;
|
total_count += 1;
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ fn renderGradient(self: CpuRenderEngine, pixels: []Color.PMA, width: u32, height
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn renderSquares(self: CpuRenderEngine, pixels: []Color.PMA, canvas_size: Size_i, visible_rect: Rect_i) void {
|
fn renderSquares(pixels: []Color.PMA, canvas_size: Size_i, visible_rect: Rect_i) void {
|
||||||
_ = self;
|
|
||||||
|
|
||||||
const colors = [_]Color.PMA{
|
const colors = [_]Color.PMA{
|
||||||
.{ .r = 255, .g = 0, .b = 0, .a = 255 },
|
.{ .r = 255, .g = 0, .b = 0, .a = 255 },
|
||||||
.{ .r = 255, .g = 165, .b = 0, .a = 255 },
|
.{ .r = 255, .g = 165, .b = 0, .a = 255 },
|
||||||
@@ -169,10 +167,10 @@ pub fn example(self: CpuRenderEngine, canvas_size: Size_i, visible_rect: Rect_i)
|
|||||||
|
|
||||||
switch (self.type) {
|
switch (self.type) {
|
||||||
.Gradient => self.renderGradient(pixels, width, height, full_w, full_h, visible_rect),
|
.Gradient => self.renderGradient(pixels, width, height, full_w, full_h, visible_rect),
|
||||||
.Squares => self.renderSquares(pixels, canvas_size, visible_rect),
|
.Squares => renderSquares(pixels, canvas_size, visible_rect),
|
||||||
}
|
}
|
||||||
|
|
||||||
return try dvui.textureCreate(pixels, width, height, .nearest);
|
return try dvui.textureCreate(pixels, width, height, .nearest, .rgba_8_8_8_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn renderEngine(self: *CpuRenderEngine) RenderEngine {
|
pub fn renderEngine(self: *CpuRenderEngine) RenderEngine {
|
||||||
@@ -191,7 +189,7 @@ pub fn renderDocument(self: *CpuRenderEngine, document: *const Document, canvas_
|
|||||||
try cpu_draw.drawDocument(pixels, width, height, visible_rect, document, canvas_size, self._allocator);
|
try cpu_draw.drawDocument(pixels, width, height, visible_rect, document, canvas_size, self._allocator);
|
||||||
self._renderStats.render_time_ns = t.read();
|
self._renderStats.render_time_ns = t.read();
|
||||||
|
|
||||||
return try dvui.textureCreate(pixels, width, height, .nearest);
|
return try dvui.textureCreate(pixels, width, height, .nearest, .rgba_8_8_8_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getStats(self: CpuRenderEngine) RenderStats {
|
pub fn getStats(self: CpuRenderEngine) RenderStats {
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
const Document = @import("../../models/Document.zig");
|
|
||||||
const pipeline = @import("pipeline.zig");
|
|
||||||
const DrawContext = pipeline.DrawContext;
|
|
||||||
|
|
||||||
const Object = Document.Object;
|
|
||||||
|
|
||||||
/// Дуга (не реализовано).
|
|
||||||
pub fn draw(_: *DrawContext, _: *const Object) void {}
|
|
||||||
@@ -16,14 +16,13 @@ pub fn draw(
|
|||||||
obj: *const Object,
|
obj: *const Object,
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
) !void {
|
) !void {
|
||||||
const p_prop = obj.getProperty(.points) orelse return;
|
const pts = obj.getProperty(.points) orelse return;
|
||||||
const pts = p_prop.points.items;
|
|
||||||
if (pts.len < 2) return;
|
if (pts.len < 2) return;
|
||||||
const stroke = if (obj.getProperty(.stroke_rgba)) |s| pipeline.rgbaToPma(s.stroke_rgba) else default_stroke;
|
const stroke = if (obj.getProperty(.stroke_rgba)) |stroke_rgba| pipeline.rgbaToPma(stroke_rgba) else default_stroke;
|
||||||
const thickness = if (obj.getProperty(.thickness)) |t| t.thickness else default_thickness;
|
const thickness = obj.getProperty(.thickness) orelse default_thickness;
|
||||||
const closed = if (obj.getProperty(.closed)) |c| c.closed else false;
|
const closed = obj.getProperty(.closed) orelse false;
|
||||||
const filled = if (obj.getProperty(.filled)) |f| f.filled else true;
|
const filled = obj.getProperty(.filled) orelse true;
|
||||||
const fill_color = if (obj.getProperty(.fill_rgba)) |f| pipeline.rgbaToPma(f.fill_rgba) else default_fill;
|
const fill_color = if (obj.getProperty(.fill_rgba)) |fill_rgba| pipeline.rgbaToPma(fill_rgba) else default_fill;
|
||||||
|
|
||||||
const buffer = try allocator.alloc(Color.PMA, ctx.buf_width * ctx.buf_height);
|
const buffer = try allocator.alloc(Color.PMA, ctx.buf_width * ctx.buf_height);
|
||||||
@memset(buffer, .{ .r = 0, .g = 0, .b = 0, .a = 0 });
|
@memset(buffer, .{ .r = 0, .g = 0, .b = 0, .a = 0 });
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ const pipeline = @import("pipeline.zig");
|
|||||||
const line = @import("line.zig");
|
const line = @import("line.zig");
|
||||||
const ellipse = @import("ellipse.zig");
|
const ellipse = @import("ellipse.zig");
|
||||||
const broken = @import("broken.zig");
|
const broken = @import("broken.zig");
|
||||||
const arc = @import("arc.zig");
|
|
||||||
const basic_models = @import("../../models/basic_models.zig");
|
const basic_models = @import("../../models/basic_models.zig");
|
||||||
const Rect_i = basic_models.Rect_i;
|
const Rect_i = basic_models.Rect_i;
|
||||||
const Size_i = basic_models.Size_i;
|
const Size_i = basic_models.Size_i;
|
||||||
@@ -14,7 +13,7 @@ const DrawContext = pipeline.DrawContext;
|
|||||||
const Transform = pipeline.Transform;
|
const Transform = pipeline.Transform;
|
||||||
|
|
||||||
fn isVisible(obj: *const Object) bool {
|
fn isVisible(obj: *const Object) bool {
|
||||||
return if (obj.getProperty(.visible)) |p| p.visible else true;
|
return obj.getProperty(.visible) orelse true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drawObject(
|
fn drawObject(
|
||||||
@@ -30,9 +29,8 @@ fn drawObject(
|
|||||||
|
|
||||||
switch (obj.shape) {
|
switch (obj.shape) {
|
||||||
.line => line.draw(ctx, obj),
|
.line => line.draw(ctx, obj),
|
||||||
.ellipse => ellipse.draw(ctx, obj),
|
.ellipse => try ellipse.draw(ctx, obj, allocator),
|
||||||
.broken => try broken.draw(ctx, obj, allocator),
|
.broken => try broken.draw(ctx, obj, allocator),
|
||||||
.arc => arc.draw(ctx, obj),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (obj.children.items) |*child| {
|
for (obj.children.items) |*child| {
|
||||||
|
|||||||
@@ -1,23 +1,36 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const std_math = std.math;
|
||||||
const Document = @import("../../models/Document.zig");
|
const Document = @import("../../models/Document.zig");
|
||||||
const pipeline = @import("pipeline.zig");
|
const pipeline = @import("pipeline.zig");
|
||||||
|
const line = @import("line.zig");
|
||||||
const DrawContext = pipeline.DrawContext;
|
const DrawContext = pipeline.DrawContext;
|
||||||
const Color = @import("dvui").Color;
|
const Color = @import("dvui").Color;
|
||||||
|
const basic_models = @import("../../models/basic_models.zig");
|
||||||
|
const Point2_f = basic_models.Point2_f;
|
||||||
|
|
||||||
const Object = Document.Object;
|
const Object = Document.Object;
|
||||||
const default_stroke: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 255 };
|
const default_stroke: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 255 };
|
||||||
|
const default_fill: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 0 };
|
||||||
const default_thickness: f32 = 2.0;
|
const default_thickness: f32 = 2.0;
|
||||||
|
|
||||||
/// Эллипс с центром (0,0) и полуосями radii (обводка с учётом thickness).
|
/// Эллипс с центром (0,0) и полуосями radii. Обводка — полоса расстояния до контура (чёткая линия, не круги).
|
||||||
pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
/// arc_percent: 100 — полный эллипс, иначе одна дуга; обход в коде от (0,ry) по квадрантам (визуально может казаться от низа против часовой из‑за экранной Y).
|
||||||
const r_prop = obj.getProperty(.radii) orelse return;
|
/// Отрисовка в отдельный буфер и один composite, чтобы при alpha<255 пиксели не накладывались несколько раз.
|
||||||
const rx = r_prop.radii.x;
|
pub fn draw(ctx: *DrawContext, obj: *const Object, allocator: std.mem.Allocator) !void {
|
||||||
const ry = r_prop.radii.y;
|
const radii = obj.getProperty(.radii) orelse return;
|
||||||
|
const rx = radii.x;
|
||||||
|
const ry = radii.y;
|
||||||
if (rx <= 0 or ry <= 0) return;
|
if (rx <= 0 or ry <= 0) return;
|
||||||
const stroke = if (obj.getProperty(.stroke_rgba)) |s| pipeline.rgbaToPma(s.stroke_rgba) else default_stroke;
|
|
||||||
const thickness = if (obj.getProperty(.thickness)) |t| t.thickness else default_thickness;
|
|
||||||
|
|
||||||
// Полуширина обводки в нормализованных единицах (d = (x/rx)² + (y/ry)², граница при d=1).
|
const stroke = if (obj.getProperty(.stroke_rgba)) |stroke_rgba| pipeline.rgbaToPma(stroke_rgba) else default_stroke;
|
||||||
|
const thickness = if (obj.getProperty(.thickness)) |thickness| thickness else default_thickness;
|
||||||
|
const arc_percent = std_math.clamp(if (obj.getProperty(.arc_percent)) |arc_percent| arc_percent else 100.0, 0.0, 100.0);
|
||||||
|
const closed = obj.getProperty(.closed) orelse true;
|
||||||
|
const filled = obj.getProperty(.filled) orelse false;
|
||||||
|
const fill_color = if (obj.getProperty(.fill_rgba)) |fill_rgba| pipeline.rgbaToPma(fill_rgba) else default_fill;
|
||||||
|
const do_fill = filled and (closed or arc_percent >= 100.0);
|
||||||
|
|
||||||
|
const t = &ctx.transform;
|
||||||
const min_r = @min(rx, ry);
|
const min_r = @min(rx, ry);
|
||||||
const half_norm = thickness / (2.0 * min_r);
|
const half_norm = thickness / (2.0 * min_r);
|
||||||
const inner = @max(0.0, 1.0 - half_norm);
|
const inner = @max(0.0, 1.0 - half_norm);
|
||||||
@@ -25,19 +38,18 @@ pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
|||||||
const d_inner_sq = inner * inner;
|
const d_inner_sq = inner * inner;
|
||||||
const d_outer_sq = outer * outer;
|
const d_outer_sq = outer * outer;
|
||||||
|
|
||||||
const corners = [_]struct { x: f32, y: f32 }{
|
const margin = 1.0 + half_norm;
|
||||||
.{ .x = -rx, .y = -ry },
|
const corners = [_]Point2_f{
|
||||||
.{ .x = rx, .y = -ry },
|
.{ .x = -rx * margin, .y = -ry * margin },
|
||||||
.{ .x = rx, .y = ry },
|
.{ .x = rx * margin, .y = -ry * margin },
|
||||||
.{ .x = -rx, .y = ry },
|
.{ .x = rx * margin, .y = ry * margin },
|
||||||
|
.{ .x = -rx * margin, .y = ry * margin },
|
||||||
};
|
};
|
||||||
const w0 = ctx.localToWorld(corners[0].x, corners[0].y);
|
var min_bx: f32 = std_math.inf(f32);
|
||||||
const b0 = ctx.worldToBufferF(w0.x, w0.y);
|
var min_by: f32 = std_math.inf(f32);
|
||||||
var min_bx: f32 = b0.x;
|
var max_bx: f32 = -std_math.inf(f32);
|
||||||
var min_by: f32 = b0.y;
|
var max_by: f32 = -std_math.inf(f32);
|
||||||
var max_bx: f32 = b0.x;
|
for (corners) |c| {
|
||||||
var max_by: f32 = b0.y;
|
|
||||||
for (corners[1..]) |c| {
|
|
||||||
const w = ctx.localToWorld(c.x, c.y);
|
const w = ctx.localToWorld(c.x, c.y);
|
||||||
const b = ctx.worldToBufferF(w.x, w.y);
|
const b = ctx.worldToBufferF(w.x, w.y);
|
||||||
min_bx = @min(min_bx, b.x);
|
min_bx = @min(min_bx, b.x);
|
||||||
@@ -47,50 +59,58 @@ pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
|||||||
}
|
}
|
||||||
const buf_w: i32 = @intCast(ctx.buf_width);
|
const buf_w: i32 = @intCast(ctx.buf_width);
|
||||||
const buf_h: i32 = @intCast(ctx.buf_height);
|
const buf_h: i32 = @intCast(ctx.buf_height);
|
||||||
const x0: i32 = @max(0, @as(i32, @intFromFloat(std.math.floor(min_bx))));
|
const x0: i32 = @max(0, @as(i32, @intFromFloat(std_math.floor(min_bx))));
|
||||||
const y0: i32 = @max(0, @as(i32, @intFromFloat(std.math.floor(min_by))));
|
const y0: i32 = @max(0, @as(i32, @intFromFloat(std_math.floor(min_by))));
|
||||||
const x1: i32 = @min(buf_w, @as(i32, @intFromFloat(std.math.ceil(max_bx))) + 1);
|
const x1: i32 = @min(buf_w, @as(i32, @intFromFloat(std_math.ceil(max_bx))) + 1);
|
||||||
const y1: i32 = @min(buf_h, @as(i32, @intFromFloat(std.math.ceil(max_by))) + 1);
|
const y1: i32 = @min(buf_h, @as(i32, @intFromFloat(std_math.ceil(max_by))) + 1);
|
||||||
|
|
||||||
|
const buffer = try allocator.alloc(Color.PMA, ctx.buf_width * ctx.buf_height);
|
||||||
|
@memset(buffer, .{ .r = 0, .g = 0, .b = 0, .a = 0 });
|
||||||
|
defer allocator.free(buffer);
|
||||||
|
|
||||||
|
var stroke_ctx = ctx.*;
|
||||||
|
stroke_ctx.pixels = buffer;
|
||||||
|
stroke_ctx.replace_mode = true;
|
||||||
|
|
||||||
|
if (do_fill) {
|
||||||
|
stroke_ctx.startFill(allocator) catch return;
|
||||||
|
}
|
||||||
|
|
||||||
// Один раз считаем аффин buffer -> local, чтобы в цикле не вызывать cos/sin и лишние функции.
|
|
||||||
const t = &ctx.transform;
|
|
||||||
const ctx_sx = if (ctx.scale_x != 0) ctx.scale_x else 1.0;
|
|
||||||
const ctx_sy = if (ctx.scale_y != 0) ctx.scale_y else 1.0;
|
|
||||||
const inv_ctx_sx = 1.0 / ctx_sx;
|
|
||||||
const inv_ctx_sy = 1.0 / ctx_sy;
|
|
||||||
const vx = @as(f32, @floatFromInt(ctx.visible_rect.x));
|
|
||||||
const vy = @as(f32, @floatFromInt(ctx.visible_rect.y));
|
|
||||||
const t_sx = if (t.scale.scale_x != 0) t.scale.scale_x else 1.0;
|
|
||||||
const t_sy = if (t.scale.scale_y != 0) t.scale.scale_y else 1.0;
|
|
||||||
const ca = std.math.cos(-t.angle);
|
|
||||||
const sa = std.math.sin(-t.angle);
|
|
||||||
const dx_off = vx * inv_ctx_sx - t.position.x;
|
|
||||||
const dy_off = vy * inv_ctx_sy - t.position.y;
|
|
||||||
const loc_x_off = (dx_off * ca - dy_off * sa) / t_sx;
|
|
||||||
const loc_y_off = (dx_off * sa + dy_off * ca) / t_sy;
|
|
||||||
const m00 = inv_ctx_sx * ca / t_sx;
|
|
||||||
const m01 = -inv_ctx_sy * sa / t_sx;
|
|
||||||
const m10 = inv_ctx_sx * sa / t_sy;
|
|
||||||
const m11 = inv_ctx_sy * ca / t_sy;
|
|
||||||
const inv_rx = 1.0 / rx;
|
const inv_rx = 1.0 / rx;
|
||||||
const inv_ry = 1.0 / ry;
|
const inv_ry = 1.0 / ry;
|
||||||
|
const arc_len = 2.0 * std_math.pi * arc_percent / 100.0;
|
||||||
|
|
||||||
var by: i32 = y0;
|
var by: i32 = y0;
|
||||||
while (by < y1) : (by += 1) {
|
while (by < y1) : (by += 1) {
|
||||||
const buf_y = @as(f32, @floatFromInt(by)) + 0.5;
|
const buf_y = @as(f32, @floatFromInt(by)) + 0.5;
|
||||||
const row_loc_x_off = buf_y * m01 + loc_x_off;
|
|
||||||
const row_loc_y_off = buf_y * m11 + loc_y_off;
|
|
||||||
var bx: i32 = x0;
|
var bx: i32 = x0;
|
||||||
while (bx < x1) : (bx += 1) {
|
while (bx < x1) : (bx += 1) {
|
||||||
const buf_x = @as(f32, @floatFromInt(bx)) + 0.5;
|
const buf_x = @as(f32, @floatFromInt(bx)) + 0.5;
|
||||||
const loc_x = buf_x * m00 + row_loc_x_off;
|
const w = stroke_ctx.bufferToWorld(buf_x, buf_y);
|
||||||
const loc_y = buf_x * m10 + row_loc_y_off;
|
const loc = stroke_ctx.worldToLocal(w.x, w.y);
|
||||||
const nx = loc_x * inv_rx;
|
const nx = loc.x * inv_rx;
|
||||||
const ny = loc_y * inv_ry;
|
const ny = loc.y * inv_ry;
|
||||||
const d = nx * nx + ny * ny;
|
const d = nx * nx + ny * ny;
|
||||||
if (d >= d_inner_sq and d <= d_outer_sq) {
|
if (d < d_inner_sq or d > d_outer_sq) continue;
|
||||||
ctx.blendPixelAtBuffer(bx, by, stroke);
|
if (arc_percent < 100.0) {
|
||||||
|
var diff = std_math.pi / 2.0 - std_math.atan2(ny, nx);
|
||||||
|
if (diff < 0) diff += 2.0 * std_math.pi;
|
||||||
|
if (diff > arc_len) continue;
|
||||||
}
|
}
|
||||||
|
stroke_ctx.blendPixelAtBuffer(bx, by, stroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (closed and arc_percent < 100.0) {
|
||||||
|
const end_x = rx * std_math.sin(arc_len);
|
||||||
|
const end_y = ry * std_math.cos(arc_len);
|
||||||
|
line.drawLine(&stroke_ctx, 0, 0, 0, ry, stroke, thickness, false);
|
||||||
|
line.drawLine(&stroke_ctx, 0, 0, end_x, end_y, stroke, thickness, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_fill) {
|
||||||
|
stroke_ctx.stopFill(allocator, fill_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.compositeDrawerContext(&stroke_ctx, t.opacity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ const default_thickness: f32 = 2.0;
|
|||||||
|
|
||||||
/// Линия от (0,0) до end_point.
|
/// Линия от (0,0) до end_point.
|
||||||
pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
||||||
const ep_prop = obj.getProperty(.end_point) orelse return;
|
const end_point = obj.getProperty(.end_point) orelse return;
|
||||||
const end_x = ep_prop.end_point.x;
|
const end_x = end_point.x;
|
||||||
const end_y = ep_prop.end_point.y;
|
const end_y = end_point.y;
|
||||||
const stroke = if (obj.getProperty(.stroke_rgba)) |s| pipeline.rgbaToPma(s.stroke_rgba) else default_stroke;
|
const stroke = if (obj.getProperty(.stroke_rgba)) |stroke_rgba| pipeline.rgbaToPma(stroke_rgba) else default_stroke;
|
||||||
const thickness = if (obj.getProperty(.thickness)) |t| t.thickness else default_thickness;
|
const thickness = obj.getProperty(.thickness) orelse default_thickness;
|
||||||
drawLine(ctx, 0, 0, end_x, end_y, stroke, thickness, false);
|
drawLine(ctx, 0, 0, end_x, end_y, stroke, thickness, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ pub const Transform = struct {
|
|||||||
opacity: f32 = 1.0,
|
opacity: f32 = 1.0,
|
||||||
|
|
||||||
pub fn init(obj: *const Document.Object) Transform {
|
pub fn init(obj: *const Document.Object) Transform {
|
||||||
const pos = if (obj.getProperty(.position)) |p| p.position else Point2_f{ .x = 0, .y = 0 };
|
const pos = obj.getProperty(.position) orelse Point2_f{ .x = 0, .y = 0 };
|
||||||
const angle = if (obj.getProperty(.angle)) |p| p.angle else 0;
|
const angle = obj.getProperty(.angle) orelse 0;
|
||||||
const scale = if (obj.getProperty(.scale)) |p| p.scale else Scale2_f{ .scale_x = 1, .scale_y = 1 };
|
const scale = obj.getProperty(.scale) orelse Scale2_f{ .scale_x = 1, .scale_y = 1 };
|
||||||
const opacity = if (obj.getProperty(.opacity)) |p| p.opacity else 1.0;
|
const opacity = obj.getProperty(.opacity) orelse 1.0;
|
||||||
return .{
|
return .{
|
||||||
.position = pos,
|
.position = pos,
|
||||||
.angle = angle,
|
.angle = angle,
|
||||||
@@ -273,7 +273,7 @@ const FillCanvas = struct {
|
|||||||
}.lessThan);
|
}.lessThan);
|
||||||
|
|
||||||
// Семена: по строкам находим сегменты (пары x), пересекаем с окном буфера, берём середину сегмента.
|
// Семена: по строкам находим сегменты (пары x), пересекаем с окном буфера, берём середину сегмента.
|
||||||
var seeds = findFillSeeds(self, keys_buf.items, buf_w_i, buf_h_i, allocator) catch return;
|
var seeds = findFillSeeds(keys_buf.items, buf_w_i, buf_h_i, allocator) catch return;
|
||||||
defer seeds.deinit(allocator);
|
defer seeds.deinit(allocator);
|
||||||
|
|
||||||
var stack = std.ArrayList(Point2_i).empty;
|
var stack = std.ArrayList(Point2_i).empty;
|
||||||
@@ -304,13 +304,11 @@ const FillCanvas = struct {
|
|||||||
|
|
||||||
/// По строкам: рёбра (подряд идущие x) → сегменты между ними. Семена — середины чётных сегментов (при чётном числе границ).
|
/// По строкам: рёбра (подряд идущие x) → сегменты между ними. Семена — середины чётных сегментов (при чётном числе границ).
|
||||||
fn findFillSeeds(
|
fn findFillSeeds(
|
||||||
self: *const FillCanvas,
|
|
||||||
keys: []const Point2_i,
|
keys: []const Point2_i,
|
||||||
buf_w_i: i32,
|
buf_w_i: i32,
|
||||||
buf_h_i: i32,
|
buf_h_i: i32,
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
) !std.ArrayList(Point2_i) {
|
) !std.ArrayList(Point2_i) {
|
||||||
_ = self;
|
|
||||||
var list = std.ArrayList(Point2_i).empty;
|
var list = std.ArrayList(Point2_i).empty;
|
||||||
errdefer list.deinit(allocator);
|
errdefer list.deinit(allocator);
|
||||||
var segments = std.ArrayList(struct { left: i32, right: i32 }).empty;
|
var segments = std.ArrayList(struct { left: i32, right: i32 }).empty;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Toolbar = @import("Toolbar.zig");
|
const Toolbar = @import("Toolbar.zig");
|
||||||
const line = @import("tools/line.zig");
|
const line = @import("tools/line.zig");
|
||||||
const ellipse = @import("tools/ellipse.zig");
|
const ellipse = @import("tools/ellipse.zig");
|
||||||
const arc = @import("tools/arc.zig");
|
|
||||||
const broken = @import("tools/broken.zig");
|
const broken = @import("tools/broken.zig");
|
||||||
const icons = @import("../icons.zig");
|
const icons = @import("../icons.zig");
|
||||||
|
|
||||||
@@ -16,11 +15,6 @@ pub const default_tools = [_]Toolbar.ToolDescriptor{
|
|||||||
.icon_tvg = icons.ellipse,
|
.icon_tvg = icons.ellipse,
|
||||||
.implementation = &ellipse.tool,
|
.implementation = &ellipse.tool,
|
||||||
},
|
},
|
||||||
.{
|
|
||||||
.name = "Arc",
|
|
||||||
.icon_tvg = icons.arc,
|
|
||||||
.implementation = &arc.tool,
|
|
||||||
},
|
|
||||||
.{
|
.{
|
||||||
.name = "Broken line",
|
.name = "Broken line",
|
||||||
.icon_tvg = icons.broken,
|
.icon_tvg = icons.broken,
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
const Tool = @import("../Tool.zig");
|
|
||||||
const shape = @import("../../models/shape/shape.zig");
|
|
||||||
|
|
||||||
fn onCanvasClick(ctx: *const Tool.ToolContext) !void {
|
|
||||||
const canvas = ctx.canvas;
|
|
||||||
var obj = shape.createObject(canvas.allocator, .arc) catch return;
|
|
||||||
defer obj.deinit(canvas.allocator);
|
|
||||||
try ctx.addObject(obj);
|
|
||||||
}
|
|
||||||
pub const tool = Tool.Tool{ .onCanvasClick = onCanvasClick };
|
|
||||||
@@ -6,6 +6,7 @@ const Document = @import("../models/Document.zig");
|
|||||||
const Property = @import("../models/Property.zig").Property;
|
const Property = @import("../models/Property.zig").Property;
|
||||||
const PropertyData = @import("../models/Property.zig").Data;
|
const PropertyData = @import("../models/Property.zig").Data;
|
||||||
const Rect_i = @import("../models/basic_models.zig").Rect_i;
|
const Rect_i = @import("../models/basic_models.zig").Rect_i;
|
||||||
|
const Point2_f = @import("../models/basic_models.zig").Point2_f;
|
||||||
const Tool = @import("../toolbar/Tool.zig");
|
const Tool = @import("../toolbar/Tool.zig");
|
||||||
const RenderStats = @import("../render/RenderStats.zig");
|
const RenderStats = @import("../render/RenderStats.zig");
|
||||||
const icons = @import("../icons.zig");
|
const icons = @import("../icons.zig");
|
||||||
@@ -16,14 +17,15 @@ pub fn canvasView(canvas: *Canvas, selected_object_id: ?u64, content_rect_scale:
|
|||||||
var overlay = dvui.overlay(@src(), .{ .expand = .both });
|
var overlay = dvui.overlay(@src(), .{ .expand = .both });
|
||||||
{
|
{
|
||||||
const overlay_parent = dvui.parentGet();
|
const overlay_parent = dvui.parentGet();
|
||||||
|
const init_options: dvui.ScrollAreaWidget.InitOpts = .{
|
||||||
|
.scroll_info = &canvas.scroll,
|
||||||
|
.vertical_bar = .auto,
|
||||||
|
.horizontal_bar = .auto,
|
||||||
|
.process_events_after = false,
|
||||||
|
};
|
||||||
var scroll = dvui.scrollArea(
|
var scroll = dvui.scrollArea(
|
||||||
@src(),
|
@src(),
|
||||||
.{
|
init_options,
|
||||||
.scroll_info = &canvas.scroll,
|
|
||||||
.vertical_bar = .auto,
|
|
||||||
.horizontal_bar = .auto,
|
|
||||||
.process_events_after = false,
|
|
||||||
},
|
|
||||||
.{
|
.{
|
||||||
.expand = .both,
|
.expand = .both,
|
||||||
.background = false,
|
.background = false,
|
||||||
@@ -99,7 +101,7 @@ pub fn canvasView(canvas: *Canvas, selected_object_id: ?u64, content_rect_scale:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scroll.init_opts.process_events_after) {
|
if (!init_options.process_events_after) {
|
||||||
if (scroll.scroll) |*sc| {
|
if (scroll.scroll) |*sc| {
|
||||||
dvui.clipSet(sc.prevClip);
|
dvui.clipSet(sc.prevClip);
|
||||||
sc.processEventsAfter();
|
sc.processEventsAfter();
|
||||||
@@ -379,6 +381,11 @@ fn drawStatsPanel(stats: RenderStats, frame_index: u64) void {
|
|||||||
panel.deinit();
|
panel.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn applyPropertyPatch(canvas: *Canvas, obj: *Document.Object, patch: Property) void {
|
||||||
|
obj.setProperty(canvas.allocator, patch) catch {};
|
||||||
|
canvas.requestRedraw();
|
||||||
|
}
|
||||||
|
|
||||||
fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Property, row_index: usize) void {
|
fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Property, row_index: usize) void {
|
||||||
const row_id: usize = row_index * 16;
|
const row_id: usize = row_index * 16;
|
||||||
const is_even = row_index % 2 == 0;
|
const is_even = row_index % 2 == 0;
|
||||||
@@ -420,8 +427,7 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
changed = res.changed or changed;
|
changed = res.changed or changed;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .position = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .position = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.angle => |angle| {
|
.angle => |angle| {
|
||||||
@@ -434,8 +440,7 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
subrow.deinit();
|
subrow.deinit();
|
||||||
if (res.changed) {
|
if (res.changed) {
|
||||||
next = degrees * std.math.pi / 180.0;
|
next = degrees * std.math.pi / 180.0;
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .angle = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .angle = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -459,29 +464,25 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
changed = res.changed or changed;
|
changed = res.changed or changed;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .scale = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .scale = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.visible => |v| {
|
.visible => |v| {
|
||||||
var next = v;
|
var next = v;
|
||||||
if (dvui.checkbox(@src(), &next, "Visible", .{})) {
|
if (dvui.checkbox(@src(), &next, "Visible", .{})) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .visible = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .visible = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.opacity => |opacity| {
|
.opacity => |opacity| {
|
||||||
var next = opacity;
|
var next = opacity;
|
||||||
if (dvui.sliderEntry(@src(), "{d:0.2}", .{ .value = &next, .min = 0.0, .max = 1.0, .interval = 0.01 }, .{ .expand = .horizontal })) {
|
if (dvui.sliderEntry(@src(), "{d:0.2}", .{ .value = &next, .min = 0.0, .max = 1.0, .interval = 0.01 }, .{ .expand = .horizontal })) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .opacity = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .opacity = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.locked => |v| {
|
.locked => |v| {
|
||||||
var next = v;
|
var next = v;
|
||||||
if (dvui.checkbox(@src(), &next, "Locked", .{})) {
|
if (dvui.checkbox(@src(), &next, "Locked", .{})) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .locked = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .locked = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.size => |size| {
|
.size => |size| {
|
||||||
@@ -504,8 +505,7 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
changed = res.changed or changed;
|
changed = res.changed or changed;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .size = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .size = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.radii => |radii| {
|
.radii => |radii| {
|
||||||
@@ -528,8 +528,13 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
changed = res.changed or changed;
|
changed = res.changed or changed;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .radii = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .radii = next } });
|
||||||
canvas.requestRedraw();
|
}
|
||||||
|
},
|
||||||
|
.arc_percent => |pct| {
|
||||||
|
var next = pct;
|
||||||
|
if (dvui.sliderEntry(@src(), "{d:0.0}%", .{ .value = &next, .min = 0.0, .max = 100.0, .interval = 1.0 }, .{ .expand = .horizontal })) {
|
||||||
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .arc_percent = next } });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.end_point => |pt| {
|
.end_point => |pt| {
|
||||||
@@ -552,15 +557,16 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
changed = res.changed or changed;
|
changed = res.changed or changed;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .end_point = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .end_point = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.points => |points| {
|
.points => |points| {
|
||||||
var list = points.clone(canvas.allocator) catch {
|
var list = std.ArrayList(Point2_f).empty;
|
||||||
dvui.label(@src(), "Points: {d}", .{points.items.len}, .{});
|
list.appendSlice(canvas.allocator, points) catch {
|
||||||
|
dvui.label(@src(), "Points: {d}", .{points.len}, .{});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
defer list.deinit(canvas.allocator);
|
||||||
dvui.label(@src(), "Points: {d}", .{list.items.len}, .{});
|
dvui.label(@src(), "Points: {d}", .{list.items.len}, .{});
|
||||||
|
|
||||||
var changed = false;
|
var changed = false;
|
||||||
@@ -670,13 +676,12 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .points = list } }) catch {
|
const slice = canvas.allocator.dupe(Point2_f, list.items) catch return;
|
||||||
list.deinit(canvas.allocator);
|
obj.setProperty(canvas.allocator, .{ .data = .{ .points = slice } }) catch {
|
||||||
|
canvas.allocator.free(slice);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
canvas.requestRedraw();
|
canvas.requestRedraw();
|
||||||
} else {
|
|
||||||
list.deinit(canvas.allocator);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.fill_rgba => |rgba| {
|
.fill_rgba => |rgba| {
|
||||||
@@ -694,23 +699,20 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope
|
|||||||
const res = dvui.textEntryNumber(@src(), T, .{ .value = &next, .min = @as(T, 0.0), .max = @as(T, 100.0) }, .{ .expand = .horizontal });
|
const res = dvui.textEntryNumber(@src(), T, .{ .value = &next, .min = @as(T, 0.0), .max = @as(T, 100.0) }, .{ .expand = .horizontal });
|
||||||
subrow.deinit();
|
subrow.deinit();
|
||||||
if (res.changed) {
|
if (res.changed) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .thickness = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .thickness = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.closed => |v| {
|
.closed => |v| {
|
||||||
var next = v;
|
var next = v;
|
||||||
if (dvui.checkbox(@src(), &next, "Closed", .{})) {
|
if (dvui.checkbox(@src(), &next, "Closed", .{})) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .closed = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .closed = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.filled => |v| {
|
.filled => |v| {
|
||||||
var next = v;
|
var next = v;
|
||||||
if (dvui.checkbox(@src(), &next, "Filled", .{})) {
|
if (dvui.checkbox(@src(), &next, "Filled", .{})) {
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .filled = next } }) catch {};
|
applyPropertyPatch(canvas, obj, .{ .data = .{ .filled = next } });
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -726,12 +728,11 @@ fn drawColorEditor(canvas: *Canvas, obj: *Document.Object, rgba: u32, is_fill: b
|
|||||||
.{ .expand = .horizontal },
|
.{ .expand = .horizontal },
|
||||||
)) {
|
)) {
|
||||||
const next = colorToRgba(hsv.toColor());
|
const next = colorToRgba(hsv.toColor());
|
||||||
if (is_fill) {
|
const patch: Property = if (is_fill)
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .fill_rgba = next } }) catch {};
|
.{ .data = .{ .fill_rgba = next } }
|
||||||
} else {
|
else
|
||||||
obj.setProperty(canvas.allocator, .{ .data = .{ .stroke_rgba = next } }) catch {};
|
.{ .data = .{ .stroke_rgba = next } };
|
||||||
}
|
applyPropertyPatch(canvas, obj, patch);
|
||||||
canvas.requestRedraw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,6 +746,7 @@ fn propertyLabel(tag: std.meta.Tag(PropertyData)) []const u8 {
|
|||||||
.locked => "Locked",
|
.locked => "Locked",
|
||||||
.size => "Size",
|
.size => "Size",
|
||||||
.radii => "Radii",
|
.radii => "Radii",
|
||||||
|
.arc_percent => "Arc %",
|
||||||
.end_point => "End point",
|
.end_point => "End point",
|
||||||
.points => "Points",
|
.points => "Points",
|
||||||
.fill_rgba => "Fill color",
|
.fill_rgba => "Fill color",
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ fn shapeLabel(shape: Object.ShapeKind) []const u8 {
|
|||||||
return switch (shape) {
|
return switch (shape) {
|
||||||
.line => "Line",
|
.line => "Line",
|
||||||
.ellipse => "Ellipse",
|
.ellipse => "Ellipse",
|
||||||
.arc => "Arc",
|
|
||||||
.broken => "Broken line",
|
.broken => "Broken line",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -223,11 +222,13 @@ pub fn leftPanel(ctx: *WindowContext) void {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
dvui.label(@src(), "Objects", .{}, .{ .font = .{
|
dvui.label(@src(), "Objects", .{}, .{
|
||||||
.id = dvui.themeGet().font_heading.id,
|
.font = .{
|
||||||
.line_height_factor = dvui.themeGet().font_heading.line_height_factor,
|
.line_height_factor = dvui.themeGet().font_heading.line_height_factor,
|
||||||
.size = dvui.themeGet().font_heading.size + 8,
|
.size = dvui.themeGet().font_heading.size + 8,
|
||||||
}, .gravity_x = 0.5 });
|
},
|
||||||
|
.gravity_x = 0.5,
|
||||||
|
});
|
||||||
var scroll = dvui.scrollArea(
|
var scroll = dvui.scrollArea(
|
||||||
@src(),
|
@src(),
|
||||||
.{ .vertical = .auto, .horizontal = .auto },
|
.{ .vertical = .auto, .horizontal = .auto },
|
||||||
|
|||||||
Reference in New Issue
Block a user