flexagon-toolkit.git
3 years agoREADME.md: mention also the tetraflexagon example master
Antonio Ospite [Thu, 28 Jun 2018 14:58:00 +0000 (16:58 +0200)]
README.md: mention also the tetraflexagon example

3 years agoTODO: remove the item about flexagon "backfaces", they are showed now
Antonio Ospite [Thu, 28 Jun 2018 14:53:12 +0000 (16:53 +0200)]
TODO: remove the item about flexagon "backfaces", they are showed now

3 years agosvg_hexaflexagon_editor: coding style fixes
Antonio Ospite [Thu, 28 Jun 2018 14:46:16 +0000 (16:46 +0200)]
svg_hexaflexagon_editor: coding style fixes

Make some lines shorter.

3 years agoinkscape-hexaflexagon-editor.svg: update the hexaflexagon example
Antonio Ospite [Thu, 28 Jun 2018 13:42:07 +0000 (15:42 +0200)]
inkscape-hexaflexagon-editor.svg: update the hexaflexagon example

3 years agosvg_hexaflexagon_editor: draw also the backfaces
Antonio Ospite [Thu, 28 Jun 2018 11:35:51 +0000 (13:35 +0200)]
svg_hexaflexagon_editor: draw also the backfaces

Draw also the hexagons backfaces, to make it easier to visualize the
symmetry when folding the flexagon.

3 years agoinkscape-tetraflexagon-editor.svg: update the tetraflexagon example
Antonio Ospite [Thu, 28 Jun 2018 13:28:38 +0000 (15:28 +0200)]
inkscape-tetraflexagon-editor.svg: update the tetraflexagon example

3 years agosvg_tetraflexagon_editor: draw also the backface
Antonio Ospite [Wed, 27 Jun 2018 18:39:36 +0000 (20:39 +0200)]
svg_tetraflexagon_editor: draw also the backface

One of the faces also have a backface, draw it to make it easier to
visualize how it will look like when folding the flexagon.

3 years agotetraflexagon_diagram: add a function to calculate the tile offset in a square
Antonio Ospite [Wed, 27 Jun 2018 18:19:10 +0000 (20:19 +0200)]
tetraflexagon_diagram: add a function to calculate the tile offset in a square

3 years agotetraflexagon_diagram: do not use a fill_color for the template tiles
Antonio Ospite [Wed, 27 Jun 2018 18:03:19 +0000 (20:03 +0200)]
tetraflexagon_diagram: do not use a fill_color for the template tiles

Pass fill_color=None when drawing the template to make it only
a wireframe reference, as it is done for the hexaflexagon case.

This also makes the result more usable as the user is able to view the
content layers more clearly without filled squares on top.

3 years agodiagram: fix a typo in a comment s/con/cos/
Antonio Ospite [Wed, 27 Jun 2018 18:02:30 +0000 (20:02 +0200)]
diagram: fix a typo in a comment s/con/cos/

3 years agodiagram: share the rotate-translate calculation in the generic diagram class
Antonio Ospite [Wed, 27 Jun 2018 18:00:05 +0000 (20:00 +0200)]
diagram: share the rotate-translate calculation in the generic diagram class

Move the calculation of the rotate-translate transformation matrix into
the generic diagram class, so that it can be shared.

3 years ago{hexa,tetra}flexagon_diagram: fix typos in comments
Antonio Ospite [Wed, 27 Jun 2018 16:02:52 +0000 (18:02 +0200)]
{hexa,tetra}flexagon_diagram: fix typos in comments

3 years agosvg_tetraflexagon_editor: fix comment
Antonio Ospite [Wed, 27 Jun 2018 15:38:47 +0000 (17:38 +0200)]
svg_tetraflexagon_editor: fix comment

The comment was copied from the Hexaflexagon example, but here the tiles
are rectangles, not polygons, amend the comment to reflect that.

3 years agosvg_tetraflexagon_editor: remove duplicate code
Antonio Ospite [Wed, 27 Jun 2018 15:37:46 +0000 (17:37 +0200)]
svg_tetraflexagon_editor: remove duplicate code

3 years agosvg_tetraflexagon_editor.py: fix coding style
Antonio Ospite [Wed, 27 Jun 2018 14:08:15 +0000 (16:08 +0200)]
svg_tetraflexagon_editor.py: fix coding style

Add an expected blank line between a class and a function, reported by
pycodestyle:

  $ pycodestyle svg_tetraflexagon_editor.py
  svg_tetraflexagon_editor.py:117:1: E302 expected 2 blank lines, found 1

3 years agotrihexaflexagon: improve get_angle_in_plan_relative_to_hexagon()
Antonio Ospite [Wed, 27 Jun 2018 13:23:47 +0000 (15:23 +0200)]
trihexaflexagon: improve get_angle_in_plan_relative_to_hexagon()

Instead of doing some arcane calculation, do what the function is meant
to do: calculate an angle relative to another angle..

This also makes the code more robust in the case the calculation of the
other angles should change for some reason.

Leave the explicit formula in the comment as documentation.

