Skip to content

Commit 13c9039

Browse files
committed
Port logo case generator to main OpenSCAD variant
1 parent f078f51 commit 13c9039

23 files changed

Lines changed: 443246 additions & 4246 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
render/*
22
!render/thumbnails
3+
export/logo/*
4+
!export/logo/OpenBikeSensor

Makefile

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
OPENSCAD=/usr/bin/openscad
2-
OPENSCAD_OPTIONS=-DVERBOSE=false -q
2+
OPENSCAD_OPTIONS=-q
33
IMAGE_OPTIONS=--imgsize=1024,768 --colorscheme "Tomorrow Night" --render true -D orient_for_printing=false
44
THUMBNAIL_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))
88
PNGS=$(patsubst src/%.scad,render/%.png,$(SRCS))
99
THUMBNAILS=$(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+
1122
all: export-all thumbnails
1223

1324
clean:
@@ -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))))

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,10 @@ rider and would like to use a top rider mount. The opposite is not available.
320320
* `HandlebarRail`
321321
* `HandlebarRail_tube_radius`: The radius (half diameter) of your handlebar,
322322
in mm.
323+
324+
### Logo customization
325+
326+
The `Makefile` supports generating the case with different logos. For now, the
327+
only parts that are customizable with logos are `MainCase/MainCase` and
328+
`MainCase/MainCaseLid`. Please check the instructions in
329+
[`logo/README.md`](./logo/README.md) for creating your own logo version.

0 commit comments

Comments
 (0)