Packages

  • package root
    Definition Classes
    root
  • package de
    Definition Classes
    root
  • package h2b
    Definition Classes
    de
  • package scala
    Definition Classes
    h2b
  • package lib
    Definition Classes
    scala
  • package simgraf

    This is a Scala library of graphics utilities.

    This is a Scala library of graphics utilities. It is focused on simple drawing of shapes and functions without the need of instructing the graphics system by a dozen or so settings before a simple picture is shown. It is not meant to program graphical user interfaces with buttons, menus and so on.

    The World

    A World provides graphics in world coordinates. For instance,

    val w = World(p1, p2)(p0, w, h, title)

    defines a world that has a coordinate system with a Point p1 in the lower-left corner and the upper-right corner at p2. All operations ensure clipping to that area, so that it is safe to use coordinates outside of it.

    The second parameter group defines the location on the screen: p0 denotes the upper left Pixel, w and h the width and the height of the window in pixels and title gives a window title (that will not reduce the drawing area).

    A Point defines a location in the world coordinate system using two doubles, while a Pixel denotes a location on the screen by means of two integers.

    Note that the y axis of the world coordinate system is directed from bottom to top while at the screen level it is vice versa.

    So, for example

    val w = World(Point(-100,-100), Point(100,100))(Pixel(0,0), 200, 200, "Circle")

    defines a world with x and y axis both ranging from -100 to +100 shown in a window of size 200x200 pixels at the upper left corner of the screen titled "Circle".

    Once you have a world, you can execute several methods on it: plot a point or clear the world to a specified color, use moveTo or drawTo for plotter-like operations and -- at the highest abstraction -- draw or fill shapes of type Drawable or Fillable, respectively.

    Each world maintains an activeColor which can be set and is used for most drawings and fillings until it is changed (except for those that use their own color).

    To fill a circle of color Magenta and radius 75.0 around the origin of our world w on a white background, we write:

    w.clear(Color.White)
    w.activeColor = Color.Magenta
    w.fill(Circle(Point(0,0), 75.0))

    That's it: with these three lines of code and the definition of w above you get a graphic on the screen.

    The Screen

    A Screen provides direct pixel graphics. It is the back end of World.

    It can be used on its own if no world coordinate system is needed and bare screen-pixel coordinates shall be applied instead. Though, there are no fancy general shape-oriented draw and fill operations as World has to offer, but only some primitives like setPixel, drawLine, drawSquare, fillSquare, moveTo or drawTo.

    Definition Classes
    lib
  • package driver
    Definition Classes
    simgraf
  • package event

    This package constitutes a high-level abstraction of input (e.g., keyboard or mouse) events using an actor event bus.

    This package constitutes a high-level abstraction of input (e.g., keyboard or mouse) events using an actor event bus.

    Such events, if triggered by the drivers, are published to the global event stream of this package and can be retrieved by subscribing to the stream object.

    Also, there is a Subscriber actor that can be used to handle events. Since version 1.3.0, it's companion object defines to methods for screens and worlds with a PartialFunction[Event, Unit] as a parameter.

    So, for example, you just can write

    	  Subscriber.to(world) {
    	    case e: Event ⇒ println(e)
    	  }

    to print out all events occurring on the specified world.

    To get the triggering enabled, the withEvents factory methods of World or Screen have to be used.

    Note that the program doesn't terminate by itself on closing all screens if the event package is used. This is due to background processes still listening to the event stream. For explicit termination call the terminate method on the package object's system value; this can be done, e. g., by subscribing to all screens or worlds and using a termination event like this:

    Subscriber.to(world1, world2) {
      case KeyEvent(k) if k=='q' ⇒
        world1.screen.close()
        world2.screen.close()
        println("terminating...")
        system.terminate()
      case _: Event ⇒ ()
    }
    Definition Classes
    simgraf
    Since

    1.2.0

  • package layout

    A package collecting some tools for positioning elements on the screen.

    A package collecting some tools for positioning elements on the screen.

    It contains a Cell (a rectangular area) and a GridLayout of cells organized into rows and columns as this:

    ----------------------------
    | cell | cell | cell | ... |
    ----------------------------
    | cell | cell | cell | ... |
    ----------------------------
    | cell | cell | cell | ... |
    ----------------------------
    | ...  | ...  | ...  | ... |
    ----------------------------
    

    Various factory methods are provided that construct grid layouts from a sample cell, within a cell or on the whole screen.

    Definition Classes
    simgraf
    Since

    1.1.0

  • package shapes

    Shapes are used for the World's draw and fill methods.

    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).

    Definition Classes
    simgraf
  • package parallel

    This package provides parallel versions of some shapes.

    This package provides parallel versions of some shapes.

    These shapes have the same interface as their sequential counterparts.

    By implementing the FutureTracking trait, some control is given when some concurrent operation is done.

    Since

    1.1.0

  • Arc
  • Circle
  • Collage
  • Coloring
  • Dot
  • Drawable
  • Ellipse
  • Enclosing
  • Fillable
  • Function
  • Grid
  • Line
  • MultivaluedFunction
  • Plus
  • Polygonal
  • Rectangle
  • Shape
  • Square
  • Text

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).

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. shapes
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. 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

    Example:
    1. Arc(Point(10,10), 5, 5, 0, 2*Math.Pi) creates a circle of diameter 5 around the centre (10,10)

  2. 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

  3. 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.

  4. 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

  5. case class Dot (p: Point) extends Drawable with Product with Serializable

    A drawable wrapper for a point.

  6. trait Drawable extends Shape

    A shape that can be drawn in a world coordinate system.

  7. 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

  8. class Enclosing extends AnyRef

    Defines an enclosing for some shapes.

  9. trait Fillable extends Shape

    A shape that can be filled in a world coordinate system.

  10. 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

  11. 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

  12. case class Line (p1: Point, p2: Point) extends Drawable with Product with Serializable

    A line between two points.

  13. 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

  14. case class Plus (p0: Point, l: Double) extends Drawable with Product with Serializable

    A plus sign (+) with centre at p0 and the specified line length l.

    A plus sign (+) with centre at p0 and the specified line length l.

    p0

    centre of the sign

    l

    length of the lines of the sign

  15. 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.

  16. case class Rectangle (p1: Point, p2: Point) extends Drawable with Fillable with Product with Serializable

    A rectangle specified by diagonal opposite corners.

  17. trait Shape extends AnyRef

    General base trait.

  18. 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 length l.

    A square with centre at p0 and the specified side length l.

    p0

    centre of the square

    l

    side length of the square

  19. 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

  1. object Dot extends Serializable
  2. object Enclosing
  3. object Grid extends Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped