@@ -1019,18 +1019,14 @@ pub fn processAnimationTool(file: *File) !void {
1019
1019
}
1020
1020
}
1021
1021
1022
- pub const FillToolOptions = struct {
1023
- texture_position_offset : [2 ]f32 = .{ 0.0 , 0.0 },
1024
- };
1025
-
1026
1022
// 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 {
1028
1024
if (x >= bounds [0 ] + bounds [2 ] or y >= bounds [1 ] + bounds [3 ] or x < bounds [0 ] or y < bounds [1 ]) {
1029
1025
return ;
1030
1026
}
1031
1027
const pixel_index = fill_layer .getPixelIndex (.{ x , y });
1032
1028
const color = pixels [pixel_index ];
1033
- if (! std .mem .eql (u8 , & color , & original_color )) {
1029
+ if (! std .meta .eql (color , original_color )) {
1034
1030
return ;
1035
1031
}
1036
1032
@@ -1044,6 +1040,10 @@ fn fillToolDFS(file: *File, fill_layer: Layer, pixels: ([][4]u8), x: usize, y: u
1044
1040
try file .buffers .stroke .append (pixel_index , original_color );
1045
1041
}
1046
1042
1043
+ pub const FillToolOptions = struct {
1044
+ texture_position_offset : [2 ]f32 = .{ 0.0 , 0.0 },
1045
+ };
1046
+
1047
1047
pub fn processFillTool (file : * File , canvas : Canvas , options : FillToolOptions ) ! void {
1048
1048
if (switch (pixi .editor .tools .current ) {
1049
1049
.bucket = > false ,
@@ -1091,13 +1091,13 @@ pub fn processFillTool(file: *File, canvas: Canvas, options: FillToolOptions) !v
1091
1091
const pixel = .{ @as (usize , @intFromFloat (pixel_coord [0 ])), @as (usize , @intFromFloat (pixel_coord [1 ])) };
1092
1092
1093
1093
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 () ;
1095
1095
1096
1096
const tile_column = @divTrunc (pixel [0 ], @as (usize , @intCast (file .tile_width )));
1097
1097
const tile_row = @divTrunc (pixel [1 ], @as (usize , @intCast (file .tile_height )));
1098
1098
1099
1099
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 ));
1101
1101
1102
1102
const bounds_width : usize = @intCast (file .tile_width );
1103
1103
const bounds_height : usize = @intCast (file .tile_height );
0 commit comments