@@ -104,13 +104,31 @@ local RIGHT_DIAGONAL_BLOCKS = {
104104 },
105105}
106106M .BLOCK_ASPECT_RATIO = 2.0 -- height / width
107+
108+ local OCTANT_CHARACTERS = {
109+ " " , " " , " 🮂" , " " , " ▘" , " " , " " , " " , " " , " ▝" , " " , " " , " " , " " , " ▀" ,
110+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
111+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
112+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " 🮅" ,
113+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
114+ " ▖" , " " , " " , " " , " " , " ▌" , " " , " " , " " , " " , " ▞" , " " , " " , " " , " " , " ▛" ,
115+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
116+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
117+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
118+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
119+ " ▗" , " " , " " , " " , " " , " ▚" , " " , " " , " " , " " , " ▐" , " " , " " , " " , " " , " ▜" ,
120+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
121+ " ▂" , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
122+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
123+ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ,
124+ " ▄" , " " , " " , " " , " " , " ▙" , " " , " " , " " , " " , " ▟" , " " , " ▆" , " " , " " , " █" ,
125+ }
107126-- stylua: ignore end
108127
109128local braille_characters = {}
110129for i = 1 , 255 do
111130 local code = 0x2800 + i
112- braille_characters [i ] =
113- string.char (0xE0 + math.floor (code / 0x1000 ), 0x80 + (math.floor (code / 0x40 ) % 0x40 ), 0x80 + (code % 0x40 ))
131+ braille_characters [i ] = vim .fn .nr2char (code )
114132end
115133
116134-- Enums for drawing quad
@@ -876,6 +894,21 @@ M.draw_quad = function(corners, target_position, vertical_bar, gradient_origin,
876894 end
877895end
878896
897+ local function draw_octant_character (row , col , cell , hl_group , zindex )
898+ local octant_index = (cell [1 ][1 ] > 0 and 1 or 0 )
899+ + (cell [1 ][2 ] > 0 and 2 or 0 )
900+ + (cell [2 ][1 ] > 0 and 4 or 0 )
901+ + (cell [2 ][2 ] > 0 and 8 or 0 )
902+ + (cell [3 ][1 ] > 0 and 16 or 0 )
903+ + (cell [3 ][2 ] > 0 and 32 or 0 )
904+ + (cell [4 ][1 ] > 0 and 64 or 0 )
905+ + (cell [4 ][2 ] > 0 and 128 or 0 )
906+
907+ if octant_index == 0 then return end
908+
909+ M .draw_character (row , col , OCTANT_CHARACTERS [octant_index ], hl_group , zindex )
910+ end
911+
879912local function draw_braille_character (row , col , cell , hl_group , zindex )
880913 local braille_index = (cell [1 ][1 ] > 0 and 1 or 0 )
881914 + (cell [2 ][1 ] > 0 and 2 or 0 )
893926
894927M .draw_particles = function (particles , target_position )
895928 if target_position == nil then target_position = { 0 , 0 } end
929+
930+ local lifetime_switch_octant_braille = config .particle_max_lifetime
931+ * (config .legacy_computing_symbols_support and config .particle_switch_octant_braille or math.huge )
896932 local cells = {}
897933
898934 for _ , particle in ipairs (particles ) do
@@ -928,18 +964,29 @@ M.draw_particles = function(particles, target_position)
928964 + cell [3 ][2 ]
929965 + cell [4 ][1 ]
930966 + cell [4 ][2 ]
931- local shade = math.min (1 , lifetime_sum / num_dots / config .particle_max_lifetime )
967+
968+ local lifetime_average = lifetime_sum / num_dots
969+ local draw_function
970+ local shade
971+ if lifetime_average > lifetime_switch_octant_braille then
972+ draw_function = draw_octant_character
973+ shade = math.min (
974+ 1 ,
975+ (lifetime_average - lifetime_switch_octant_braille )
976+ / (config .particle_max_lifetime - lifetime_switch_octant_braille )
977+ )
978+ else
979+ draw_function = draw_braille_character
980+ shade = math.min (
981+ 1 ,
982+ lifetime_average / math.min (config .particle_max_lifetime , lifetime_switch_octant_braille )
983+ )
984+ end
932985 local hl_group_index = round (shade * config .color_levels )
933986
934987 if hl_group_index == 0 then goto continue end
935988
936- draw_braille_character (
937- row ,
938- col ,
939- cell ,
940- color .get_hl_group ({ level = hl_group_index }),
941- config .windows_zindex - 1
942- )
989+ draw_function (row , col , cell , color .get_hl_group ({ level = hl_group_index }), config .windows_zindex - 1 )
943990
944991 :: continue::
945992 end
0 commit comments