3 years agotrihexaflexagon: clarify the formula in get_angle_in_plan_relative_to_hexagon()
Antonio Ospite [Thu, 28 Jun 2018 10:42:08 +0000 (12:42 +0200)]
trihexaflexagon: clarify the formula in get_angle_in_plan_relative_to_hexagon()

Write the formula in a clearer way and explain the meaning of the
integer division.

3 years agoChange how a trihexaflexagon is drawn
Antonio Ospite [Wed, 27 Jun 2018 13:48:35 +0000 (15:48 +0200)]
Change how a trihexaflexagon is drawn

Change how a trihexaflexagon is drawn to obtain a hexaflexagon more
aligned with conventions used elsewhere.

Now the hexagons are drawn with a "vertical orientation", opposed to the
previous horizontal one where they looked like they were laying on the
x axis.

This shows more clearly that the triangles are grouped in couples and
these couples only change orientation on one axis when shown on the
"opposite" face.

To have a clearer view of hat that means take a look at "The symmetry
within the trihexaflexagon, with Simon Pampena":
https://www.youtube.com/watch?v=NBJrGbbxceU

3 years agotetraflexagon_diagram: fix typo
Antonio Ospite [Wed, 27 Jun 2018 15:34:09 +0000 (17:34 +0200)]
tetraflexagon_diagram: fix typo

The function is called calc_angle_in_plan().

3 years agohexaflexagon_diagram: reuse get_triangle_center_in_plan()
Antonio Ospite [Wed, 27 Jun 2018 13:05:06 +0000 (15:05 +0200)]
hexaflexagon_diagram: reuse get_triangle_center_in_plan()

Reuse get_triangle_center_in_plan() also in draw_plan_template() instead
of open coding the calculations.

3 years agoAdd an example to show how Inkscape can be used as a tetraflexagon editor
Antonio Ospite [Wed, 27 Jun 2018 10:07:51 +0000 (12:07 +0200)]
Add an example to show how Inkscape can be used as a tetraflexagon editor

3 years agoAdd support for tetraflexagons
Antonio Ospite [Wed, 27 Jun 2018 09:31:05 +0000 (11:31 +0200)]
Add support for tetraflexagons

3 years agosvgwrite_diagram: add a test function
Antonio Ospite [Tue, 26 Jun 2018 14:18:31 +0000 (16:18 +0200)]
svgwrite_diagram: add a test function

Add a test function similar to the one used in the cairo backend.

Add also the same workaround to handle local includes in python2.

3 years agosvgwrite_diagram: return "something" from draw_centered_text()
Antonio Ospite [Tue, 26 Jun 2018 14:15:36 +0000 (16:15 +0200)]
svgwrite_diagram: return "something" from draw_centered_text()

Add a quick and dirty way to advance text when calling
draw_centered_text() just for consistency with the cairo backend.

The return value is just a rough estimate, it does not consider the
particular font in use.

3 years agocairo_diagram: save a file when generating the test diagram
Antonio Ospite [Tue, 26 Jun 2018 14:14:29 +0000 (16:14 +0200)]
cairo_diagram: save a file when generating the test diagram

3 years agodiagram: factor out a generic drawing test
Antonio Ospite [Tue, 26 Jun 2018 14:02:35 +0000 (16:02 +0200)]
diagram: factor out a generic drawing test

Factor out from cairo_diagram.py some code which draws a test diagram
and put it into diagram.py

3 years agosvgwrite_diagram: implement draw_circle, draw_line and draw_rect
Antonio Ospite [Tue, 26 Jun 2018 13:49:50 +0000 (15:49 +0200)]
svgwrite_diagram: implement draw_circle, draw_line and draw_rect

Complete the implementation of the svgwrite diagram backend by
implementing the missing methods.

3 years agosvgwrite_diagram: proper support for stroke_width
Antonio Ospite [Tue, 26 Jun 2018 13:46:14 +0000 (15:46 +0200)]
svgwrite_diagram: proper support for stroke_width

Support stroke_width for all drawing operations that call the _stroke()
method, and remove ad-hoc support for draw_polygon_by_verts() and
draw_star_by_verts()

3 years agosvgwrite_diagram: implement the clear() method
Antonio Ospite [Tue, 26 Jun 2018 13:45:24 +0000 (15:45 +0200)]
svgwrite_diagram: implement the clear() method

3 years agodiagram: move draw_rect_from_center to the generic Diagram class
Antonio Ospite [Tue, 26 Jun 2018 13:42:26 +0000 (15:42 +0200)]
diagram: move draw_rect_from_center to the generic Diagram class

Move draw_rect_from_center from cairo_diagram.py to diagram.py as it
does not depend on any specific backend.

3 years agoTODO: mention that showing the "wrong" faces could be useful too
Antonio Ospite [Wed, 4 Apr 2018 10:50:25 +0000 (12:50 +0200)]
TODO: mention that showing the "wrong" faces could be useful too

3 years agoAdd an example to show how Inkscape can be used as a flexagon editor
Antonio Ospite [Tue, 30 Jan 2018 11:18:15 +0000 (12:18 +0100)]
Add an example to show how Inkscape can be used as a flexagon editor

3 years agoInitial import
Antonio Ospite [Mon, 29 Jan 2018 14:31:26 +0000 (15:31 +0100)]
Initial import