Skip to content

Commit b3e1af8

Browse files
authored
Merge pull request #252 from HuntFeng/master
feat: added scale_factor for custom global scaling
2 parents fd70543 + bc2054b commit b3e1af8

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lua/image/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ local default_options = {
3131
max_height = nil,
3232
max_width_window_percentage = 100,
3333
max_height_window_percentage = 50,
34+
scale_factor = 1.0,
3435
kitty_method = "normal",
3536
window_overlap_clear_enabled = false,
3637
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "scrollview", "scrollview_sign" },

lua/image/renderer.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ local cache = {}
1111
local render = function(image)
1212
local state = image.global_state
1313
local term_size = utils.term.get_size()
14-
local image_rows = math.floor(image.image_height / term_size.cell_height)
15-
local image_columns = math.floor(image.image_width / term_size.cell_width)
14+
local scale_factor = 1.0
15+
if type(state.options.scale_factor) == "number" then scale_factor = state.options.scale_factor end
16+
local image_rows = math.floor(image.image_height / term_size.cell_height * scale_factor)
17+
local image_columns = math.floor(image.image_width / term_size.cell_width * scale_factor)
1618
local image_cache = cache[image.original_path] or { resized = {}, cropped = {} }
1719

1820
-- utils.debug(("renderer.render() %s"):format(image.id), {

lua/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
---@field max_height? number
3838
---@field max_width_window_percentage? number
3939
---@field max_height_window_percentage? number
40+
---@field scale_factor? number
4041
---@field kitty_method "normal"|"unicode-placeholders"
4142
---@field window_overlap_clear_enabled? boolean
4243
---@field window_overlap_clear_ft_ignore? string[]

0 commit comments

Comments
 (0)