Skip to content

Instantly share code, notes, and snippets.

@Atlas48
Last active September 18, 2022 11:38
Show Gist options
  • Save Atlas48/89b7cbe46facb990f68dda8da21f3ce4 to your computer and use it in GitHub Desktop.
Save Atlas48/89b7cbe46facb990f68dda8da21f3ce4 to your computer and use it in GitHub Desktop.
Generates a svg pallete based on a textual list of colours
#!/usr/bin/awk -f
# gp.awk: generates a svg rendering of a textual pallete list
BEGIN {
if(!h) h=1080
if(!w) w=1920
c=0
print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
printf("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"%d\" width=\"%d\">\n", h, w)
}
{
a[c]=$0
c++
}
END {
stop=w/c
cur=0.0
for(i in a) {
printf("<rect x=\"%g\" y=\"0\" height=\"%d\" width=\"%g\" style=\"fill:%s\" />\n",cur,h,stop,a[i])
cur+=stop
}
print "</svg>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment