Package micycle.pgs

Class PGS_Construction

java.lang.Object
micycle.pgs.PGS_Construction

public class PGS_Construction extends Object
Construct uncommon/interesting 2D geometries (beyond those offered in Processing).
Author:
Michael Carleton
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static processing.core.PShape
    createArbelos(double centerX, double centerY, double radius, double notchPosition)
    Creates an Arbelos shape, a mathematical figure bounded by three semicircles.
    static processing.core.PShape
    createArc(double centerX, double centerY, double width, double height, double orientation, double angle)
    Creates an elliptical arc polygon (a slice of a circle).
    static processing.core.PShape
    createBlobbie(double centerX, double centerY, double maxWidth, double a, double b, double c, double d)
    Creates a "blob"-like shape.
    static processing.core.PShape
    createCircle(double x, double y, double r)
    Creates a circle of radius r centered on (x,y).
    static processing.core.PShape
    createFermatSpiral(double centerX, double centerY, double coils, double outerRadius)
    Creates Fermat's spiral, a parabolic spiral which is symmetrical about the origin.
    static processing.core.PShape
    createGear(double centerX, double centerY, double radius, int n)
    Creates a gear shape from a parametric gear curve.
    static processing.core.PShape
    createHeart(double centerX, double centerY, double width)
    Creates a heart shape.
    static processing.core.PShape
    createHilbertCurve(double width, double height, int order)
    Creates a Hilbert Curve shape, a type of plane-filling curve.
    static processing.core.PShape
    createKochSnowflake(double width, double height, int order)
    Creates a Koch Snowflake shape, a fractal curve.
    static processing.core.PShape
    createLinearSpiral(double centerX, double centerY, double coils, double outerRadius)
    Creates an linear/archimedean spiral shape, where the distance between any 2 successive windings is constant.
    static processing.core.PShape
    createRandomBezierPolygon(int nPoints, double scale, double radius, double spikiness, long seed)
    Generates a smooth or spiky random polygon comprising Bezier curves.
    static processing.core.PShape
    createRandomPolygon(int n, double maxWidth, double maxHeight)
    Generates a random simple convex polygon (n-gon).
    static processing.core.PShape
    createRandomPolygon(int n, double maxWidth, double maxHeight, long seed)
    Generates a random simple convex polygon (n-gon), having a given random seed.
    static processing.core.PShape
    createRandomPolygonExact(int n, double width, double height)
    Generates a random simple convex polygon (n-gon), where the output's bounding box has the dimensions of those specified.
    static processing.core.PShape
    createRandomPolygonExact(int n, double width, double height, long seed)
    Generates a random simple convex polygon (n-gon), where the output's bounding box has the dimensions of those specified.
    static processing.core.PShape
    createRandomSFCurve(int nColumns, int nRows, double cellWidth, double cellHeight)
    Creates a random space-filling curve.
    static processing.core.PShape
    createRandomSFCurve(int nColumns, int nRows, double cellWidth, double cellHeight, long seed)
    Creates a random space-filling curve, having a specific random seed.
    static processing.core.PShape
    createRectangularSpiral(float x, float y, float width, float height, float spacing)
    Creates a rectangular-shaped spiral shape.
    static processing.core.PShape
    createRegularPolyon(int n, double centerX, double centerY, double width)
    Generates an N-sided regular polygon.
    static processing.core.PShape
    createRing(double centerX, double centerY, double outerRadius, double innerRadius)
    Creates a joined ring (a "donut") shape.
    static processing.core.PShape
    createRing(double centerX, double centerY, double outerRadius, double innerRadius, double orientation, double angle)
    Creates an (un)joined ring shape.
    static processing.core.PShape
    createSierpinskiCarpet(double width, double height, int order)
    Creates a Sierpiński Carpet shape, a type of plane fractal.
    static processing.core.PShape
    createSierpinskiCurve(double centerX, double centerY, double width, int curveOrder)
    Creates a closed Sierpiński curve (a recursive space-filling curve), having a user-defined degree/order.
    static processing.core.PShape
    Creates one of a family of trifurcating Sierpinski curves.
    static processing.core.PShape
    createSponge(double width, double height, int generators, double thickness, double smoothing, int classes, long seed)
    Creates a sponge-like porous structure.
    static processing.core.PShape
    createStar(double centerX, double centerY, int numRays, double innerRadius, double outerRadius, double roundness)
    Creates a star shape, having a specified number of rays.
    static processing.core.PShape
    createSupercircle(double centerX, double centerY, double diameter, double power)
    Creates a supercircle shape.
    static processing.core.PShape
    createSuperRandomPolygon(double dimensions, int cells, double markFraction, int smoothing, int depth, boolean orthogonal, boolean holes, long seed)
    Generates a highly customisable random polygon based on a square grid of NxN cells.
    static processing.core.PShape
    createSuperShape(double centerX, double centerY, double radius, double m, double n1, double n2, double n3)
    Creates a supershape PShape.
    static processing.core.PShape
    createTaijitu(double centerX, double centerY, double radius)
    Creates a Taijitu shape (a geometric representation of the Taoist symbol of yin and yang).
    static processing.core.PShape
    createTeardrop(double centerX, double centerY, double height, double m)
    Creates a teardrop shape from a parametric curve.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createRandomPolygon

      public static processing.core.PShape createRandomPolygon(int n, double maxWidth, double maxHeight)
      Generates a random simple convex polygon (n-gon).
      Parameters:
      n - number of polygon vertices/sides
      maxWidth - maximum width of generated random polygon
      maxHeight - maximum height of generated random polygon
      Returns:
      a PShape representing the generated polygon
    • createRandomPolygon

      public static processing.core.PShape createRandomPolygon(int n, double maxWidth, double maxHeight, long seed)
      Generates a random simple convex polygon (n-gon), having a given random seed.
      Parameters:
      n - number of polygon vertices/sides
      maxWidth - maximum width of generated random polygon
      maxHeight - maximum height of generated random polygon
      seed - a seed value used to generate the random polygon (optional)
      Returns:
      a PShape representing the generated polygon
    • createRandomPolygonExact

      public static processing.core.PShape createRandomPolygonExact(int n, double width, double height)
      Generates a random simple convex polygon (n-gon), where the output's bounding box has the dimensions of those specified.
      Parameters:
      n - number of polygon vertices/sides
      width - width of generated random polygon
      height - height of generated random polygon
      Returns:
      a PShape representing the generated polygon
    • createRandomPolygonExact

      public static processing.core.PShape createRandomPolygonExact(int n, double width, double height, long seed)
      Generates a random simple convex polygon (n-gon), where the output's bounding box has the dimensions of those specified.
      Parameters:
      n - number of polygon vertices/sides
      width - width of generated random polygon
      height - height of generated random polygon
      seed - a seed value used to generate the random polygon
      Returns:
      a PShape representing the generated polygon
    • createRegularPolyon

      public static processing.core.PShape createRegularPolyon(int n, double centerX, double centerY, double width)
      Generates an N-sided regular polygon.
      Parameters:
      n - number of sides
      centerX - centre point X
      centerY - centre point Y
      width - polygon width
      Since:
      2.0
    • createSupercircle

      public static processing.core.PShape createSupercircle(double centerX, double centerY, double diameter, double power)
      Creates a supercircle shape.
      Parameters:
      centerX - centre point X
      centerY - centre point Y
      diameter -
      power - circularity of the super circle. Values less than 1 create star-like shapes; power=1 is a square; values>1 are increasingly circular.
      Returns:
    • createSuperShape

      public static processing.core.PShape createSuperShape(double centerX, double centerY, double radius, double m, double n1, double n2, double n3)
      Creates a supershape PShape. The parameters feed into the superformula, which is a simple 2D analytical expression allowing to draw a wide variety of geometric and natural shapes (starfish, petals, snowflakes) by choosing suitable values relevant to few parameters.
      • As the n's are kept equal but reduced the form becomes increasingly pinched.
      • If n1 is slightly larger than n2 and n3 then bloated forms result.
      • Polygonal shapes are achieved with very large values of n1 and large but equal values for n2 and n3.
      • Asymmetric forms can be created by using different values for the n's.
      • Smooth starfish shapes result from smaller values of n1 than the n2 and n3.
      Parameters:
      centerX - centre point X
      centerY - centre point Y
      radius - maximum radius
      m - specifies the rotational symmetry of the shape (3 = 3 sided; 4 = 4 sided)
      n1 - supershape parameter 1
      n2 - supershape parameter 2
      n3 - supershape parameter 3
      Returns:
    • createArc

      public static processing.core.PShape createArc(double centerX, double centerY, double width, double height, double orientation, double angle)
      Creates an elliptical arc polygon (a slice of a circle). The polygon is formed from the specified arc of an ellipse and the two radii connecting the endpoints to the centre of the ellipse.
      Parameters:
      centerX - centre point X
      centerY - centre point Y
      width -
      height -
      orientation - start angle/orientation in radians (where 0 is 12 o'clock)
      angle - size of the arc angle in radians
      Returns:
    • createTaijitu

      public static processing.core.PShape createTaijitu(double centerX, double centerY, double radius)
      Creates a Taijitu shape (a geometric representation of the Taoist symbol of yin and yang).
      Parameters:
      centerX - the x-coordinate of the center of the shape
      centerY - the y-coordinate of the center of the shape
      radius - the radius of the shape
      Returns:
      a PShape representing the Taijitu shape
      Since:
      1.4.0
    • createArbelos

      public static processing.core.PShape createArbelos(double centerX, double centerY, double radius, double notchPosition)
      Creates an Arbelos shape, a mathematical figure bounded by three semicircles.

      The position of the central notch is arbitrary and can be located anywhere along the diameter.

      Parameters:
      centerX - the x-coordinate of the center of the shape
      centerY - the y-coordinate of the center of the shape
      radius - radius of the largest (enclosing) circle
      notchPosition - the fractional position, between 0 and 1, along the diameter where the notch will be
      Returns:
      a PShape representing the Arbelos shape
      Since:
      1.4.0
    • createStar

      public static processing.core.PShape createStar(double centerX, double centerY, int numRays, double innerRadius, double outerRadius, double roundness)
      Creates a star shape, having a specified number of rays.
      Parameters:
      centerX - The x coordinate of the center
      centerY - The y coordinate of the center
      numRays - The number of rays the star has
      innerRadius - The inner radius of the star
      outerRadius - The outer radius of the star
      roundness - A roundness value between 0.0 and 1.0, for the inner and outer corners of the star.
      Returns:
      The star shape
    • createBlobbie

      public static processing.core.PShape createBlobbie(double centerX, double centerY, double maxWidth, double a, double b, double c, double d)
      Creates a "blob"-like shape.

      In order for the shape to not self intersect a + b should be less than 1.

      Parameters:
      centerX - The x coordinate of the center
      centerY - The y coordinate of the center
      maxWidth -
      a - blob parameter. a + b should be less than 1
      b - blob parameter.a + b should be less than 1
      c - blob parameter
      d - blob parameter
      Returns:
      Since:
      1.3.0
    • createHeart

      public static processing.core.PShape createHeart(double centerX, double centerY, double width)
      Creates a heart shape.
      Parameters:
      centerX - The x coordinate of the center of the heart
      centerY - The y coordinate of the center of the heart
      width - Maximum width of the widest part of the heart
      Returns:
      Since:
      1.1.0
    • createTeardrop

      public static processing.core.PShape createTeardrop(double centerX, double centerY, double height, double m)
      Creates a teardrop shape from a parametric curve.
      Parameters:
      centerX - The x coordinate of the center of the teardrop
      centerY - The y coordinate of the center of the teardrop
      height - height of the teardrop
      m - order of the curve. Values of [2...5] give good results
      Returns:
      Since:
      1.4.0
    • createGear

      public static processing.core.PShape createGear(double centerX, double centerY, double radius, int n)
      Creates a gear shape from a parametric gear curve.
      Parameters:
      centerX - The x coordinate of the center of the gear
      centerY - The y coordinate of the center of the gear
      radius - maximum radius of gear teeth
      n - number of gear teeth
      Returns:
      the gear shape
      Since:
      1.4.0
    • createRing

      public static processing.core.PShape createRing(double centerX, double centerY, double outerRadius, double innerRadius)
      Creates a joined ring (a "donut") shape.
      Parameters:
      centerX - the x coordinate of the center
      centerY - the y coordinate of the center
      outerRadius - radius of ring exterior
      innerRadius - radius of ring hole
      Returns:
      the ring shape
      Since:
      1.1.3
    • createRing

      public static processing.core.PShape createRing(double centerX, double centerY, double outerRadius, double innerRadius, double orientation, double angle)
      Creates an (un)joined ring shape.
      Parameters:
      centerX - the x coordinate of the center
      centerY - the y coordinate of the center
      outerRadius - radius of ring exterior
      innerRadius - radius of ring hole
      orientation - start angle/orientation in radians (where 0 is 12 o'clock)
      angle - size of the ring arc angle in radians
      Returns:
      the ring shape
      Since:
      1.1.3
    • createSponge

      public static processing.core.PShape createSponge(double width, double height, int generators, double thickness, double smoothing, int classes, long seed)
      Creates a sponge-like porous structure.

      The sponge structure is formed by randomly merging adjacent cells of a Voronoi tessellation and then smoothing them; the final structure is obtained by subtracting that result from a rectangle.

      Parameters:
      width - the width of the sponge bounds
      height - the height of the sponge bounds
      generators - the number of generator points for the underlying Voronoi tessellation. Should be >5.
      thickness - thickness of sponge structure walls
      smoothing - the cell smoothing factor which determines how rounded the cells are. a value of 6 is a good starting point.
      classes - the number of classes to use for the cell merging process, where lower results in more merging (or larger "blob-like" shapes).
      seed - the seed for the random number generator
      Returns:
      the sponge shape
      Since:
      1.4.0
    • createLinearSpiral

      public static processing.core.PShape createLinearSpiral(double centerX, double centerY, double coils, double outerRadius)
      Creates an linear/archimedean spiral shape, where the distance between any 2 successive windings is constant.
      Parameters:
      centerX - the x coordinate of the spiral center point / origin
      centerY - the y coordinate of the spiral center point / origin
      coils - number of coils/rotations in the spiral
      outerRadius - the outer-most radius of the spiral / final coil
      Returns:
      a stroked PATH PShape
      Since:
      1.2.0
    • createFermatSpiral

      public static processing.core.PShape createFermatSpiral(double centerX, double centerY, double coils, double outerRadius)
      Creates Fermat's spiral, a parabolic spiral which is symmetrical about the origin.
      Parameters:
      centerX - the x coordinate of the spiral center point / origin
      centerY - the y coordinate of the spiral center point / origin
      coils - number of coils/rotations in the spiral
      outerRadius - the outer-most radius of the spiral / final coil
      Returns:
      a stroked PATH PShape
      Since:
      1.2.0
    • createRectangularSpiral

      public static processing.core.PShape createRectangularSpiral(float x, float y, float width, float height, float spacing)
      Creates a rectangular-shaped spiral shape.
      Parameters:
      x - x position of the top-left of spiral
      y - y position of the top-left of spiral
      width - width of outer-most coil
      height - height of outer-most coil
      spacing - the distance between successive coils
      Returns:
      a stroked PATH PShape with SQUARE stroke cap and MITER joins
      Since:
      1.3.0
    • createRandomSFCurve

      public static processing.core.PShape createRandomSFCurve(int nColumns, int nRows, double cellWidth, double cellHeight)
      Creates a random space-filling curve.

      A space-filling curve is a continuous curve that (in this case) traverses every cell of a grid exactly once.

      Parameters:
      nColumns - number of columns in the underlying grid
      nRows - number of rows in the underlying grid
      cellWidth - visual/pixel width of each cell
      cellHeight - visual/pixel width of each cell
      Returns:
      a stroked PATH PShape
      Since:
      1.4.0
      See Also:
    • createRandomSFCurve

      public static processing.core.PShape createRandomSFCurve(int nColumns, int nRows, double cellWidth, double cellHeight, long seed)
      Creates a random space-filling curve, having a specific random seed.

      A space-filling curve is a continuous curve that (in this case) traverses every cell of a grid exactly once.

      Parameters:
      nColumns - number of columns in the underlying grid
      nRows - number of rows in the underlying grid
      cellWidth - visual/pixel width of each cell
      cellHeight - visual/pixel width of each cell
      seed - random seed
      Returns:
      a stroked PATH PShape
      Since:
      1.4.0
      See Also:
    • createSuperRandomPolygon

      public static processing.core.PShape createSuperRandomPolygon(double dimensions, int cells, double markFraction, int smoothing, int depth, boolean orthogonal, boolean holes, long seed)
      Generates a highly customisable random polygon based on a square grid of NxN cells.

      The number of vertices of the polygon generated is not configurable, but depends on the size of cells and the percentage markPercent: for larger values of cells, the more vertices the polygon tends to have for a given markPercent.

      Visually pleasing "random" polygons can be achieved by selecting fairly small values for markFraction, e.g., markFraction=0.1 or even markPercent=0.01.

      Parameters:
      dimensions - pixel dimensions of the polygon in its longest axis.
      cells - the number of cells in the X and Y directions of the grid.
      markFraction - The fraction of vertices marked on the grid. The larger the percentage, the more vertices the polygon tends to have. Should generally be between 0...0.5.
      holes - If true, generates a holes in the polygon.
      orthogonal - Whether the polygon vertices lie exactly on integer grid points and only form horizontal and vertical lines.
      smoothing - The number of rounds of corner cutting to apply to the polygon. A small positive integer value is recommended. A value of 3 is probably sufficient.
      depth - The number of rounds of recursive refinement to apply to the polygon generated. A small positive integer value is recommended. This is akin to increasing the depth of fractal curve.
      seed - the seed for the random number generator
      Since:
      1.4.0
    • createRandomBezierPolygon

      public static processing.core.PShape createRandomBezierPolygon(int nPoints, double scale, double radius, double spikiness, long seed)
      Generates a smooth or spiky random polygon comprising Bezier curves.
      Parameters:
      nPoints - The number of bezier curves the polygon consists of.
      scale - Polygon scale. Determines the maximum width or height the polygon could have.
      radius - The radius relative to the distance between adjacent points. The radius is used to position the control points of the bezier curve, should be between 0 and 1. Larger values result in sharper features on the curve.
      spikiness - A measure of the curve's smoothness. If 0, the curve's angle through each point will be the average between the direction to adjacent points. As it increases, the angle will be determined mostly by one adjacent point, making the curve more "spiky".
      seed - the seed for the random number generator
      Returns:
      the random polygon shape
      Since:
      1.4.0
    • createSierpinskiCurve

      public static processing.core.PShape createSierpinskiCurve(double centerX, double centerY, double width, int curveOrder)
      Creates a closed Sierpiński curve (a recursive space-filling curve), having a user-defined degree/order.
      Parameters:
      centerX - the x coordinate of the curve center point
      centerY - the y coordinate of the curve center point
      width - length (the maximum width and height) of the curve (the curve will approach this width as the curve order is increased and more space is filled)
      curveOrder - the order of the curve (the number of recursive subdivisions). Must be 1 or greater.
      Returns:
      a Sierpiński curve of the specified order
      Since:
      1.2.0
    • createHilbertCurve

      public static processing.core.PShape createHilbertCurve(double width, double height, int order)
      Creates a Hilbert Curve shape, a type of plane-filling curve.
      Parameters:
      width - pixel width of the curve
      height - pixel height of the curve
      order - order of the hilbert curve. should be at least 0
      Returns:
      a stroked PATH PShape, anchored at (0, 0)
      Since:
      1.3.0
    • createSierpinskiCarpet

      public static processing.core.PShape createSierpinskiCarpet(double width, double height, int order)
      Creates a Sierpiński Carpet shape, a type of plane fractal.
      Parameters:
      width - pixel width of the curve
      height - pixel height of the curve
      order - the number of recursive subdivisions (at least 0, probably no more than 5)
      Returns:
      carpet shape, anchored at (0, 0)
      Since:
      1.3.0
    • createKochSnowflake

      public static processing.core.PShape createKochSnowflake(double width, double height, int order)
      Creates a Koch Snowflake shape, a fractal curve.
      Parameters:
      width - pixel width of the curve's envelope
      height - pixel width of the curve's envelope
      order - the number of recursive subdivisions (at least 0)
      Returns:
      snowflake shape, whose envelope is anchored at (0, 0)
      Since:
      1.3.0
    • createSierpinskiTriCurve

      public static processing.core.PShape createSierpinskiTriCurve(PGS_Construction.SierpinskiTriCurveType type, double width, int order)
      Creates one of a family of trifurcating Sierpinski curves.
      Parameters:
      type - the type of tri-curve: {TRI, TETRA, PENTA, DECA}
      width - pixel width of the curve's envelope
      order - the number of recursive subdivisions (at least 1)
      Returns:
      curve shape, anchored at (0, 0)
      Since:
      1.3.0
    • createCircle

      public static processing.core.PShape createCircle(double x, double y, double r)
      Creates a circle of radius r centered on (x,y).
      Since:
      2.0