Skip to content

Commit

Permalink
Merge pull request #252 from HuntFeng/master
Browse files Browse the repository at this point in the history
feat: added scale_factor for custom global scaling
  • Loading branch information
3rd authored Dec 5, 2024
2 parents fd70543 + bc2054b commit b3e1af8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions lua/image/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local default_options = {
max_height = nil,
max_width_window_percentage = 100,
max_height_window_percentage = 50,
scale_factor = 1.0,
kitty_method = "normal",
window_overlap_clear_enabled = false,
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "scrollview", "scrollview_sign" },
Expand Down
6 changes: 4 additions & 2 deletions lua/image/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ local cache = {}
local render = function(image)
local state = image.global_state
local term_size = utils.term.get_size()
local image_rows = math.floor(image.image_height / term_size.cell_height)
local image_columns = math.floor(image.image_width / term_size.cell_width)
local scale_factor = 1.0
if type(state.options.scale_factor) == "number" then scale_factor = state.options.scale_factor end
local image_rows = math.floor(image.image_height / term_size.cell_height * scale_factor)
local image_columns = math.floor(image.image_width / term_size.cell_width * scale_factor)
local image_cache = cache[image.original_path] or { resized = {}, cropped = {} }

-- utils.debug(("renderer.render() %s"):format(image.id), {
Expand Down
1 change: 1 addition & 0 deletions lua/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
---@field max_height? number
---@field max_width_window_percentage? number
---@field max_height_window_percentage? number
---@field scale_factor? number
---@field kitty_method "normal"|"unicode-placeholders"
---@field window_overlap_clear_enabled? boolean
---@field window_overlap_clear_ft_ignore? string[]
Expand Down

0 comments on commit b3e1af8

Please sign in to comment.