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
  • Color
  • ColorIterator
  • Pixel
  • Point
  • PointStore
  • Screen
  • World

abstract class Screen extends ScreenDriver

Provides screen (pixel) graphics.

The drawing area will have the specified width and height and will be positioned at the given location (if possible).

It will have a coordinate system with the origin (0, 0) in the lower-left corner and the upper-right corner at (width-1, height-1). All operations ensure clipping to that area, so that it is safe to use coordinates outside of it.

Implementation note: This abstract class does not add abstract members other than it inherits from ScreenDriver.

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

Instance Constructors

  1. new Screen(p0: Pixel, width: Int, height: Int, title: String = "")

    p0

    location of the upper-left corner on the screen

    width

    horizontal dimension

    height

    vertical dimension

    title

    optional window title (will not reduce the drawing area, defaults to empty string)

Abstract Value Members

  1. abstract val activeColor: Color

    color to be used for the next operations (except for those that use their own color)

    color to be used for the next operations (except for those that use their own color)

    Definition Classes
    ScreenDriver
  2. abstract def close(): Unit

    Closes the screen this driver is associated to.

    Closes the screen this driver is associated to.

    Definition Classes
    ScreenDriver
    Since

    1.3.0

    Note

    Might not have an effect if the underlying implementation does not support such an operation.

  3. abstract def drawArc(p0: Pixel, width: Int, height: Int, startAngle: Int, arcAngle: Int): Unit

    Draws an arc within a virtual rectangle.

    Draws an arc within a virtual rectangle.

    Angles are given in degrees, 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 rectangle

    height

    of the enclosing rectangle

    startAngle

    start in degrees

    arcAngle

    extent in degrees

    Definition Classes
    ScreenDriver
    Example:
    1. drawArc(Pixel(10,10), 5, 5, 0, 360) draws a circle of diameter 5 around the centre (10,10)

  4. abstract def drawLine(p1: Pixel, p2: Pixel): Unit

    Draws a line from p1 to p2.

    Draws a line from p1 to p2.

    Definition Classes
    ScreenDriver
  5. abstract def drawPolyline(p: Seq[Pixel]): Unit

    Draws a polygonal chain with vertices defined by the specified sequence.

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

    Definition Classes
    ScreenDriver
  6. abstract def drawRectangle(p1: Pixel, p2: Pixel): Unit

    Draws a rectangle with diagonal opposite corners at p1 and p2.

    Draws a rectangle with diagonal opposite corners at p1 and p2.

    Definition Classes
    ScreenDriver
  7. abstract def drawText(p0: Pixel, text: String): Unit

    Draws a text with lower-left corner at p0.

    Draws a text with lower-left corner at p0.

    text

    null does nothing

    Definition Classes
    ScreenDriver
  8. abstract def fillArc(p0: Pixel, width: Int, height: Int, startAngle: Int, arcAngle: Int): Unit

    Fills an arc within a virtual rectangle.

    Fills an arc within a virtual rectangle.

    Angles are given in degrees, 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 rectangle

    height

    of the enclosing rectangle

    startAngle

    start in degrees

    arcAngle

    extent in degrees

    Definition Classes
    ScreenDriver
    Example:
    1. fillArc(Pixel(10,10), 5, 5, 0, 360) fills a circle of diameter 5 around the centre (10,10)

  9. abstract def fillPolygon(p: Seq[Pixel]): Unit

    Fills a polygonal area with vertices defined by the specified sequence.

    Fills a polygonal area with vertices defined by the specified sequence.

    There is no need to close the sequence of vertices.

    Definition Classes
    ScreenDriver
  10. abstract def fillRectangle(p1: Pixel, p2: Pixel): Unit

    Fills a rectangle with diagonal opposite corners at p1 and p2.

    Fills a rectangle with diagonal opposite corners at p1 and p2.

    Definition Classes
    ScreenDriver
  11. abstract def getPixel(p: Pixel): Color

    Gets color of a pixel.

    Gets color of a pixel.

    returns

    the color of the pixel at p or Color(0, 0, 0) if it is outside of the drawing area

    Definition Classes
    ScreenDriver
  12. abstract def setPixel(p: Pixel, color: Color): Unit

    Sets pixel to color.

    Sets pixel to color.

    Definition Classes
    ScreenDriver

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clear(col: Color): Unit

    Sets all pixels of the screen to a specified color.

    Sets all pixels of the screen to a specified color.

    col

    specified color

  6. def clear(p1: Pixel, p2: Pixel, col: Color): Unit

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a specified color.

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a specified color.

    col

    specified color

  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def drawCircle(p0: Pixel, r: Int): Unit

    Draws a circle.

    Draws a circle.

    p0

    centre of the circle

    r

    radius of the circle

  9. def drawCross(p0: Pixel, l: Int): Unit

    Draws a cross (+) with centre at p0 and the specified line length l.

    Draws a cross (+) with centre at p0 and the specified line length l.

    p0

    centre of the cross

    l

    length of the lines of the cross

  10. def drawEllipse(p0: Pixel, width: Int, height: Int): Unit

    Draws an ellipse within a virtual rectangle.

    Draws an ellipse within a virtual rectangle.

    p0

    centre of the ellipse

    width

    of the enclosing rectangle

    height

    of the enclosing rectangle

  11. def drawGrid(dx: Int, dy: Int): Unit

    Draws a grid on the whole screen.

    Draws a grid on the whole screen.

    dx

    distance of vertical lines

    dy

    distance of horizontal lines

  12. def drawGrid(p1: Pixel, p2: Pixel, dx: Int, dy: Int): Unit

    Draws a grid in a rectangle with diagonal opposite corners at p1 and p2.

    Draws a grid in a rectangle with diagonal opposite corners at p1 and p2.

    dx

    distance of vertical lines

    dy

    distance of horizontal lines

  13. def drawSquare(p0: Pixel, l: Int): Unit

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

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

    p0

    centre of the square

    l

    side length of the square

  14. def drawTo(p: Pixel): Unit

    Draws a line in the active color from the active starting point to the given endpoint and sets the latter as new starting point for the next drawTo.

    Draws a line in the active color from the active starting point to the given endpoint and sets the latter as new starting point for the next drawTo.

    No methods other than moveTo and drawTo have an effect on the starting point.

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  17. def fillCircle(p0: Pixel, r: Int): Unit

    Fills a circle.

    Fills a circle.

    p0

    centre of the circle

    r

    radius of the circle

  18. def fillEllipse(p0: Pixel, width: Int, height: Int): Unit

    Fills an ellipse within a virtual rectangle.

    Fills an ellipse within a virtual rectangle.

    p0

    centre of the ellipse

    width

    of the enclosing rectangle

    height

    of the enclosing rectangle

  19. def fillSquare(p0: Pixel, l: Int): Unit

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

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

    p0

    centre of the square

    l

    side length of the square

  20. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def flipV(y: Int): Int

    Helper function for systems with origin at upper-left corner.

    Helper function for systems with origin at upper-left corner.

    y

    original coordinate

    returns

    vertical flipped coordinate

    Attributes
    protected
    Definition Classes
    ScreenDriver
  22. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  24. val height: Int
    Definition Classes
    ScreenScreenDriver
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def moveTo(p: Pixel): Unit

    Sets starting point for next drawtTo.

    Sets starting point for next drawtTo.

    No methods other than moveTo and drawTo have an effect on this starting point.

  27. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. final def notify(): Unit
    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  30. val p0: Pixel
    Definition Classes
    ScreenScreenDriver
  31. def setPixels(col: (Pixel) ⇒ Color): Unit

    Sets all pixels of the screen to a computed color.

    Sets all pixels of the screen to a computed color.

    col

    computing function that maps pixel coordinates to colors

  32. def setPixels(p1: Pixel, p2: Pixel)(col: (Pixel) ⇒ Color): Unit

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a computed color.

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a computed color.

    col

    computing function that maps pixel coordinates to colors

  33. def setPixelsParallel(col: (Pixel) ⇒ Color): Future[Unit]

    Sets all pixels of the screen to a computed color using parallel operations.

    Sets all pixels of the screen to a computed color using parallel operations.

    The returned value can be used if further operations need to be informed when this operation is done (e.g., by setting a callback). The future is completed when either all pixels are set or some exception occurs. Note that in case of an exception some pixel settings might still continue afterwards.

    col

    computing function that maps pixel coordinates to colors

    returns

    a future with no specific value indicating the completion of this operation

    Since

    1.1.0

  34. def setPixelsParallel(p1: Pixel, p2: Pixel)(col: (Pixel) ⇒ Color): Future[Unit]

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a computed color using parallel operations.

    Sets all pixels in a rectangle with diagonal opposite corners at p1 and p2 to a computed color using parallel operations.

    The returned value can be used if further operations need to be informed when this operation is done (e.g., by setting a callback). The future is completed when either all pixels are set or some exception occurs. Note that in case of an exception some pixel settings might still continue afterwards.

    col

    computing function that maps pixel coordinates to colors

    returns

    a future with no specific value indicating the completion of this operation

    Since

    1.1.0

  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. val title: String
    Definition Classes
    ScreenScreenDriver
  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. val width: Int
    Definition Classes
    ScreenScreenDriver

Inherited from ScreenDriver

Inherited from AnyRef

Inherited from Any

Ungrouped