package shapes
Shapes are used for the World
's draw
and fill
methods. A shape can
extend the Shape.Drawable
or Shape.Fillable
trait or both, which makes it
applicable to the according method.
The package comes with a variety of predefined shapes ranging from simple
figures like Line
, Rectangle
or Circle
to higher-order ones like
Function
or even Grid
which draws a simple coordinate system into the
world.
Of course, you can define your own shapes. Just implement the Shape.Drawable
or Shape.Fillable
trait(s).
- Alphabetic
- By Inheritance
- shapes
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
case class
Arc
(p0: Point, width: Double, height: Double, startAngle: Double, arcAngle: Double) extends Drawable with Fillable with Product with Serializable
An arc within a virtual rectangle.
An arc within a virtual rectangle.
Angles are given in radian measure, where 0 is the direction of the x axis and positive values count counter-clockwise while negative values count clockwise.
- p0
centre of the arc
- width
of the enclosing virtual rectangle
- height
of the enclosing virtual rectangle
- startAngle
start in radians
- arcAngle
extent in radians
Arc(Point(10,10), 5, 5, 0, 2*Math.Pi) creates a circle of diameter 5 around the centre (10,10)
Example: -
case class
Circle
(p0: Point, r: Double) extends Drawable with Fillable with Product with Serializable
A circle.
A circle.
- p0
centre of the circle
- r
radius of the circle
-
case class
Collage
(items: Seq[Shape]) extends Drawable with Fillable with Product with Serializable
A collection of shapes.
A collection of shapes.
This collage can contain both drawables and fillables, but of course only drawables are drawn and fillables are filled. In both cases, items are processed in the order in which they appear within the sequence parameter.
-
case class
Coloring
(col: (Point) ⇒ Color)(implicit enc: Enclosing) extends Fillable with Product with Serializable
A computed coloring.
A computed coloring.
- col
computing function that maps point coordinates to colors
- enc
enclosing for this grid; defaults to the full world if not explicitly or otherwise implicitly given
-
case class
Dot
(p: Point) extends Drawable with Product with Serializable
A drawable wrapper for a point.
-
trait
Drawable
extends Shape
A shape that can be drawn in a world coordinate system.
-
case class
Ellipse
(p0: Point, width: Double, height: Double) extends Drawable with Fillable with Product with Serializable
An ellipse within a virtual rectangle.
An ellipse within a virtual rectangle.
- p0
centre of the ellipse
- width
of the enclosing virtual rectangle
- height
of the enclosing virtual rectangle
-
class
Enclosing
extends AnyRef
Defines an enclosing for some shapes.
-
trait
Fillable
extends Shape
A shape that can be filled in a world coordinate system.
-
case class
Function
(f: (Double) ⇒ Double)(implicit enc: Enclosing) extends Drawable with Fillable with Product with Serializable
A function as shape.
A function as shape.
When filling, this is done from the x axis (i.e.
y==0
).- enc
enclosing for this function; defaults to the full world if not explicitly or otherwise implicitly given
-
case class
Grid
(dx: Double, dy: Double, label: Label = Label.Default)(implicit enc: Enclosing) extends Drawable with Product with Serializable
A grid with labels.
A grid with labels.
- dx
distance of vertical lines
- dy
distance of horizontal lines
- label
optional label formatting
- enc
enclosing for this grid; defaults to the full world if not explicitly or otherwise implicitly given
-
case class
Line
(p1: Point, p2: Point) extends Drawable with Product with Serializable
A line between two points.
-
case class
MultivaluedFunction
(f: (Double) ⇒ Set[Double])(implicit enc: Enclosing) extends Drawable with Fillable with Product with Serializable
A multivalued function as shape.
A multivalued function as shape.
When filling, this is done from the lowest to the highest multivalue for each x, respectively.
- enc
enclosing for this function; defaults to the full world if not explicitly or otherwise implicitly given
-
case class
Plus
(p0: Point, l: Double) extends Drawable with Product with Serializable
A plus sign (+) with centre at
p0
and the specified line lengthl
.A plus sign (+) with centre at
p0
and the specified line lengthl
.- p0
centre of the sign
- l
length of the lines of the sign
-
case class
Polygonal
(p: Seq[Point]) extends Drawable with Fillable with Product with Serializable
A polygonal chain with vertices defined by the specified sequence.
A polygonal chain with vertices defined by the specified sequence.
The chain is not closed by default. To achieve this, set the last vertex equal to the first. Note that there is no need to close the sequence of vertices when filling the polygonal area.
-
case class
Rectangle
(p1: Point, p2: Point) extends Drawable with Fillable with Product with Serializable
A rectangle specified by diagonal opposite corners.
-
trait
Shape
extends AnyRef
General base trait.
-
case class
Square
(p0: Point, l: Double) extends Drawable with Fillable with Product with Serializable
A square with centre at
p0
and the specified side lengthl
.A square with centre at
p0
and the specified side lengthl
.- p0
centre of the square
- l
side length of the square
-
case class
Text
(p0: Point, text: String) extends Drawable with Product with Serializable
A text at a specified position.
A text at a specified position.
- p0
lower-left corner
Value Members
- object Dot extends Serializable
- object Enclosing
- object Grid extends Serializable