Прикольные цвета для сетки
This commit is contained in:
@@ -17,7 +17,7 @@ scroll: dvui.ScrollInfo = .{
|
||||
.vertical = .auto,
|
||||
.horizontal = .auto,
|
||||
},
|
||||
native_scaling: bool = false,
|
||||
native_scaling: bool = true,
|
||||
gradient_start: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 255 },
|
||||
gradient_end: Color.PMA = .{ .r = 255, .g = 255, .b = 255, .a = 255 },
|
||||
document: ?*Document = null,
|
||||
|
||||
@@ -63,6 +63,15 @@ fn renderGradient(self: CpuRenderEngine, pixels: []Color.PMA, width: u32, height
|
||||
fn renderSquares(self: CpuRenderEngine, pixels: []Color.PMA, canvas_size: ImageSize, visible_rect: ImageRect) void {
|
||||
_ = self;
|
||||
|
||||
const colors = [_]Color.PMA{
|
||||
.{ .r = 255, .g = 0, .b = 0, .a = 255 }, // red
|
||||
.{ .r = 255, .g = 165, .b = 0, .a = 255 }, // orange
|
||||
.{ .r = 255, .g = 255, .b = 0, .a = 255 }, // yellow
|
||||
.{ .r = 0, .g = 255, .b = 0, .a = 255 }, // green
|
||||
.{ .r = 0, .g = 255, .b = 255, .a = 255 }, // cyan
|
||||
.{ .r = 0, .g = 0, .b = 255, .a = 255 }, // blue
|
||||
};
|
||||
|
||||
const squares_num = 5;
|
||||
var thikness: u32 = @intFromFloat(@as(f32, @floatFromInt(canvas_size.w + canvas_size.h)) / 2 * 0.03);
|
||||
if (thikness == 0) thikness = 1;
|
||||
@@ -97,26 +106,28 @@ fn renderSquares(self: CpuRenderEngine, pixels: []Color.PMA, canvas_size: ImageS
|
||||
const canvas_x = x + visible_rect.x;
|
||||
if (canvas_x >= canvas_size.w) continue;
|
||||
|
||||
// Check if in vertical line
|
||||
var in_vertical_line = false;
|
||||
for (x_pos) |pos| {
|
||||
if (canvas_x >= pos and canvas_x < pos + thikness) {
|
||||
in_vertical_line = true;
|
||||
// Check vertical line index
|
||||
var vertical_index: ?u32 = null;
|
||||
for (0..x_pos.len) |i| {
|
||||
if (canvas_x >= x_pos[i] and canvas_x < x_pos[i] + thikness) {
|
||||
vertical_index = @intCast(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if in horizontal line
|
||||
var in_horizontal_line = false;
|
||||
for (y_pos) |pos| {
|
||||
if (canvas_y >= pos and canvas_y < pos + thikness) {
|
||||
in_horizontal_line = true;
|
||||
// Check horizontal line index
|
||||
var horizontal_index: ?u32 = null;
|
||||
for (0..y_pos.len) |i| {
|
||||
if (canvas_y >= y_pos[i] and canvas_y < y_pos[i] + thikness) {
|
||||
horizontal_index = @intCast(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_vertical_line or in_horizontal_line) {
|
||||
pixels[y * visible_rect.w + x] = .{ .r = 255, .g = 0, .b = 0, .a = 255 };
|
||||
if (vertical_index) |idx| {
|
||||
pixels[y * visible_rect.w + x] = colors[idx];
|
||||
} else if (horizontal_index) |idx| {
|
||||
pixels[y * visible_rect.w + x] = colors[idx];
|
||||
} else {
|
||||
// Find square
|
||||
var square_x: u32 = 0;
|
||||
|
||||
Reference in New Issue
Block a user