summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-08-16 19:38:46 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-08-16 19:38:46 +0200
commite54fafdcfcfd2947fcd96a7d1e392be573ae2edb (patch)
tree896c27fdfb0abda56ecbc375e1e8169fe9ed571d
parentc6e20cf71341707516b420e477549564add49dc0 (diff)
Script to generate a fan patternfan
-rw-r--r--source/misc/index.rst12
-rw-r--r--source/misc/unclassified/index.rst13
-rwxr-xr-xsource/misc/unclassified/paper_covered_fan/fan.py118
-rw-r--r--source/misc/unclassified/paper_covered_fan/index.rst26
4 files changed, 169 insertions, 0 deletions
diff --git a/source/misc/index.rst b/source/misc/index.rst
new file mode 100644
index 0000000..ada75e8
--- /dev/null
+++ b/source/misc/index.rst
@@ -0,0 +1,12 @@
+###############
+ Miscellaneous
+###############
+
+Various things that had no place elsewhere.
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ unclassified/index
+
diff --git a/source/misc/unclassified/index.rst b/source/misc/unclassified/index.rst
new file mode 100644
index 0000000..8a3ccdd
--- /dev/null
+++ b/source/misc/unclassified/index.rst
@@ -0,0 +1,13 @@
+**************
+ Unclassified
+**************
+
+Things in this chapter may be moved elsewhere if a more suitable
+chapter is addded.
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ paper_covered_fan/index
+
diff --git a/source/misc/unclassified/paper_covered_fan/fan.py b/source/misc/unclassified/paper_covered_fan/fan.py
new file mode 100755
index 0000000..e50ac75
--- /dev/null
+++ b/source/misc/unclassified/paper_covered_fan/fan.py
@@ -0,0 +1,118 @@
+#!/usr/bin/env python3
+
+import math
+
+import hazwaz
+import svgwrite
+
+
+# 1 cm in px
+cm = 37.795276
+
+LINE_STYLE = {
+ 'stroke': svgwrite.utils.rgb(0, 0, 0),
+ 'stroke_width': 0.5,
+ 'fill': 'none'
+ }
+
+FOLD_LINE_STYLE = {
+ 'stroke': svgwrite.utils.rgb(0, 0, 0),
+ 'stroke_width': 0.5,
+ 'fill': 'none',
+ 'stroke-dasharray': "5,5",
+ }
+
+class Fan(hazwaz.MainCommand):
+ """
+ Draw a fan cover
+ """
+
+ def add_arguments(self, parser):
+ parser.add_argument(
+ "-o", "--outer_radius",
+ type=float,
+ default=25.0,
+ help="Outer radius of the fan sticks (cm)",
+ )
+ parser.add_argument(
+ "-i", "--inner_radius",
+ type=float,
+ default=10.0,
+ help="Outer radius of the fan sticks (cm)",
+ )
+ parser.add_argument(
+ "-w", "--folded_width",
+ type=float,
+ default=2.0,
+ help="Width of the outer sticks (and folded fan) at the top",
+ )
+ parser.add_argument(
+ "-s", "--sticks",
+ type=int,
+ default=12,
+ help="Number of sticks (excluding the outer ones)."
+ )
+
+ def main(self):
+ self.sections = self.args.sticks * 2 + 3
+ self.alpha = self.args.folded_width / self.args.outer_radius
+ self.angle = self.alpha * self.sections
+
+ size = str(self.args.outer_radius * 2 + 2) + "cm"
+ dest = dest = svgwrite.Drawing(
+ filename="fan.svg",
+ size=(size, size),
+ profile="full",
+ )
+ fan = self.draw_fan(dest)
+ dest.save()
+
+ def draw_fan(self, dest):
+ c = (self.args.outer_radius + 1 )* cm
+ a = self.alpha
+ r_o = self.args.outer_radius
+ r_i = self.args.inner_radius
+
+ grp = dest.g()
+ grp.add(dest.circle(
+ center=(c, c),
+ r=r_o * cm,
+ ** LINE_STYLE
+ ))
+ grp.add(dest.circle(
+ center=(c, c),
+ r=r_i * cm,
+ ** LINE_STYLE
+ ))
+ grp.add(dest.line(
+ start=(c + r_i * cm, c),
+ end=(c + r_o * cm, c),
+ ** LINE_STYLE
+ ))
+ for i in range(1, self.sections):
+ grp.add(dest.line(
+ start=(
+ c + (math.cos(a * - i) * r_i) * cm,
+ c + (math.sin(a * - i) * r_i) * cm
+ ),
+ end=(
+ c + (math.cos(a * - i) * r_o) * cm,
+ c + (math.sin(a * - i) * r_o) * cm
+ ),
+ ** FOLD_LINE_STYLE
+ ))
+ grp.add(dest.line(
+ start=(
+ c + (math.cos(a * - self.sections) * r_i) * cm,
+ c + (math.sin(a * - self.sections) * r_i) * cm
+ ),
+ end=(
+ c + (math.cos(a * - self.sections) * r_o) * cm,
+ c + (math.sin(a * - self.sections) * r_o) * cm
+ ),
+ ** LINE_STYLE
+ ))
+ dest.add(grp)
+
+if __name__ == "__main__":
+ Fan().run()
diff --git a/source/misc/unclassified/paper_covered_fan/index.rst b/source/misc/unclassified/paper_covered_fan/index.rst
new file mode 100644
index 0000000..83e7af1
--- /dev/null
+++ b/source/misc/unclassified/paper_covered_fan/index.rst
@@ -0,0 +1,26 @@
+Paper Covered Fan
+=================
+
+.. figure::
+ :align: center
+
+.. only:: html
+
+ .. contents::
+
+
+Materials
+---------
+
+You need:
+
+* A fan
+
+
+Instructions
+------------
+
+
+See also
+--------
+