drawing-templates-generator 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: drawing-templates-generator
3
+ Version: 0.1.0
4
+ Summary: Generate drawing templates in PNG (for digital art) and PDF (to be printed)
5
+ Author-email: Iacchus <iacchus@users.noreply.github.com>
6
+ Project-URL: Homepage, https://github.com/iacchus/drawing-templates-generator
7
+ Project-URL: Repository, https://github.com/iacchus/drawing-templates-generator
8
+ Keywords: drawing,templates,loomis,png,pdf,art
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Multimedia :: Graphics
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: click
17
+ Requires-Dist: Wand
18
+
19
+ ## drawing-templates-generator
20
+
21
+ ### WAT
22
+
23
+ here are some examples
24
+
25
+ ```
26
+ ./drawing-templates-generator.py --square --columns 6
27
+ ```
28
+
29
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-000.png?raw=true)
30
+
31
+ ---
32
+
33
+ ```
34
+ ./drawing-templates-generator.py --circle --columns 8
35
+ ```
36
+
37
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-000.png?raw=true)
38
+
39
+ ---
40
+
41
+ ```
42
+ ./drawing-templates-generator.py --circle --columns 6 --dont-interlace --spacing 33
43
+ ```
44
+
45
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-001.png?raw=true)
46
+
47
+ ---
48
+
49
+ ```
50
+ ./drawing-templates-generator.py --square --columns 7 --spacing=0 --stroke-width 1 --stroke-color "#000000"
51
+ ```
52
+
53
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-001.png?raw=true)
54
+
55
+ ### dependencies
56
+
57
+ * python3 with pip
58
+ * python wand (and its dependencies)
59
+ * python click
60
+
61
+ ```
62
+ pip install wand click
63
+ ```
64
+ ### features
65
+
66
+ * generates a template with squares or circles (for Loomis' style heads)
67
+ * generates png, for digital art
68
+ * generates pdf, for printing the template
69
+ * pdf paper size can be changed via a set of predefined sizes
70
+ * colors can be changed (fill, outline and background)
71
+ * template's margin/padding can be changed
72
+
73
+ ### usage
74
+
75
+ ```
76
+ $ ./drawing-templates-generator.py --help
77
+
78
+ Usage: drawing-templates-generator.py [options]
79
+
80
+ Generate drawing templates in png (for digital art) and pdf (to be printed)
81
+
82
+ Options:
83
+ --width <width> Width for the generated png image [default:
84
+ 1200]
85
+ --height <height> Height for the generated png image [default:
86
+ 2000]
87
+ --spacing <spacing> Margin/padding between the shapes, in pixels
88
+ [default: 11]
89
+ --columns <num_of_cols> How many shapes to draw in a line [default: 6]
90
+ --page <page_type> Page format for pdf (see below) [default: a4]
91
+ --dpi <resolution> Resolution for the pdf document [default: 288]
92
+ --square [shape] Use squares as shape [default: square]
93
+ --circle [shape] Use circles as shape [default: square]
94
+ --dont-interlace [--circle only] Don't interlace when using
95
+ circles as shape; align all lines instead
96
+ --png [format] Generates a png image (for digital art)
97
+ [default: png]
98
+ --pdf [format] Generates a pdf document, useful for
99
+ printing [default: png]
100
+ --stroke-width <width> Width of the shapes' outline [default: 2]
101
+ --stroke-color <color> Color of the shapes' outline (see below)
102
+ [default: black]
103
+ --fill-color <color> Color to fill the shapes (see below) [default:
104
+ white]
105
+ --background-color <color> Background color of the page (see below)
106
+ [default: white]
107
+ --help Show this message and exit.
108
+
109
+ Generates a template given the options.
110
+
111
+ 'page' can be any of:
112
+
113
+ 4x6, 5x7, 7x9, 8x10, 9x11, 9x12, 10x13, 10x14, 11x17, 4A0, 2A0, a0, a1, a2,
114
+ a3, a4, a4small, a5, a6, a7, a8, a9, a10, archa, archb, archC, archd, arche,
115
+ b0, b1, b10, b2, b3, b4, b5, b6, b7, b8, b9, c0, c1, c2, c3, c4, c5, c6, c7,
116
+ csheet, dsheet, esheet, executive, flsa, flse, folio, halfletter, isob0,
117
+ isob1, isob10, isob2, isob3, isob4, isob5, isob6, isob7, isob8, isob9,
118
+ jisb0, jisb1, jisb2, jisb3, jisb4, jisb5, jisb6, ledger, legal, letter,
119
+ lettersmall, monarch, quarto, statement, tabloid
120
+
121
+ 'stroke-color', 'fill-color' and 'background-color' can be hexadecimal
122
+ "#xxxxxx" values or ImageMagick Color Names; these are described at:
123
+
124
+ https://imagemagick.org/script/color.php
125
+
126
+ <https://github.com/iacchus/drawing-templates-generator>
127
+ ```
@@ -0,0 +1,109 @@
1
+ ## drawing-templates-generator
2
+
3
+ ### WAT
4
+
5
+ here are some examples
6
+
7
+ ```
8
+ ./drawing-templates-generator.py --square --columns 6
9
+ ```
10
+
11
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-000.png?raw=true)
12
+
13
+ ---
14
+
15
+ ```
16
+ ./drawing-templates-generator.py --circle --columns 8
17
+ ```
18
+
19
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-000.png?raw=true)
20
+
21
+ ---
22
+
23
+ ```
24
+ ./drawing-templates-generator.py --circle --columns 6 --dont-interlace --spacing 33
25
+ ```
26
+
27
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-001.png?raw=true)
28
+
29
+ ---
30
+
31
+ ```
32
+ ./drawing-templates-generator.py --square --columns 7 --spacing=0 --stroke-width 1 --stroke-color "#000000"
33
+ ```
34
+
35
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-001.png?raw=true)
36
+
37
+ ### dependencies
38
+
39
+ * python3 with pip
40
+ * python wand (and its dependencies)
41
+ * python click
42
+
43
+ ```
44
+ pip install wand click
45
+ ```
46
+ ### features
47
+
48
+ * generates a template with squares or circles (for Loomis' style heads)
49
+ * generates png, for digital art
50
+ * generates pdf, for printing the template
51
+ * pdf paper size can be changed via a set of predefined sizes
52
+ * colors can be changed (fill, outline and background)
53
+ * template's margin/padding can be changed
54
+
55
+ ### usage
56
+
57
+ ```
58
+ $ ./drawing-templates-generator.py --help
59
+
60
+ Usage: drawing-templates-generator.py [options]
61
+
62
+ Generate drawing templates in png (for digital art) and pdf (to be printed)
63
+
64
+ Options:
65
+ --width <width> Width for the generated png image [default:
66
+ 1200]
67
+ --height <height> Height for the generated png image [default:
68
+ 2000]
69
+ --spacing <spacing> Margin/padding between the shapes, in pixels
70
+ [default: 11]
71
+ --columns <num_of_cols> How many shapes to draw in a line [default: 6]
72
+ --page <page_type> Page format for pdf (see below) [default: a4]
73
+ --dpi <resolution> Resolution for the pdf document [default: 288]
74
+ --square [shape] Use squares as shape [default: square]
75
+ --circle [shape] Use circles as shape [default: square]
76
+ --dont-interlace [--circle only] Don't interlace when using
77
+ circles as shape; align all lines instead
78
+ --png [format] Generates a png image (for digital art)
79
+ [default: png]
80
+ --pdf [format] Generates a pdf document, useful for
81
+ printing [default: png]
82
+ --stroke-width <width> Width of the shapes' outline [default: 2]
83
+ --stroke-color <color> Color of the shapes' outline (see below)
84
+ [default: black]
85
+ --fill-color <color> Color to fill the shapes (see below) [default:
86
+ white]
87
+ --background-color <color> Background color of the page (see below)
88
+ [default: white]
89
+ --help Show this message and exit.
90
+
91
+ Generates a template given the options.
92
+
93
+ 'page' can be any of:
94
+
95
+ 4x6, 5x7, 7x9, 8x10, 9x11, 9x12, 10x13, 10x14, 11x17, 4A0, 2A0, a0, a1, a2,
96
+ a3, a4, a4small, a5, a6, a7, a8, a9, a10, archa, archb, archC, archd, arche,
97
+ b0, b1, b10, b2, b3, b4, b5, b6, b7, b8, b9, c0, c1, c2, c3, c4, c5, c6, c7,
98
+ csheet, dsheet, esheet, executive, flsa, flse, folio, halfletter, isob0,
99
+ isob1, isob10, isob2, isob3, isob4, isob5, isob6, isob7, isob8, isob9,
100
+ jisb0, jisb1, jisb2, jisb3, jisb4, jisb5, jisb6, ledger, legal, letter,
101
+ lettersmall, monarch, quarto, statement, tabloid
102
+
103
+ 'stroke-color', 'fill-color' and 'background-color' can be hexadecimal
104
+ "#xxxxxx" values or ImageMagick Color Names; these are described at:
105
+
106
+ https://imagemagick.org/script/color.php
107
+
108
+ <https://github.com/iacchus/drawing-templates-generator>
109
+ ```
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "drawing-templates-generator"
7
+ dynamic = ["version"]
8
+ description = "Generate drawing templates in PNG (for digital art) and PDF (to be printed)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [
12
+ { name = "Iacchus", email = "iacchus@users.noreply.github.com" },
13
+ ]
14
+ keywords = ["drawing", "templates", "loomis", "png", "pdf", "art"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Environment :: Console",
18
+ "Intended Audience :: End Users/Desktop",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Multimedia :: Graphics",
21
+ ]
22
+ dependencies = [
23
+ "click",
24
+ "Wand",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/iacchus/drawing-templates-generator"
29
+ Repository = "https://github.com/iacchus/drawing-templates-generator"
30
+
31
+ [project.scripts]
32
+ drawing-templates-generator = "drawing_templates_generator.cli:generate_template"
33
+
34
+ [tool.setuptools.dynamic]
35
+ version = { attr = "drawing_templates_generator._version.__version__" }
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Drawing templates generator package."""
2
+
3
+ from ._version import __version__
4
+
5
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """Module entrypoint for ``python -m drawing_templates_generator``."""
2
+
3
+ from .cli import generate_template
4
+
5
+ if __name__ == "__main__":
6
+ generate_template()
@@ -0,0 +1,3 @@
1
+ """Package version."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,441 @@
1
+ import glob
2
+ import math
3
+ import os
4
+
5
+ import click
6
+
7
+ from wand.image import Image
8
+ from wand.image import PAPERSIZE_MAP
9
+ from wand.drawing import Drawing
10
+ from wand.color import Color
11
+
12
+ from ._version import __version__
13
+
14
+ DEBUG = True if os.environ.get("DEBUG") else False
15
+
16
+ def get_filename_number(filename):
17
+ filename_without_extension = filename.split(".")[0]
18
+ number = filename_without_extension.split("-")[1]
19
+
20
+ return number if number.isdecimal() else -1
21
+
22
+
23
+ def create_filename(prefix, extension):
24
+
25
+ if DEBUG:
26
+ filename = f"{prefix}-debug.{extension}"
27
+ return filename
28
+
29
+ filename_wildcard = f"{prefix}-*.{extension}"
30
+ files = glob.glob(filename_wildcard)
31
+ numbers = [int(get_filename_number(filename)) for filename in files]
32
+ next_number = 0
33
+ if numbers:
34
+ next_number = max(numbers) + 1
35
+ next_number_str = str(next_number).zfill(3)
36
+ filename = f"{prefix}-{next_number_str}.{extension}"
37
+ return filename
38
+
39
+
40
+ def get_line_size(square_size, spacing, equidistant):
41
+
42
+ if equidistant:
43
+ alpha_angle_degrees = 30
44
+ cosene = math.cos(math.radians(alpha_angle_degrees))
45
+ hypotenuse = square_size + spacing
46
+
47
+ # cos alpha = b/c
48
+ # b = c * cos alpha
49
+ line_size = hypotenuse * cosene
50
+
51
+ else:
52
+ line_size = square_size + spacing
53
+
54
+ return line_size
55
+
56
+
57
+ def get_square_geometry(x, y, spacing, square_size, dont_interlace,
58
+ equidistant):
59
+ line_size = get_line_size(square_size=square_size, spacing=spacing,
60
+ equidistant=equidistant)
61
+
62
+ interlacing_offset = (square_size/2) if (y % 2 == 0) \
63
+ and not dont_interlace else 0
64
+ left = spacing * x + (x-1)*square_size + interlacing_offset
65
+ if equidistant:
66
+ top = spacing + (y-1)*line_size
67
+ else:
68
+ if y == 1:
69
+ top = spacing
70
+ else:
71
+ top = spacing + (y-1) * line_size
72
+
73
+ right = spacing * x + interlacing_offset + (x)*square_size # FIXME: ioffset order
74
+ if equidistant:
75
+ bottom = spacing + (y)*line_size
76
+ else:
77
+ if y == 1:
78
+ bottom = spacing + square_size
79
+ else:
80
+ bottom = spacing + (y-1) * line_size + square_size
81
+
82
+ geometry = dict(
83
+ left=left,
84
+ top=top,
85
+ right=right,
86
+ bottom=bottom
87
+ )
88
+
89
+ return geometry
90
+
91
+
92
+ def get_circle_geometry(x, y, spacing, square_size, dont_interlace,
93
+ equidistant):
94
+ line_size = get_line_size(square_size=square_size, spacing=spacing,
95
+ equidistant=equidistant)
96
+
97
+ interlacing_offset = (square_size/2) if (y % 2 == 0) \
98
+ and not dont_interlace else 0
99
+ left = spacing * x + (x-1)*square_size + interlacing_offset
100
+ if equidistant:
101
+ top = spacing + (y-1)*line_size
102
+ top = spacing + (y-1)*line_size + 4 # FIXME: this +4
103
+ else:
104
+ top = spacing * y + (y-1)*square_size
105
+
106
+ origin_x = left + (square_size/2)
107
+ origin_y = top + (square_size/2)
108
+
109
+ perimeter_x = left + (square_size/2)
110
+ perimeter_y = top
111
+
112
+ geometry = dict(
113
+ origin=(origin_x, origin_y),
114
+ perimeter=(perimeter_x, perimeter_y)
115
+ )
116
+
117
+ return geometry
118
+
119
+
120
+ def get_square_size(page_size, spacing, columns):
121
+ outer_margin = spacing * 2
122
+ intermediary_total_padding = ((columns-1) * spacing)
123
+ spacing_total_size = outer_margin + intermediary_total_padding
124
+ square_total_size = page_size - spacing_total_size
125
+ square_size = square_total_size / columns
126
+
127
+ return square_size
128
+
129
+
130
+ def get_max_lines(page_height, spacing, line_size):
131
+ page_height_without_outer_margins = page_height - (spacing*2)
132
+ max_lines = int(page_height_without_outer_margins / line_size) # floor
133
+
134
+ return max_lines
135
+
136
+
137
+ def draw_and_write(width, height, spacing, columns, resolution, shape,
138
+ dont_interlace, file_format, stroke_width, stroke_color,
139
+ fill_color, background_color, equidistant, filename,
140
+ footer):
141
+
142
+ with Drawing() as draw:
143
+ draw.fill_color = fill_color
144
+ draw.stroke_color = stroke_color
145
+ draw.stroke_width = stroke_width
146
+
147
+ square_size = get_square_size(page_size=width, spacing=spacing,
148
+ columns=columns)
149
+
150
+ line_size = get_line_size(square_size, spacing, equidistant)
151
+
152
+ lines = get_max_lines(page_height=height, spacing=spacing,
153
+ line_size=line_size)
154
+
155
+ squares = [(x+1, y+1) for x in range(columns) for y in range(lines)]
156
+
157
+ for square_x, square_y in squares:
158
+ square_data = dict(x=square_x,
159
+ y=square_y,
160
+ spacing=spacing,
161
+ square_size=square_size)
162
+
163
+ if shape == "square":
164
+ if ((square_y % 2) == 0) and ((square_x) == columns) \
165
+ and not dont_interlace:
166
+ continue
167
+ square_geometry = get_square_geometry(**square_data,
168
+ dont_interlace=dont_interlace,
169
+ equidistant=equidistant)
170
+ draw.rectangle(**square_geometry)
171
+
172
+ elif shape == "circle":
173
+ if ((square_y % 2) == 0) and ((square_x) == columns) \
174
+ and not dont_interlace:
175
+ continue
176
+ circle_geometry = get_circle_geometry(**square_data,
177
+ dont_interlace=dont_interlace,
178
+ equidistant=equidistant)
179
+ if DEBUG:
180
+ square_geometry = get_square_geometry(**square_data,
181
+ dont_interlace=dont_interlace,
182
+ equidistant=equidistant)
183
+ draw.rectangle(**square_geometry)
184
+ draw.circle(**circle_geometry) # origin, perimeter
185
+
186
+ with Image(width=width,
187
+ height=height,
188
+ background=background_color,
189
+ resolution=resolution) as image:
190
+ draw(image)
191
+
192
+ if filename == "":
193
+ filename = create_filename(prefix=shape, extension=file_format)
194
+ # else filename = filename
195
+
196
+ image.save(filename=filename)
197
+ if os.path.isfile(filename):
198
+ print("Created", file_format, "file", filename)
199
+ else:
200
+ print("Error creating", filename)
201
+
202
+
203
+ width_option = click.option("--width",
204
+ type=int,
205
+ default=1200,
206
+ metavar="<width>",
207
+ show_default=True,
208
+ help="Width for the generated png image")
209
+
210
+ height_option = click.option("--height",
211
+ type=int,
212
+ default=2000,
213
+ metavar="<height>",
214
+ show_default=True,
215
+ help="Height for the generated png image")
216
+
217
+ spacing_option = click.option("--spacing",
218
+ type=int,
219
+ default=11,
220
+ metavar="<spacing>",
221
+ show_default=True,
222
+ help="Margin/padding between the shapes, "
223
+ "in pixels")
224
+
225
+ columns_option = click.option("--columns",
226
+ type=int,
227
+ default=6,
228
+ metavar="<num_of_cols>",
229
+ show_default=True,
230
+ help="How many shapes to draw in a line")
231
+
232
+ page_option = click.option("--page",
233
+ type=str,
234
+ default="a4",
235
+ metavar="<page_type>",
236
+ show_default=True,
237
+ help="Page format for pdf "
238
+ "(see below)") # "a4" etc... type is Choice
239
+
240
+ dpi_option = click.option("--dpi",
241
+ type=int,
242
+ default=288,
243
+ metavar="<resolution>",
244
+ show_default=True,
245
+ help="Resolution for the pdf "
246
+ "document") # 72, 288 etc
247
+
248
+ square_option = click.option("--square",
249
+ "shape",
250
+ is_flag=True,
251
+ flag_value="square",
252
+ default="square",
253
+ show_default=True,
254
+ help="[shape] Use squares as shape")
255
+
256
+ dont_interlace_option = click.option("--dont-interlace", "dont_interlace_flag",
257
+ is_flag=True,
258
+ flag_value=True,
259
+ default=False,
260
+ show_default=False,
261
+ help="[--circle only] Don't interlace when using "
262
+ "circles as shape; align all lines instead")
263
+
264
+ equidistant_option = click.option("--equidistant", "equidistant_flag",
265
+ is_flag=True,
266
+ flag_value=True,
267
+ # flag_value=True,
268
+ default=False,
269
+ show_default=False,
270
+ help="[--circle only] Make circles' origins "
271
+ "equidistant with the line below.")
272
+ # equidistant_option = click.option("--equidistant", "equidistant_flag",
273
+ # type=click.Choice(BoolAuto, case_sensitive=False),
274
+ # is_flag=True,
275
+ # flag_value=BoolAuto.TRUE,
276
+ # # flag_value=True,
277
+ # default=BoolAuto.AUTO,
278
+ # show_default=False,
279
+ # help="[--circle only] Make circles' origins "
280
+ # "equidistant with the line below.")
281
+ #
282
+ circle_option = click.option("--circle",
283
+ "shape",
284
+ is_flag=True,
285
+ flag_value="circle",
286
+ show_default=True,
287
+ help="[shape] Use circles as shape")
288
+
289
+ png_option = click.option("--png",
290
+ "file_format",
291
+ is_flag=True,
292
+ flag_value="png",
293
+ default="png",
294
+ show_default=True,
295
+ help="[format] Generates a png image "
296
+ "(for digital art)")
297
+
298
+ pdf_option = click.option("--pdf",
299
+ "file_format",
300
+ is_flag=True,
301
+ flag_value="pdf",
302
+ show_default=True,
303
+ help="[format] Generates a pdf document, "
304
+ "useful for printing")
305
+
306
+ fill_color_option = click.option("--fill-color",
307
+ type=str,
308
+ default="white",
309
+ metavar="<color>",
310
+ show_default=True,
311
+ help="Color to fill the shapes (see below)"
312
+ )
313
+
314
+ stroke_color_option = click.option("--stroke-color",
315
+ type=str,
316
+ default="black",
317
+ metavar="<color>",
318
+ show_default=True,
319
+ help="Color of the shapes' outline "
320
+ "(see below)")
321
+
322
+ background_color_option = click.option("--background-color",
323
+ type=str,
324
+ default="white",
325
+ metavar="<color>",
326
+ show_default=True,
327
+ help="Background color of the page "
328
+ "(see below)")
329
+
330
+ stroke_width_option = click.option("--stroke-width",
331
+ type=int,
332
+ default=2,
333
+ metavar="<width>",
334
+ show_default=True,
335
+ help="Width of the shapes' outline")
336
+
337
+ filename_option = click.option("--filename",
338
+ type=str,
339
+ default="",
340
+ metavar="<filename>",
341
+ show_default=False,
342
+ help="Choose a filename different from the "
343
+ "default one.")
344
+
345
+ footer_option = click.option("--footer",
346
+ is_flag=True,
347
+ flag_value=True,
348
+ show_default=True,
349
+ default=False,
350
+ help="Show footer")
351
+ epilog = f"""\
352
+ Generates a template given the options.
353
+
354
+ 'page' can be any of:
355
+
356
+ {', '.join(PAPERSIZE_MAP.keys())}
357
+
358
+ 'stroke-color', 'fill-color' and 'background-color' can be hexadecimal \
359
+ "#xxxxxx"
360
+ values or ImageMagick Color Names; these are described at:
361
+
362
+ https://imagemagick.org/script/color.php
363
+
364
+ <https://github.com/iacchus/drawing-templates-generator>
365
+ """
366
+
367
+ @click.command(help="Generate drawing templates in png (for digital art)"
368
+ " and pdf (to be printed)",
369
+ epilog=epilog,
370
+ short_help="sht hlp",
371
+ options_metavar="[options]",
372
+ no_args_is_help=False)
373
+ @click.version_option(version=__version__)
374
+ @width_option
375
+ @height_option
376
+ @spacing_option
377
+ @columns_option
378
+ @page_option
379
+ @dpi_option
380
+ @square_option
381
+ @circle_option
382
+ @dont_interlace_option
383
+ @equidistant_option
384
+ @png_option
385
+ @pdf_option
386
+ @stroke_width_option
387
+ @stroke_color_option
388
+ @fill_color_option
389
+ @background_color_option
390
+ @filename_option
391
+ @footer_option
392
+ def generate_template(width, height, spacing, columns, page, dpi, shape,
393
+ dont_interlace_flag, file_format, stroke_width, stroke_color,
394
+ fill_color, background_color, equidistant_flag, filename,
395
+ footer):
396
+ resolution_factor = dpi / 72
397
+
398
+ dont_interlace = bool()
399
+ if not dont_interlace_flag:
400
+ if shape == "square":
401
+ dont_interlace = True
402
+ elif shape == "circle":
403
+ dont_interlace = False
404
+ else:
405
+ dont_interlace = True
406
+
407
+ equidistant = bool()
408
+ if not equidistant_flag:
409
+ if shape == "square":
410
+ equidistant = False
411
+ elif shape == "circle":
412
+ equidistant = True
413
+ else:
414
+ equidistant = True # FIXME
415
+ # equidistant = False # FIXME
416
+
417
+
418
+ if file_format == "pdf":
419
+ page_w, page_h = PAPERSIZE_MAP[page] # this size is for 72dpi
420
+ width = int(page_w * resolution_factor)
421
+ height = int(page_h * resolution_factor)
422
+
423
+ draw_and_write(width=width,
424
+ height=height,
425
+ spacing=spacing,
426
+ columns=columns,
427
+ resolution=dpi,
428
+ shape=shape,
429
+ dont_interlace=dont_interlace,
430
+ equidistant=equidistant,
431
+ file_format=file_format,
432
+ stroke_width=stroke_width,
433
+ stroke_color=Color(stroke_color),
434
+ fill_color=Color(fill_color),
435
+ background_color=Color(background_color),
436
+ filename=filename,
437
+ footer=footer)
438
+
439
+
440
+ if __name__ == "__main__":
441
+ generate_template()
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: drawing-templates-generator
3
+ Version: 0.1.0
4
+ Summary: Generate drawing templates in PNG (for digital art) and PDF (to be printed)
5
+ Author-email: Iacchus <iacchus@users.noreply.github.com>
6
+ Project-URL: Homepage, https://github.com/iacchus/drawing-templates-generator
7
+ Project-URL: Repository, https://github.com/iacchus/drawing-templates-generator
8
+ Keywords: drawing,templates,loomis,png,pdf,art
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Multimedia :: Graphics
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: click
17
+ Requires-Dist: Wand
18
+
19
+ ## drawing-templates-generator
20
+
21
+ ### WAT
22
+
23
+ here are some examples
24
+
25
+ ```
26
+ ./drawing-templates-generator.py --square --columns 6
27
+ ```
28
+
29
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-000.png?raw=true)
30
+
31
+ ---
32
+
33
+ ```
34
+ ./drawing-templates-generator.py --circle --columns 8
35
+ ```
36
+
37
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-000.png?raw=true)
38
+
39
+ ---
40
+
41
+ ```
42
+ ./drawing-templates-generator.py --circle --columns 6 --dont-interlace --spacing 33
43
+ ```
44
+
45
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/circle-001.png?raw=true)
46
+
47
+ ---
48
+
49
+ ```
50
+ ./drawing-templates-generator.py --square --columns 7 --spacing=0 --stroke-width 1 --stroke-color "#000000"
51
+ ```
52
+
53
+ ![](https://github.com/iacchus/drawing-templates-generator/blob/main/square-001.png?raw=true)
54
+
55
+ ### dependencies
56
+
57
+ * python3 with pip
58
+ * python wand (and its dependencies)
59
+ * python click
60
+
61
+ ```
62
+ pip install wand click
63
+ ```
64
+ ### features
65
+
66
+ * generates a template with squares or circles (for Loomis' style heads)
67
+ * generates png, for digital art
68
+ * generates pdf, for printing the template
69
+ * pdf paper size can be changed via a set of predefined sizes
70
+ * colors can be changed (fill, outline and background)
71
+ * template's margin/padding can be changed
72
+
73
+ ### usage
74
+
75
+ ```
76
+ $ ./drawing-templates-generator.py --help
77
+
78
+ Usage: drawing-templates-generator.py [options]
79
+
80
+ Generate drawing templates in png (for digital art) and pdf (to be printed)
81
+
82
+ Options:
83
+ --width <width> Width for the generated png image [default:
84
+ 1200]
85
+ --height <height> Height for the generated png image [default:
86
+ 2000]
87
+ --spacing <spacing> Margin/padding between the shapes, in pixels
88
+ [default: 11]
89
+ --columns <num_of_cols> How many shapes to draw in a line [default: 6]
90
+ --page <page_type> Page format for pdf (see below) [default: a4]
91
+ --dpi <resolution> Resolution for the pdf document [default: 288]
92
+ --square [shape] Use squares as shape [default: square]
93
+ --circle [shape] Use circles as shape [default: square]
94
+ --dont-interlace [--circle only] Don't interlace when using
95
+ circles as shape; align all lines instead
96
+ --png [format] Generates a png image (for digital art)
97
+ [default: png]
98
+ --pdf [format] Generates a pdf document, useful for
99
+ printing [default: png]
100
+ --stroke-width <width> Width of the shapes' outline [default: 2]
101
+ --stroke-color <color> Color of the shapes' outline (see below)
102
+ [default: black]
103
+ --fill-color <color> Color to fill the shapes (see below) [default:
104
+ white]
105
+ --background-color <color> Background color of the page (see below)
106
+ [default: white]
107
+ --help Show this message and exit.
108
+
109
+ Generates a template given the options.
110
+
111
+ 'page' can be any of:
112
+
113
+ 4x6, 5x7, 7x9, 8x10, 9x11, 9x12, 10x13, 10x14, 11x17, 4A0, 2A0, a0, a1, a2,
114
+ a3, a4, a4small, a5, a6, a7, a8, a9, a10, archa, archb, archC, archd, arche,
115
+ b0, b1, b10, b2, b3, b4, b5, b6, b7, b8, b9, c0, c1, c2, c3, c4, c5, c6, c7,
116
+ csheet, dsheet, esheet, executive, flsa, flse, folio, halfletter, isob0,
117
+ isob1, isob10, isob2, isob3, isob4, isob5, isob6, isob7, isob8, isob9,
118
+ jisb0, jisb1, jisb2, jisb3, jisb4, jisb5, jisb6, ledger, legal, letter,
119
+ lettersmall, monarch, quarto, statement, tabloid
120
+
121
+ 'stroke-color', 'fill-color' and 'background-color' can be hexadecimal
122
+ "#xxxxxx" values or ImageMagick Color Names; these are described at:
123
+
124
+ https://imagemagick.org/script/color.php
125
+
126
+ <https://github.com/iacchus/drawing-templates-generator>
127
+ ```
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/drawing_templates_generator/__init__.py
4
+ src/drawing_templates_generator/__main__.py
5
+ src/drawing_templates_generator/_version.py
6
+ src/drawing_templates_generator/cli.py
7
+ src/drawing_templates_generator.egg-info/PKG-INFO
8
+ src/drawing_templates_generator.egg-info/SOURCES.txt
9
+ src/drawing_templates_generator.egg-info/dependency_links.txt
10
+ src/drawing_templates_generator.egg-info/entry_points.txt
11
+ src/drawing_templates_generator.egg-info/requires.txt
12
+ src/drawing_templates_generator.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ drawing-templates-generator = drawing_templates_generator.cli:generate_template