aboutsummaryrefslogtreecommitdiff
path: root/make_preview_image.lua
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-10-10 16:38:47 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-10-10 16:38:47 -0400
commit40b51358400dfbc875d031b5a6cd92d09f1f51d4 (patch)
treebdf75ff0da2a187bc07dd017411021975e1bfd52 /make_preview_image.lua
parent826b819b731849779dfeb0144d2372785a318832 (diff)
parent3c9753416961ce86094eb4bf812d1f352cf7ff7b (diff)
downloadlite-xl-colors-40b51358400dfbc875d031b5a6cd92d09f1f51d4.tar.gz
lite-xl-colors-40b51358400dfbc875d031b5a6cd92d09f1f51d4.zip
Merge remote-tracking branch 'upstream/master' into flexoki
Diffstat (limited to 'make_preview_image.lua')
-rwxr-xr-xmake_preview_image.lua51
1 files changed, 0 insertions, 51 deletions
diff --git a/make_preview_image.lua b/make_preview_image.lua
deleted file mode 100755
index 6bcaac8..0000000
--- a/make_preview_image.lua
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/lua
-
-local filename = ...
-local name = filename:match("([^\\/]+)%..*$")
-
-
--- get colors
-local text = io.open(filename):read("*a")
-local colors = {}
-for r, g, b in text:gmatch("#(%x%x)(%x%x)(%x%x)") do
- r = tonumber(r, 16)
- g = tonumber(g, 16)
- b = tonumber(b, 16)
- table.insert(colors, { r, g, b })
-end
-
-table.sort(colors, function(a, b)
- return a[1] + a[2] + a[3] < b[1] + b[2] + b[3]
-end)
-
-local function eq(a, b)
- return a[1] == b[1] and a[2] == b[2] and a[3] == b[3]
-end
-
-local prev = {}
-for i = #colors, 1, -1 do
- if eq(colors[i], prev) then
- table.remove(colors, i)
- else
- prev = colors[i]
- end
-end
-
-
---generate svg file
-local w = 200
-local h = 16
-local fp = io.open("previews/" .. name .. ".svg", "wb")
-
-fp:write('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'..w..'" height="'..h..'" shape-rendering="crispEdges"> \n')
-
-for i = 1, #colors do
- local width = w/#colors
- local r, g, b = table.unpack(colors[i])
- local rect = '<rect x="'..(i-1)*width..'" width="'..width..'" height="'..h..'" fill="rgb('..r..', '..g..', '..b..')"></rect> \n'
- fp:write(rect)
-end
-
-fp:write('</svg>')
-fp:close()
-