Skip to content

Commit

Permalink
feat: are more parameters to quad draw
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Dec 2, 2024
1 parent 9ee4ab8 commit 0ab8ab8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lua/smear_cursor/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ M.min_slope_vertical = 2

M.color_levels = 16 -- Minimum 1
M.gamma = 2.2 -- For color blending
M.diagonal_pixel_value_threshold = 0.25 -- 0.1: more pixels, 0.9: less pixels
M.max_shade_no_matrix = 0.9 -- 0: more overhangs, 1: more matrices
M.matrix_pixel_threshold = 0.2 -- 0: all pixels, 1: no pixel
M.matrix_pixel_min_factor = 0.5 -- 0: all pixels, 1: no pixel
M.volume_reduction_exponent = 0.2 -- 0: no reduction, 1: full reduction
M.minimum_volume_factor = 0.7 -- 0: no limit, 1: no reduction

Expand Down
9 changes: 6 additions & 3 deletions lua/smear_cursor/draw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ local function draw_partial_block(row, col, character_list, character_index, hl_
end

local function draw_matrix_character(row, col, matrix)
local threshold = config.diagonal_pixel_value_threshold
* math.max(matrix[1][1], matrix[1][2], matrix[2][1], matrix[2][2])
local max = math.max(matrix[1][1], matrix[1][2], matrix[2][1], matrix[2][2])
if max < config.matrix_pixel_threshold then
return
end
local threshold = max * config.matrix_pixel_min_factor
local bit_1 = (matrix[1][1] > threshold) and 1 or 0
local bit_2 = (matrix[1][2] > threshold) and 1 or 0
local bit_3 = (matrix[2][1] > threshold) and 1 or 0
Expand Down Expand Up @@ -397,7 +400,7 @@ M.draw_quad = function(corners, target_position)

-- Draw shifted block
if is_vertically_shifted and is_horizontally_shifted then
if vertical_shade < 0.75 and horizontal_shade < 0.75 then
if vertical_shade < config.max_shade_no_matrix and horizontal_shade < config.max_shade_no_matrix then
goto continue
elseif vertical_shade < horizontal_shade then
is_horizontally_shifted = false
Expand Down

0 comments on commit 0ab8ab8

Please sign in to comment.