home / system / tools_source

Menu
  • GraphQL API
  • Search all tables

tools_source: 12

This data as json

id tool_id filename language content
12 1 colors.sh sh #!/bin/sh # colors — convert between hex, rgb, hsl hex_to_rgb() { hex="${1#\#}" [ ${#hex} -eq 3 ] && hex="$(echo "$hex" | sed 's/./&&/g')" r=$((16#${hex%????})) g=$((16#$(echo "$hex" | cut -c3-4))) b=$((16#${hex#????})) printf 'rgb(%d, %d, %d)\n' "$r" "$g" "$b" } input="${1:-$(cat)}" case "$input" in \#*|[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]*) hex_to_rgb "$input" ;; *) echo "unsupported format: $input" >&2 exit 1 ;; esac
Powered by Datasette · 0.62ms · krisyotam.com