11OPENSCAD =/usr/bin/openscad
2- OPENSCAD_OPTIONS=-DVERBOSE =false - q
2+ OPENSCAD_OPTIONS =-q
33IMAGE_OPTIONS=--imgsize =1024,768 --colorscheme "Tomorrow Night" --render true -D orient_for_printing=false
44THUMBNAIL_OPTIONS=--imgsize =400,300 --colorscheme "Tomorrow Night" --render true -D fast=true -D orient_for_printing=false
55
@@ -8,6 +8,17 @@ STLS=$(patsubst src/%.scad,export/%.stl,$(SRCS))
88PNGS =$(patsubst src/% .scad,render/% .png,$(SRCS ) )
99THUMBNAILS =$(patsubst src/% .scad,render/thumbnails/% .png,$(SRCS ) )
1010
11+ LOGOS =$(shell find logo/ -mindepth 1 -maxdepth 1 -type d -not -name template | xargs basename)
12+ FILES_WITH_LOGO := MainCase/MainCase MainCase/MainCaseLid
13+ LOGO_PARTS := main highlight
14+ LOGO_MODES := normal inverted
15+
16+ ifdef DEBUG
17+ OPENSCAD_OPTIONS += -D fast=true
18+ endif
19+
20+ $(info $(OPENSCAD_OPTIONS))
21+
1122all : export-all thumbnails
1223
1324clean :
@@ -36,3 +47,36 @@ render/assembly.gif: assembly.scad $(SRCS)
3647 $(OPENSCAD ) --animate 60 $(OPENSCAD_OPTIONS ) $(IMAGE_OPTIONS ) --camera 0,0,0,45,0,60,600 assembly.scad -o render/assembly.png
3748 convert render/assembly* .png -set delay 4 -reverse y* .png -set delay 4 -loop 0 render/assembly.gif
3849
50+ # $1: logo name
51+ # $2: part path (e. g. MainCase/MainCaseLid)
52+ # $3: logo part (main|highlight)
53+ # $4: logo mode (normal|inverted)
54+ define logo-part-rule
55+ export /logo/$(1)/$(shell basename $(2))-$(4)-$(3).stl: src/$(2).scad logo/$(1)/$(shell basename $(2)).svg
56+ @mkdir -p $$(shell dirname $$@ )
57+ $$(OPENSCAD ) $$(OPENSCAD_OPTIONS ) -D orient_for_printing=true -D logo_enabled=true -D 'logo_mode="$(4 ) "' -D 'logo_part="$(3 ) "' -D 'logo_name="$(1 ) "' -o $$@ $$<
58+
59+ logo-$1-$4: export/logo/$(1 ) /$(shell basename $(2 ) ) -$(4 ) -$(3 ) .stl
60+ logo-$1: export/logo/$(1 ) /$(shell basename $(2 ) ) -$(4 ) -$(3 ) .stl
61+ logos: logo-$1
62+ endef
63+
64+ $(foreach logo,$(LOGOS), \
65+ $(foreach file,$(FILES_WITH_LOGO), \
66+ $(foreach logo_part,$(LOGO_PARTS), \
67+ $(foreach logo_mode,$(LOGO_MODES), \
68+ $(eval $(call logo-part-rule,$(logo),$(file),$(logo_part),$(logo_mode)))))))
69+
70+
71+ # $1: part path (e. g. MainCase/MainCaseLid)
72+ define logo-template-rule
73+ logo/template/$(shell basename $(1 ) ) .svg: src/$(1 ) .scad
74+ @mkdir -p $$(shell dirname $$@ )
75+ $(OPENSCAD ) $(OPENSCAD_OPTIONS ) -D orient_for_printing=true -D logo_generate_templates=true -D fast=true -o $$@ $$<
76+ sed -i 's/stroke-width="[0-9\.]*"/stroke-width="0"/' $$@
77+
78+ logo-templates: logo/template/$(shell basename $(1 ) ) .svg
79+ endef
80+
81+ $(foreach file,$(FILES_WITH_LOGO), \
82+ $(eval $(call logo-template-rule,$(file))))
0 commit comments