Первая растеризация
This commit is contained in:
22
src/render/cpu/broken.zig
Normal file
22
src/render/cpu/broken.zig
Normal file
@@ -0,0 +1,22 @@
|
||||
const std = @import("std");
|
||||
const Document = @import("../../models/Document.zig");
|
||||
const pipeline = @import("pipeline.zig");
|
||||
const line = @import("line.zig");
|
||||
const DrawContext = pipeline.DrawContext;
|
||||
const Color = @import("dvui").Color;
|
||||
|
||||
const Object = Document.Object;
|
||||
const default_stroke: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 255 };
|
||||
|
||||
/// Рисует ломаную по точкам в локальных координатах. Обводка по stroke_rgba.
|
||||
pub fn draw(ctx: *DrawContext, obj: *const Object) void {
|
||||
const p_prop = obj.getProperty(.points) orelse return;
|
||||
const pts = p_prop.points.items;
|
||||
if (pts.len < 2) return;
|
||||
const stroke = if (obj.getProperty(.stroke_rgba)) |s| pipeline.rgbaToPma(s.stroke_rgba) else default_stroke;
|
||||
|
||||
var i: usize = 0;
|
||||
while (i + 1 < pts.len) : (i += 1) {
|
||||
line.drawLine(ctx, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y, stroke);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user