Skip to content

Commit 1439489

Browse files
committed
fix: prevent drawing diagonal blocks if others edges intersect cell
1 parent c0feada commit 1439489

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

lua/smear_cursor/config.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ M.max_slope_horizontal = (1 / 3) / 1.5
121121
M.min_slope_vertical = 2 * 1.5
122122
M.max_angle_difference_diagonal = math.pi / 16 -- radians
123123
M.max_offset_diagonal = 0.2 -- cell widths
124+
M.min_shade_no_diagonal = 0.2 -- 0: less diagonal blocks, 1: more diagonal blocks
125+
M.min_shade_no_diagonal_vertical_bar = 0.5
124126

125127
M.color_levels = 16 -- Minimum 1, don't set manually if using cterm_cursor_colors
126128
M.gamma = 2.2 -- For color blending
127129
M.max_shade_no_matrix = 0.75 -- 0: more overhangs, 1: more matrices
128130
M.matrix_pixel_threshold = 0.7 -- 0: all pixels, 1: no pixel
129-
M.matrix_pixel_threshold_vertical_bar = 0.3 -- 0: all pixels, 1: no pixel
131+
M.matrix_pixel_threshold_vertical_bar = 0.25 -- 0: all pixels, 1: no pixel
130132
M.matrix_pixel_min_factor = 0.5 -- 0: all pixels, 1: no pixel
131133
M.volume_reduction_exponent = 0.3 -- 0: no reduction, 1: full reduction
132134
M.minimum_volume_factor = 0.7 -- 0: no limit, 1: no reduction

lua/smear_cursor/draw.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ M.draw_quad = function(corners, target_position, vertical_bar)
713713
bulge_above = not bulge_above
714714
corners = ensure_clockwise(corners)
715715
local G = precompute_quad_geometry(corners)
716+
local min_shade_no_diagonal = vertical_bar and config.min_shade_no_diagonal_vertical_bar
717+
or config.min_shade_no_diagonal
716718

717719
for row = G.top, G.bottom do
718720
for col = G.left, G.right do
@@ -732,18 +734,22 @@ M.draw_quad = function(corners, target_position, vertical_bar)
732734
for i = 1, 4 do
733735
local intersection = get_edge_cell_intersection(i, row, col, G)
734736
local edge_type = G.edge_types[i]
735-
if edge_type == LEFT_DIAGONAL or edge_type == RIGHT_DIAGONAL then edge_type = DIAGONAL end
736-
if edge_type ~= DIAGONAL and intersection >= 1 then goto continue end
737737

738-
if edge_type == DIAGONAL then
738+
if edge_type == LEFT_DIAGONAL or edge_type == RIGHT_DIAGONAL then
739+
edge_type = DIAGONAL
739740
local intersection_low = get_edge_cell_intersection(i, row, col, G, true)
740741
if intersection_low >= 1 then goto continue end
741-
-- if intersections[DIAGONAL] ~= nil and intersection > 0 then single_diagonal = false end
742+
if intersection > min_shade_no_diagonal and intersections[DIAGONAL] ~= nil then
743+
single_diagonal = false
744+
end
742745
else
743-
if intersection > 0 then single_diagonal = false end
746+
if intersection >= 1 then goto continue end
747+
if intersection > min_shade_no_diagonal then single_diagonal = false end
744748
end
745749

746-
if intersections[edge_type] == nil or intersection > intersections[edge_type] then
750+
if
751+
intersection > 0 and (intersections[edge_type] == nil or intersection > intersections[edge_type])
752+
then
747753
intersections[edge_type] = intersection
748754
if edge_type == DIAGONAL then diagonal_edge_index = i end
749755
end

0 commit comments

Comments
 (0)