Skip to content

Commit 2429919

Browse files
committed
File: Fix width being used instead of height
1 parent a26a3da commit 2429919

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

assets/src/cursors.pixi

-2.85 KB
Binary file not shown.

assets/src/misc.pixi

-2.68 KB
Binary file not shown.

src/internal/File.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,18 +1019,14 @@ pub fn processAnimationTool(file: *File) !void {
10191019
}
10201020
}
10211021

1022-
pub const FillToolOptions = struct {
1023-
texture_position_offset: [2]f32 = .{ 0.0, 0.0 },
1024-
};
1025-
10261022
// Internal dfs function for flood fill
1027-
fn fillToolDFS(file: *File, fill_layer: Layer, pixels: ([][4]u8), x: usize, y: usize, bounds: [4]usize, original_color: [4]u8, new_color: [4]u8) !void {
1023+
fn fillToolDFS(file: *File, fill_layer: Layer, pixels: [][4]u8, x: usize, y: usize, bounds: [4]usize, original_color: [4]u8, new_color: [4]u8) !void {
10281024
if (x >= bounds[0] + bounds[2] or y >= bounds[1] + bounds[3] or x < bounds[0] or y < bounds[1]) {
10291025
return;
10301026
}
10311027
const pixel_index = fill_layer.getPixelIndex(.{ x, y });
10321028
const color = pixels[pixel_index];
1033-
if (!std.mem.eql(u8, &color, &original_color)) {
1029+
if (!std.meta.eql(color, original_color)) {
10341030
return;
10351031
}
10361032

@@ -1044,6 +1040,10 @@ fn fillToolDFS(file: *File, fill_layer: Layer, pixels: ([][4]u8), x: usize, y: u
10441040
try file.buffers.stroke.append(pixel_index, original_color);
10451041
}
10461042

1043+
pub const FillToolOptions = struct {
1044+
texture_position_offset: [2]f32 = .{ 0.0, 0.0 },
1045+
};
1046+
10471047
pub fn processFillTool(file: *File, canvas: Canvas, options: FillToolOptions) !void {
10481048
if (switch (pixi.editor.tools.current) {
10491049
.bucket => false,
@@ -1091,13 +1091,13 @@ pub fn processFillTool(file: *File, canvas: Canvas, options: FillToolOptions) !v
10911091
const pixel = .{ @as(usize, @intFromFloat(pixel_coord[0])), @as(usize, @intFromFloat(pixel_coord[1])) };
10921092

10931093
const index = selected_layer.getPixelIndex(pixel);
1094-
var pixels = @as([*][4]u8, @ptrCast(selected_layer.texture.image.data.ptr))[0 .. selected_layer.texture.image.data.len / 4];
1094+
var pixels = selected_layer.pixels();
10951095

10961096
const tile_column = @divTrunc(pixel[0], @as(usize, @intCast(file.tile_width)));
10971097
const tile_row = @divTrunc(pixel[1], @as(usize, @intCast(file.tile_height)));
10981098

10991099
const bounds_x: usize = tile_column * @as(usize, @intCast(file.tile_width));
1100-
const bounds_y: usize = tile_row * @as(usize, @intCast(file.tile_width));
1100+
const bounds_y: usize = tile_row * @as(usize, @intCast(file.tile_height));
11011101

11021102
const bounds_width: usize = @intCast(file.tile_width);
11031103
const bounds_height: usize = @intCast(file.tile_height);

0 commit comments

Comments
 (0)