Copyright | (c) Chris Reade 2021 |
---|---|
License | BSD-style |
Maintainer | chrisreade@mac.com |
Stability | experimental |
Safe Haskell | None |
Language | GHC2021 |
TileLibP3
Description
This module introduces Penrose's P3 tilings (narrow and wide rhombuses). It includes P3_HalfTiles, P3_Pieces and P3_Patches to represent and draw rhombuses plus conversion to and from Darts and Kites (the P2 tiles). A class P3_Drawable is introduced with instance P3_Patch, Patch, VPatch, Tgraph and generalised drawing functions for drawing P3 tilings.
Synopsis
- data P3_HalfTile a
- tileRepP3 :: P3_HalfTile a -> a
- type P3_Piece = P3_HalfTile (V2 Double)
- decompPieceP2toP3 :: Located Piece -> [Located P3_Piece]
- decompPieceP3toP2 :: Located P3_Piece -> [Located Piece]
- type P3_Patch = [Located P3_Piece]
- decompP2toP3 :: Patch -> P3_Patch
- decompP3toP2 :: P3_Patch -> Patch
- drawPieceP3 :: OKBackend b => P3_Piece -> Diagram b
- drawjPieceP3 :: OKBackend b => P3_Piece -> Diagram b
- fillOnlyPieceP3 :: (OKBackend b, Color c) => c -> P3_Piece -> Diagram b
- fillOnlyPieceWN :: (OKBackend b, Color cw, Color cn) => cw -> cn -> P3_Piece -> Diagram b
- fillPieceWN :: (OKBackend b, Color cw, Color cn) => cw -> cn -> P3_Piece -> Diagram b
- class P3_Drawable a where
- drawP3With :: OKBackend b => (P3_Piece -> Diagram b) -> a -> Diagram b
- drawP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b
- drawjP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b
- dashjP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b
- fillWN :: (OKBackend b, P3_Drawable a, Color cw, Color cn) => cw -> cn -> a -> Diagram b
- fillNW :: (OKBackend b, P3_Drawable a, Color cw, Color cn) => cw -> cn -> a -> Diagram b
- class P3_DrawableLabelled a where
- labelSizeP3 :: (OKBackend b, P3_DrawableLabelled a) => Measure Double -> (P3_Patch -> Diagram b) -> a -> Diagram b
- labelledP3 :: (OKBackend b, P3_DrawableLabelled a) => (P3_Patch -> Diagram b) -> a -> Diagram b
P3_HalfTiles
data P3_HalfTile a Source #
Penrose P3 Tiling uses wide and narrow rhombuses These are split into half tiles (triangles) as with kites and darts
Constructors
LW a | Left Wide Rhombus |
RW a | Right Wide Rhombus |
LN a | Left Narrow Rhombus |
RN a | Right Narrow Rhombus |
Instances
P3_Drawable P3_Patch Source # | A P3_Patch is P3_Drawable. |
Functor P3_HalfTile Source # | Make P3_Halftile a Functor |
Defined in TileLibP3 Methods fmap :: (a -> b) -> P3_HalfTile a -> P3_HalfTile b # (<$) :: a -> P3_HalfTile b -> P3_HalfTile a # | |
Show a => Show (P3_HalfTile a) Source # | |
Defined in TileLibP3 Methods showsPrec :: Int -> P3_HalfTile a -> ShowS # show :: P3_HalfTile a -> String # showList :: [P3_HalfTile a] -> ShowS # | |
Transformable a => Transformable (P3_HalfTile a) Source # | P3_HalfTile inherits Transformable - Requires FlexibleInstances |
Defined in TileLibP3 Methods transform :: Transformation (V (P3_HalfTile a)) (N (P3_HalfTile a)) -> P3_HalfTile a -> P3_HalfTile a # | |
Eq a => Eq (P3_HalfTile a) Source # | |
Defined in TileLibP3 Methods (==) :: P3_HalfTile a -> P3_HalfTile a -> Bool # (/=) :: P3_HalfTile a -> P3_HalfTile a -> Bool # | |
type N (P3_HalfTile a) Source # | Needed for Transformable instance of P3_HalfTile - requires TypeFamilies |
Defined in TileLibP3 | |
type V (P3_HalfTile a) Source # | Needed for Transformable instance of P3_HalfTile - requires TypeFamilies |
Defined in TileLibP3 |
tileRepP3 :: P3_HalfTile a -> a Source #
tileRepP3 produces the representation without the label (LW,RW,LN,RN)
P3_Pieces
type P3_Piece = P3_HalfTile (V2 Double) Source #
A P3_Piece is a P3_Halftile with a vector along its join edge. The vector for a wide rhombus is on the long diagonal, and the vector for a narrow rhombus is along the short diagonal. The choice of which vertex is the origin is derived from conversions from Darts and Kites (P2 tilings)
Converting (located) Pieces
decompPieceP2toP3 :: Located Piece -> [Located P3_Piece] Source #
Converting from P2 to P3 tilings. Half darts become half wide rhombuses (LD->RW,RD->LW). (The new origin is the dart wing, and the new join is the dart long edge.) Half kites are decomposed to a half wide and a half narrow rhombus. (For wide rhombuses, the new origin is the kite origin and the join is the kite long edge.) (For narrow rhombuses, the new origin is the kite opp and the join is toward the kite origin.)
decompPieceP3toP2 :: Located P3_Piece -> [Located Piece] Source #
Converting from P3 to P2 tilings. Half narrow rhombuses become half kites (but the origin vertex and join edge are changed). Half wide rhombuses are decomposed to a half dart and a half kite.
Converting Patches
type P3_Patch = [Located P3_Piece] Source #
a P3_Patch is analagous to a Patch (but for for P3_Pieces)
decompP2toP3 :: Patch -> P3_Patch Source #
Conversion from a Patch to a P3_Patch (Kites and Darts to Rhombuses)
decompP3toP2 :: P3_Patch -> Patch Source #
Conversion from a P3_Patch to a Patch (Rhombuses to Kites and Darts) Note this does not reverse decompP2toP3, but the combination decompP3toP2 . decompP2toP3 is equivalent to a decompose operation (decompPatch)
Drawing P3_Pieces
drawjPieceP3 :: OKBackend b => P3_Piece -> Diagram b Source #
Draws all edges of a P3_Piece using a faint dashed line for the join edge
fillOnlyPieceP3 :: (OKBackend b, Color c) => c -> P3_Piece -> Diagram b Source #
Fills a P3_Piece with a colour (without drawn edges)
fillOnlyPieceWN :: (OKBackend b, Color cw, Color cn) => cw -> cn -> P3_Piece -> Diagram b Source #
Fills a P3_Piece with one of 2 colours (but no drawn edges). The first colour is used for wide rhombuses, and the second for narrow rhombuses. (Note the order WN)
fillPieceWN :: (OKBackend b, Color cw, Color cn) => cw -> cn -> P3_Piece -> Diagram b Source #
Fills and draws a P3_Piece with one of 2 colours The first colour is used for wide rhombuses, and the second for narrow rhombuses. (Note the order WN)
P3_Drawable Class
class P3_Drawable a where Source #
A class for things that can be turned to diagrams when given a function to draw P3_Pieces.
Instances
P3_Drawable Tgraph Source # | A Tgraph is P3_Drawable. |
P3_Drawable VPatch Source # | A VPatch is P3_Drawable. |
P3_Drawable Patch Source # | A Patch is also P3_Drawable (by conversion to a P3_Patch). |
P3_Drawable P3_Patch Source # | A P3_Patch is P3_Drawable. |
Drawing functions producing P3 Rhombuses
drawP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b Source #
The main drawing function for anything P3_Drawable
drawjP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b Source #
An alternative drawing function for anything P3_Drawable adding dashed lines for join edges
dashjP3 :: (OKBackend b, P3_Drawable a) => a -> Diagram b Source #
Deprecated: Replaced by drawjP3
Deprecated (renamed as drawjP3)
fillWN :: (OKBackend b, P3_Drawable a, Color cw, Color cn) => cw -> cn -> a -> Diagram b Source #
The main draw and fill function for anything P3_Drawable. The first colour is used for wide rhombuses, and the second for narrow rhombuses. (Note the order W N).
fillNW :: (OKBackend b, P3_Drawable a, Color cw, Color cn) => cw -> cn -> a -> Diagram b Source #
A variation on fillWN where the first colour is for narrow rhombuses, the second for wide rhombuses. (Note the order N W).
P3_DrawableLabelled Class
class P3_DrawableLabelled a where Source #
A class for things that can be drawn (P3 style) with labels when given a colour and a measure (size) for the labels and a a draw function (for P3_Patches). So labelColourSizeP3 c m modifies a P3_Patch drawing function to add labels (of colour c and size measure m). Measures are defined in Diagrams. In particular: tiny, verySmall, small, normal, large, veryLarge, huge.
Methods
labelColourSizeP3 :: OKBackend b => Colour Double -> Measure Double -> (P3_Patch -> Diagram b) -> a -> Diagram b Source #
Instances
P3_DrawableLabelled Tgraph Source # | Tgraphs can be drawn (Rhombus/P3 style) with labels NB: the additional vertices for P3 are only added when drawing and are not part of the Tgraph or its VPatch. Thus using such a vertex for alignment will raise an error. |
P3_DrawableLabelled VPatch Source # | VPatches can be drawn (Rhombus/P3 style) with labels NB: the additional vertices for P3 are only added when drawing and are not part of the VPatch. Thus using such a vertex for alignment will raise an error. |
Adding labels to functions producing P3 Rhombuses
labelSizeP3 :: (OKBackend b, P3_DrawableLabelled a) => Measure Double -> (P3_Patch -> Diagram b) -> a -> Diagram b Source #
Default Version of labelColourSizeP3 with colour red. Example usage: labelSizeP3 tiny drawP3 a , labelSizeP3 normal drawjP3 a
labelledP3 :: (OKBackend b, P3_DrawableLabelled a) => (P3_Patch -> Diagram b) -> a -> Diagram b Source #
Default Version of labelColourSizeP3 using red and small (rather than normal label size). Example usage: labelledP3 drawP3 a , labelledP3 drawjP3 a