Class PGS_Construction
- Author:
- Michael Carleton
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
createSierpinskiTriCurve
(PGS_Construction.SierpinskiTriCurveType type, double width, int order) 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.
-
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/sidesmaxWidth
- maximum width of generated random polygonmaxHeight
- 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/sidesmaxWidth
- maximum width of generated random polygonmaxHeight
- maximum height of generated random polygonseed
- 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/sideswidth
- width of generated random polygonheight
- 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/sideswidth
- width of generated random polygonheight
- height of generated random polygonseed
- 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 sidescenterX
- centre point XcenterY
- centre point Ywidth
- 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 XcenterY
- centre point Ydiameter
-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 XcenterY
- centre point Yradius
- maximum radiusm
- specifies the rotational symmetry of the shape (3 = 3 sided; 4 = 4 sided)n1
- supershape parameter 1n2
- supershape parameter 2n3
- 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 XcenterY
- centre point Ywidth
-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 shapecenterY
- the y-coordinate of the center of the shaperadius
- 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 shapecenterY
- the y-coordinate of the center of the shaperadius
- radius of the largest (enclosing) circlenotchPosition
- 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 centercenterY
- The y coordinate of the centernumRays
- The number of rays the star hasinnerRadius
- The inner radius of the starouterRadius
- The outer radius of the starroundness
- 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 centercenterY
- The y coordinate of the centermaxWidth
-a
- blob parameter. a + b should be less than 1b
- blob parameter.a + b should be less than 1c
- blob parameterd
- 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 heartcenterY
- The y coordinate of the center of the heartwidth
- 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 teardropcenterY
- The y coordinate of the center of the teardropheight
- height of the teardropm
- 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 gearcenterY
- The y coordinate of the center of the gearradius
- maximum radius of gear teethn
- 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 centercenterY
- the y coordinate of the centerouterRadius
- radius of ring exteriorinnerRadius
- 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 centercenterY
- the y coordinate of the centerouterRadius
- radius of ring exteriorinnerRadius
- radius of ring holeorientation
- 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 boundsheight
- the height of the sponge boundsgenerators
- the number of generator points for the underlying Voronoi tessellation. Should be >5.thickness
- thickness of sponge structure wallssmoothing
- 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 / origincenterY
- the y coordinate of the spiral center point / origincoils
- number of coils/rotations in the spiralouterRadius
- 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 / origincenterY
- the y coordinate of the spiral center point / origincoils
- number of coils/rotations in the spiralouterRadius
- 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 spiraly
- y position of the top-left of spiralwidth
- width of outer-most coilheight
- height of outer-most coilspacing
- 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 gridnRows
- number of rows in the underlying gridcellWidth
- visual/pixel width of each cellcellHeight
- 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 gridnRows
- number of rows in the underlying gridcellWidth
- visual/pixel width of each cellcellHeight
- visual/pixel width of each cellseed
- 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 percentagemarkPercent
: for larger values ofcells
, 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 evenmarkPercent=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 pointcenterY
- the y coordinate of the curve center pointwidth
- 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 curveheight
- pixel height of the curveorder
- 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 curveheight
- pixel height of the curveorder
- 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 envelopeheight
- pixel width of the curve's envelopeorder
- 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 envelopeorder
- 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
-