From cb7a18ff336943df1034ab51825acbdca11f77fd Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 22 Oct 2021 11:02:05 -0400 Subject: add bin/logo-0 --- bin/logo-0/Gemfile | 7 ++ bin/logo-0/Gemfile.lock | 13 +++ bin/logo-0/README.md | 17 +++ bin/logo-0/gen-logo.rb | 181 ++++++++++++++++++++++++++++++ bin/logo-0/logo-0-orig.svg | 271 +++++++++++++++++++++++++++++++++++++++++++++ bin/logo-0/logo-color.png | Bin 0 -> 3436 bytes 6 files changed, 489 insertions(+) create mode 100644 bin/logo-0/Gemfile create mode 100644 bin/logo-0/Gemfile.lock create mode 100644 bin/logo-0/README.md create mode 100755 bin/logo-0/gen-logo.rb create mode 100644 bin/logo-0/logo-0-orig.svg create mode 100644 bin/logo-0/logo-color.png diff --git a/bin/logo-0/Gemfile b/bin/logo-0/Gemfile new file mode 100644 index 0000000..0f2e0cc --- /dev/null +++ b/bin/logo-0/Gemfile @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +gem 'luigi-template' diff --git a/bin/logo-0/Gemfile.lock b/bin/logo-0/Gemfile.lock new file mode 100644 index 0000000..1179afe --- /dev/null +++ b/bin/logo-0/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + remote: https://rubygems.org/ + specs: + luigi-template (0.5.0) + +PLATFORMS + ruby + +DEPENDENCIES + luigi-template + +BUNDLED WITH + 2.1.4 diff --git a/bin/logo-0/README.md b/bin/logo-0/README.md new file mode 100644 index 0000000..915e59d --- /dev/null +++ b/bin/logo-0/README.md @@ -0,0 +1,17 @@ +pablotron.org logo +================== +[Ruby][] script to generate the site logo as an animated [SVG][]. + +Usage: + + # install dependencies in ./vendor + # (you only need to do this once) + bundle install + + # write logo to "static/logo.svg" + bundle exec ./gen-logo.rb > ../../static/logo.svg + +[ruby]: https://ruby-lang.org/ + "Ruby programming language" +[svg]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics + "Scalable Vector Graphics" diff --git a/bin/logo-0/gen-logo.rb b/bin/logo-0/gen-logo.rb new file mode 100755 index 0000000..7dcffef --- /dev/null +++ b/bin/logo-0/gen-logo.rb @@ -0,0 +1,181 @@ +#!/usr/bin/env ruby + +# +# gen-logo.rb: generate svg logo +# +# +# notes: +# * used #4e86b1 as base color +# * used color wheel to generate complimentary colors: +# https://www.sessions.edu/color-calculator/ +# + +require 'luigi-template' + +CONFIG = { + # svg dimensions + # FIXME: these aren't working + svg_width: 108, + svg_height: 90, + + # show background? + bg: false, + + # animation duration, in seconds + duration: 20, + + # animation delay coefficients + # delay = (y - 1) * YC + (x - 1) * XC + delay_coefficients: { + y: 1.0, + x: 0.2, + }, + + # animation color keyframes + colors: [ + { c: '#ffffff', t: 0 }, + { c: '#4e86b1', t: 0.333 }, + { c: '#4eb179', t: 0.666 }, + { c: '#ffffff', t: 1 }, + ], + + # dot sizes + dot_width: 12, + dot_height: 10, + + # square coordinates + dots: [ + # P (0) + { x: 1, y: 1 }, + { x: 1, y: 2 }, + { x: 1, y: 3 }, + { x: 1, y: 4 }, + { x: 1, y: 5 }, + { x: 1, y: 5 }, + + # P (1) + { x: 2, y: 1 }, + { x: 2, y: 3 }, + + # P (2) + { x: 3, y: 1 }, + { x: 3, y: 2 }, + { x: 3, y: 3 }, + + # T (0) + { x: 5, y: 1 }, + + # T (1) + { x: 6, y: 1 }, + { x: 6, y: 2 }, + { x: 6, y: 3 }, + { x: 6, y: 4 }, + { x: 6, y: 5 }, + + # T (2) + { x: 7, y: 1 }, + + # _ (0-7) + { x: 1, y: 7 }, + { x: 2, y: 7 }, + { x: 3, y: 7 }, + { x: 4, y: 7 }, + { x: 5, y: 7 }, + { x: 6, y: 7 }, + { x: 7, y: 7 }, + ], +} + +# build template cache +TEMPLATES = Luigi::Cache.new({ + svg: %{ + + + %{bg} + + + %{dots} + + + }, + + bg: %{ + + }, + + dot: %{ + + + + }, +}.reduce({}) do |r, row| + r[row[0]] = row[1].strip.gsub(/(?)\s+/, ' ') + r +end) + +# keyframe color values +VALUES = CONFIG[:colors].map { |row| + row[:c] +}.join(';').freeze + +# keyframe times +TIMES = CONFIG[:colors].map { |row| + ('%1.3f' % row[:t]).gsub(/0+$/, '').gsub(/\.$/, '') +}.join(';').freeze + +# get delay coefficients +YC = CONFIG[:delay_coefficients][:y] +XC = CONFIG[:delay_coefficients][:x] + +# generate svg +svg = TEMPLATES[:svg].run({ + # svg dimensions + width: CONFIG[:svg_width], + height: CONFIG[:svg_height], + + # background + bg: CONFIG[:bg] ? TEMPLATES[:bg].run({}) : '', + + # dots + dots: CONFIG[:dots].map { |row| + y = row[:y] * CONFIG[:dot_height] + x = row[:x] * CONFIG[:dot_width] + + # calculate animation delay + delay = (row[:y] - 1) * YC + (row[:x] - 1) * XC + + TEMPLATES[:dot].run(row.merge({ + x: x - 5, + y: y, + width: CONFIG[:dot_width], + height: CONFIG[:dot_height], + + duration: CONFIG[:duration], + begin: '%1.1fs' % [delay], + values: VALUES, + times: TIMES, + })) + }.join, +}) + +# apply cleanups to svg, then write it to stdout +puts([ + [ /> +<' ], + [ /\s+>/m, '>' ], + [ / +\/>/, '/>' ], + [ / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/logo-0/logo-color.png b/bin/logo-0/logo-color.png new file mode 100644 index 0000000..93091ad Binary files /dev/null and b/bin/logo-0/logo-color.png differ -- cgit v1.2.3