pkgs/nix-gscheits.artwork: init

Since OpenSCAD has only limited SVG export capabilities, this
implementation exports the image as PNG. Also, because OpenSCAD lacks
transparency and anti-aliasing, the background colour is replaced by
transparency and the image is then scaled down.
This commit is contained in:
Simon Bruder 2021-07-24 19:25:29 +02:00
parent 71769cb74c
commit c3feedb74a
No known key found for this signature in database
GPG key ID: 8D3C82F9F309F8EC
9 changed files with 139 additions and 0 deletions

2
.gitattributes vendored
View file

@ -1,3 +1,5 @@
**/secrets.yaml diff=sops
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text

View file

@ -110,6 +110,11 @@
(flake-utils.lib.flattenTree {
inherit (pkgs)
fablab;
nix-gscheits = lib.recurseIntoAttrs {
inherit (pkgs.nix-gscheits)
artwork;
};
});
}) // {
overlay = import ./pkgs;

3
pkgs/artwork/artwork/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/icon-*.png
/logo.png
/wallpaper.jpg

View file

@ -0,0 +1,26 @@
ICON_RESOLUTIONS = 16 32 48 64 128 256 512 1024
ICONS = $(foreach resolution,$(ICON_RESOLUTIONS),icon-$(resolution).png )
default: wallpaper.jpg $(ICONS)
logo.png: logo.scad
xvfb-run openscad -q -o $@ $< --camera=0,0,0,0,0,0,150 --projection=ortho --imgsize=4096,4096
mogrify -transparent "#ffffe5" -filter Mitchell -resize 2048 logo.png
icon-%.png: logo.png
convert -filter Mitchell -resize $(basename $(@:icon-%=%)) $< $@
oxipng -q $@
wallpaper.jpg: wallpaper.svg logo.png
inkscape -o - --export-type=png wallpaper.svg | convert -quality 92 - $@
jpegoptim -q -s $@
.PHONY: clean install
install: wallpaper.jpg $(ICONS)
install -Dm444 wallpaper.jpg $(PREFIX)/share/backgrounds/nix-gscheits.jpg
for resolution in $(ICON_RESOLUTIONS); do \
install -Dm444 icon-$${resolution}.png $(PREFIX)/share/icons/hicolor/$${resolution}x$${resolution}/nix-gscheits.png; \
done
clean:
rm -f logo.png wallpaper.jpg $(ICONS)

BIN
pkgs/artwork/artwork/lasercutter.jpg (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,61 @@
// constants
$fn=64;
LABCUBE_COLOURS = [ "#c93841", "#4164b0", "#14a95d" ];
NIX_FLAKE_COLOURS = [ "#5277c3", "#7ebae4" ];
// lib
module axonometric2rectangular(angle) {
scale([tan(angle), 1, 1]) rotate(45) children();
}
module shear2d(x, y) {
multmatrix(m = [[ 1, tan(x)],
[tan(y), 1]]) scale([cos(y), cos(x)]) children();
}
// nix flake
module axonometric_lambda() {
polygon([
[0, 0],
[-8, 0],
[-8, -9],
[-21, -9],
[-21, -13],
[-17, -17],
[-8, -17],
[-8, -26],
[0, -34]
]);
}
module lambda() {
axonometric2rectangular(30) axonometric_lambda();
}
module nix_flake(gap = 0.5, hexagon_size = 10) {
for (angle = [0:60:360]) {
color(NIX_FLAKE_COLOURS[(angle%120)/60]) rotate(angle) translate([-hexagon_size, -gap, 0]) lambda();
}
}
// lab cube
module labcube_face(radius = .33, neck = .32) {
translate([-1/2, -1/2])
difference() {
square();
translate([1/2, 1/2]) circle(radius);
translate([(1-neck)/2, 0]) square(neck);
}
}
module labcube(size = 10) {
for (i = [0:2]) {
color(LABCUBE_COLOURS[i]) rotate(i*120) shear2d(-30, 0) translate([size/2, size/2]) mirror([0, 1, 0]) scale(size) labcube_face();
}
}
// composition
nix_flake(gap = 0.5);
labcube(size = 10-0.5);

BIN
pkgs/artwork/artwork/wallpaper.svg (Stored with Git LFS) Normal file

Binary file not shown.

32
pkgs/artwork/default.nix Normal file
View file

@ -0,0 +1,32 @@
{ lib, stdenv, imagemagick, inkscape, jpegoptim, mesa, openscad, oxipng, xvfb-run }:
stdenv.mkDerivation {
name = "nix-gscheits-artwork";
src = ./artwork;
nativeBuildInputs = [
imagemagick
inkscape
jpegoptim
openscad
oxipng
xvfb-run
];
preBuild = ''
export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib/dri
export LD_LIBRARY_PATH=${mesa.drivers}/lib
'';
enableParallelBuilding = true;
makeFlags = [ "PREFIX=$(out)" ];
meta = with lib; {
description = "Artwork for nix-gscheits";
license = licenses.cc-by-sa-40;
maintainers = with maintainers; [ sbruder ];
platforms = platforms.unix;
};
}

View file

@ -4,4 +4,8 @@ let
in
{
fablab = recurseIntoAttrs (callPackage ./fablab { });
nix-gscheits = prev.recurseIntoAttrs {
artwork = callPackage ./artwork { };
};
}