From c6a53d271092423569c068b1c913537f41c1dc75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?w=C5=8D=C3=B0-w=C5=8Dd?= Date: Thu, 6 Jul 2017 23:14:25 -0400 Subject: [PATCH] creatio ex nihilo --- .gitignore | 2 + GNUmakefile | 27 ++++++++++++ LICENSE | 23 ++++++++++ Makefile | 24 +++++++++++ README | 19 +++++++++ gen_png_thumbs.sh | 14 +++++++ ps2png.sh | 32 ++++++++++++++ transyMjolnir.ps | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 263 insertions(+) create mode 100644 .gitignore create mode 100644 GNUmakefile create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100755 gen_png_thumbs.sh create mode 100755 ps2png.sh create mode 100644 transyMjolnir.ps diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..212e3cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.*.swp +.*~ diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..8750947 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,27 @@ +# +# Makefile for GNU make (`gmake`) +# +SIZES_AND_RESOS= 128:72 64:36 32:18 +FILENAME_PREFIX= transyMjolnir_ +SRC= transyMjolnir.ps +OFILES= + +define MAKE_RULE = +OFILES+= $(FILENAME_PREFIX)$(1)x$(1).png +$(FILENAME_PREFIX)$(1)x$(1).png: $(SRC) + ./ps2png.sh $$^ $$@ $(1) $(2) +endef + +$(foreach i,$(SIZES_AND_RESOS),$(eval \ +$(call MAKE_RULE,$(firstword $(subst :, ,$(i))),\ + $(lastword $(subst :, ,$(i)))))) + + +all: $(OFILES) + +clean: + rm *.png + +.PHONY: all clean +.DEFAULT_GOAL:= all + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..37639fb --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +transyMjolnir.ps and friends are copyright © 2017 Candace Hierehāt + +This work is free software. It is provided without any warranty, +neither express nor implied, to the full extent permitted under +applicable law. You may redistribute it and/or modify it under the +terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, Version 2, +as published by Sam Hocevar. The license text is reproduced below. + + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e457fe --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +# +# Makefile for BSD make (`bmake`) +# +SIZES_AND_RESOS= 128 72 64 36 32 18 +FILENAME_PREFIX= transyMjolnir_ +SRC= transyMjolnir.ps +OFILES= + + +.for size res in ${SIZES_AND_RESOS} +OFILES+= ${FILENAME_PREFIX}${size}x${size}.png +${FILENAME_PREFIX}${size}x${size}.png: ${SRC} + ./ps2png.sh $> $@ ${size} ${res} +.endfor + + +all: ${OFILES} + +clean: + rm *.png + +.PHONY: all clean +.MAIN: all + diff --git a/README b/README new file mode 100644 index 0000000..3314f9c --- /dev/null +++ b/README @@ -0,0 +1,19 @@ +transyMjolnir.ps: draw a transpride Mjölnir + +Prerequisite: Ghostscript (tested with GPL Ghostscript 9.19) + +Build automation is provided for BSD make (bmake), GNU make (gmake), and +GNU bash (probably works with ksh, too, but hasn't been tested). + +If you've got `gs`, `bash`, and `make` in your PATH, it should be enough +to just run `make` in this directory. + +The build scripts all attempt to accomplish the same goal: use the +Ghostscript interpreter to generate PNG rasterizations of the logo +at three different size: 128x128, 64x64, and 32x32. They'll be written +to the current directory. + + Have fun. + -- Candace (wōð-wōd) + 2017-07-06 + diff --git a/gen_png_thumbs.sh b/gen_png_thumbs.sh new file mode 100755 index 0000000..32b1e59 --- /dev/null +++ b/gen_png_thumbs.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +run() { + echo "$@" + "$@" + return "$?" +} + +for i in "128 72" "64 36" "32 18"; do + S="${i% *}" + R="${i#$S}" + run ./ps2png.sh transyMjolnir.ps transyMjolnir_${S}x${S}.png ${S} ${R} +done + diff --git a/ps2png.sh b/ps2png.sh new file mode 100755 index 0000000..a7ec70a --- /dev/null +++ b/ps2png.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +if [ -z "$1" -o -z "$2" ]; then + echo "${0##*/}: generate PNG raster image from PostScript file" >&2 + echo "usage: ${0##*/} [outsize] [outres]" >&2 + exit 1 +fi + + +RES=72 +BOX=128 +if [ -n "$4" ]; then + RES="$4" +fi +if [ -n "$3" ]; then + BOX="$3" +fi + +if ! echo "$BOX" |grep x; then + BOX="${BOX}x${BOX}" +fi + + +gs -sDEVICE=pngalpha \ + -q \ + -dNOPAUSE \ + -sOutputFile="$2" \ + -r"$RES" \ + -g"$BOX" \ + "$1" + +exit "$?" diff --git a/transyMjolnir.ps b/transyMjolnir.ps new file mode 100644 index 0000000..7a637f3 --- /dev/null +++ b/transyMjolnir.ps @@ -0,0 +1,122 @@ +%!PS-Adobe-3.0 +%%Title: transyMjolnir.ps +%%Creator: Candace Hierehāt +%%CreationDate: 2017-07-01 +%%Pages: 1 +%%BoundingBox: 0 0 128 128 +%%EndComments +% +% Draw a Mjölnir (Thor's hammer) symbol adorned with the tricolour +% of the transgender pride flag. +% + + +% hammerdo - +% create a Mjölnir path within a square of size and call procedure +% within the path's context, passing atop the stack the size of the context: +% - +% +/hammerdo { + 2 dict begin % room for 2 local variables + /f exch def % top of stack goes into + /s exch def % new top goes into + + gsave % save the graphics context + s 36290 div dup scale % scale local coords to fit within x + newpath % start drawing a new path + 18145 0 moveto % path data... + 11842 3800 1528 4560 764 4560 curveto + 0 4560 0 5320 0 5320 curveto + 0 12160 lineto + 14325 11970 13370 15010 13370 15010 curveto + 13370 27170 lineto + 13370 27170 13561 33250 10314 33250 curveto + 10123 33250 10314 36290 10314 36290 curveto + 25785 36290 lineto + 25785 36290 25785 33250 25785 33250 curveto + 22538 33250 22729 27170 22729 27170 curveto + 22729 15010 lineto + 22729 15010 21774 11970 36290 12160 curveto + 36290 5320 lineto + 36290 5320 36290 4560 35335 4560 curveto + 34571 4560 24257 3800 18145 0 curveto + closepath % that's all the data; close the path + 36290 f % call with the local coord scale factor + grestore % restore the previous graphics context + + end % end local scope +} def + + +% push some rgb values onto the stack for use with setrgbcolor +% - /colour +% +/blue { 91 255 div 206 255 div 250 255 div } def +/pink { 245 255 div 169 255 div 184 255 div } def +/white { 255 255 div 255 255 div 255 255 div } def + + +% flagfill - +% draw an x square trans pride flag at the origin +% +/flagfill { + 2 dict begin % room for two local variables + /s exch def % pop top of stack into + + /t s 5 div def % height of each stripe + + blue setrgbcolor % fill the background with a blue + 0 0 s s rectfill % x square + pink setrgbcolor % now paint over part of the bg with a pink, + 0 t s 3 t mul rectfill % vertically-centered x<3t> rectangle + white setrgbcolor % and paint over part of that with a white, + 0 t t add s t rectfill % vertically-centered x rectangle + + end % end of local scope +} def + +%%EndProlog + +% + +%%BeginSetup +initgraphics + +/sz currentpagedevice /PageSize get 0 get def % page size +/res currentpagedevice /HWResolution get 0 get def % output DPI +/rsb 72 def % the resolutory basis in which to draw +/lwd rsb res sub rsb res div dup add div res add def + % line width divisor: (rsb-res) / 2*(rsb/res) + res +/ofs sz lwd div 2 mul def % the desired offset for drop shadow +/tsz sz ofs sub def % size of the Mjölnir symbol to draw +% uncomment to "disable" drop shadow: +%/ofs 0 def +%/tsz sz def +%%EndSetup + + +%%Page: 1 1 +gsave + ofs 0 translate % to the right by units + tsz { % draw a drop shadow + pop % don't need the context size here + 0 setgray % paint it black + fill % fill the hammer shape black + } hammerdo +grestore % back to the initial graphics state +gsave + 0 ofs translate % up by units + tsz { % main attraction + clip flagfill % use hammer as clip path when drawing flag + } hammerdo + + tsz { % draw a dark outline + lwd div setlinewidth + 0 setgray % paint it black + stroke % draw the outline along the path + } hammerdo +grestore +showpage % finished drawing + +quit +%%EOF -- 2.11.4.GIT