Packages

  • package root
    Definition Classes
    root
  • package hevs
    Definition Classes
    root
  • package graphics

    A library used for teaching computer science in the ISC degree programme, notably for the course _101.1 Imperative programming_.

    A library used for teaching computer science in the ISC degree programme, notably for the course _101.1 Imperative programming_.

    The library provides classes for simple graphical drawing, with primitives such as points and lines drawing, simple text with different fonts, ... Input primitives are also available using keyboard or mouse. Several examples are also provided.

    Overview

    Here is how to create a window and draw a circle on it using FunGraphics :

    val f = new FunGraphics(400, 300)
    f.drawCircle(200,150, 50)
    Definition Classes
    hevs
  • package advanced
    Definition Classes
    graphics
  • package interfaces
    Definition Classes
    graphics
  • package samples
    Definition Classes
    graphics
  • package utils
    Definition Classes
    graphics
  • AcceleratedDisplay
  • FunGraphics
  • ImageGraphics
  • TurtleGraphics
c

hevs.graphics

TurtleGraphics

class TurtleGraphics extends FunGraphics

Graphics class that emulates the tortoise in the Logo programming language

The turtle starts at the center of the window, looking up with a black color and pen down

Basic port implementation by Pierre Roduit, rewritten for use with FunGraphics by Pierre-André Mudry.

Version

2.01 Using FunGraphics as main class

See also

Wikipedia description of Turtle Graphics

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TurtleGraphics
  2. FunGraphics
  3. DualLayerGraphics
  4. Graphics
  5. AcceleratedDisplay
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new TurtleGraphics(width: Int, height: Int)

    Creates a turtle window

    Creates a turtle window

    width

    Width of the window

    height

    Height of the window

  2. new TurtleGraphics(width: Int, height: Int, windowName: String)

    Creates a turtle window

    Creates a turtle window

    width

    Width of the window

    height

    Height of the window

    windowName

    Title of the window

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. var DISPLAY_FPS: Boolean
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  5. var TRANSPARENT: Color
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  6. def addMouseListener(l: MouseListener): Unit

    Adds a MouseListener to the window to react on mouse events

    Adds a MouseListener to the window to react on mouse events

    l

    The MouseListener

    Definition Classes
    FunGraphics
  7. def addMouseMotionListener(m: MouseMotionListener): Unit

    Adds a MouseMotionListener to the window to react on mouse movements

    Adds a MouseMotionListener to the window to react on mouse movements

    m

    The MouseMotionListener

    Definition Classes
    FunGraphics
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. var backBuffer: BufferedImage
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  10. var backg2d: Graphics2D
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  11. var bufferStrategy: BufferStrategy

    Buffer and g2d stuff

    Buffer and g2d stuff

    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  12. def changeColor(color: Color): Unit

    Change the color of drawing

    Change the color of drawing

    color

    the new color

  13. var checkBorders: Boolean
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  14. def clear(c: Color): Unit

    Method which cleans up the display.

    Method which cleans up the display. Everything becomes the background again.

    Definition Classes
    FunGraphicsGraphics
  15. def clear(): Unit

    Method which cleans up the display.

    Method which cleans up the display. Everything becomes the background again

    Definition Classes
    FunGraphicsGraphics
  16. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  17. var current_fps: Double
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  18. def displayFPS(x: Boolean): Unit

    Selects if the FPS should be printed

    Selects if the FPS should be printed

    x

    FPS will be printed when set to true

    Definition Classes
    AcceleratedDisplay
  19. def drawBackground(): Unit

    Call this method to modify only the background

    Call this method to modify only the background

    Definition Classes
    FunGraphicsDualLayerGraphics
  20. def drawCircle(posX: Int, posY: Int, f: Int): Unit

    Draws a circle starting from (Top left X, Top left Y)

    Draws a circle starting from (Top left X, Top left Y)

    posX

    X top-left position of the circle

    posY

    Y top-left position of the circle

    f

    Diameter of the drawn circle

    Definition Classes
    FunGraphicsGraphics
  21. def drawFancyString(posX: Int, posY: Int, str: String, fontFamily: String = "Georgia", fontStyle: Int = Font.BOLD, fontSize: Int = 20, color: Color = Color.BLACK, halign: Int = SwingConstants.LEFT, valign: Int = SwingConstants.BOTTOM, shadowX: Int = 0, shadowY: Int = 0, shadowColor: Color = Color.GRAY, shadowThickness: Int = 0, outlineColor: Color = Color.WHITE, outlineThickness: Int = 0): Unit

    Draws a text with a shadow and/or outline

    Draws a text with a shadow and/or outline

    posX

    X position of the string

    posY

    Y position of the string

    str

    the string to draw

    fontFamily

    the font family

    fontStyle

    the font style (Font.PLAIN, Font.BOLD, Font.ITALIC, ...)

    fontSize

    the font size

    color

    the text color

    halign

    the horizontal alignment (see javax.swing.SwingConstants) Valid values: LEFT, CENTER and RIGHT

    valign

    the vertical alignment (see javax.swing.SwingConstants) Valid values: TOP, CENTER and BOTTOM

    shadowX

    the shadow's X offset

    shadowY

    the shadow's Y offset

    shadowColor

    the shadow color

    shadowThickness

    the shadow thickness

    outlineColor

    the outline color

    outlineThickness

    the outline thickness

    Definition Classes
    FunGraphicsGraphics
  22. def drawFancyString(posX: Int, posY: Int, str: String, color: Color, size: Int): Unit

    Draws a text with a shadow

    Draws a text with a shadow

    posX

    X position of the string

    posY

    Y position of the string

    str

    the string to draw

    color

    the text color

    size

    the font size

    Definition Classes
    FunGraphicsGraphics
  23. def drawFillRect(rect: Rectangle): Unit

    Draw a filled rectangle in the color selected with setColor.

    Draw a filled rectangle in the color selected with setColor.

    rect

    rectangle to draw

    Definition Classes
    FunGraphicsGraphics
  24. def drawFillRect(posX: Int, posY: Int, width: Int, height: Int): Unit

    Draw a filled rectangle in the color selected with setColor.

    Draw a filled rectangle in the color selected with setColor.

    posX

    X coordinate of the top left corner of the rectangle

    posY

    Y coordinate of the top left corner of the rectangle

    width

    Width of the rectangle

    height

    Height of the rectangle

    Definition Classes
    FunGraphicsGraphics
  25. def drawFilledCircle(posX: Int, posY: Int, diameter: Int): Unit

    Draws a circle starting from (Top left X, Top left Y)

    Draws a circle starting from (Top left X, Top left Y)

    posX

    X top-left position of the circle

    posY

    Y top-left position of the circle

    diameter

    Diameter of the drawn circle

    Definition Classes
    FunGraphicsGraphics
  26. def drawFilledOval(posX: Int, posY: Int, width: Int, height: Int): Unit

    Draws an oval starting from (Top left X, Top left Y)

    Draws an oval starting from (Top left X, Top left Y)

    posX

    X top-left position of the circle

    posY

    Y top-left position of the circle

    width

    Width of the drawn oval

    height

    Height of the drawn oval

    Definition Classes
    FunGraphicsGraphics
  27. def drawFilledPolygon(p: Polygon, c: Color): Unit

    Draw a filled polygon

    Draw a filled polygon

    p

    the polygon to draw

    c

    the color of the polygon

    Definition Classes
    FunGraphicsGraphics
  28. def drawForeground(): Unit

    Call this method to modify only the foreground

    Call this method to modify only the foreground

    Definition Classes
    FunGraphicsDualLayerGraphics
  29. def drawLine(p1x: Int, p1y: Int, p2x: Int, p2y: Int): Unit

    Draw a line from P1 to P2 in the color selected with setColor.

    Draw a line from P1 to P2 in the color selected with setColor.

    p1x

    X coordinate of P1

    p1y

    Y coordinate of P1

    p2x

    X coordinate of P2

    p2y

    Y coordinate of P2

    Definition Classes
    FunGraphicsGraphics
  30. def drawMirroredPicture(posX: Int, posY: Int, angle: Double, bitmap: GraphicsBitmap): Unit

    Draw a mirrored centered picture from a file (gif, jpg, png) to (posX, posY)

    Draw a mirrored centered picture from a file (gif, jpg, png) to (posX, posY)

    posX

    X position of the image

    posY

    Y position of the image

    angle

    The rotation angle of the image to be drawn

    bitmap

    A bitmap

    Definition Classes
    FunGraphicsGraphics
  31. def drawPicture(posX: Int, posY: Int, bitmap: GraphicsBitmap): Unit

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY)

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY)

    posX

    X position of the image

    posY

    Y position of the image

    bitmap

    A bitmap

    Definition Classes
    FunGraphicsGraphics
  32. def drawRect(rect: Rectangle): Unit

    Draw an empty rectangle in the color selected with setColor

    Draw an empty rectangle in the color selected with setColor

    rect

    rectangle to draw

    Definition Classes
    FunGraphicsGraphics
  33. def drawRect(posX: Int, posY: Int, width: Int, height: Int): Unit

    Draw an empty rectangle in the color selected with setColor.

    Draw an empty rectangle in the color selected with setColor.

    posX

    X coordinate of the top left corner of the rectangle

    posY

    Y coordinate of the top left corner of the rectangle

    width

    Width of the rectangle

    height

    Height of the rectangle

    Definition Classes
    FunGraphicsGraphics
  34. def drawString(posX: Int, posY: Int, str: String, color: Color, size: Int): Unit

    Write the given string at (posX, posY)

    Write the given string at (posX, posY)

    posX

    Position x of the string

    posY

    Position y of the string

    str

    The string to be drawn

    color

    The color of the string

    size

    The size of the font

    Definition Classes
    FunGraphicsGraphics
  35. def drawString(posX: Int, posY: Int, str: String, fontFamily: String = "SansSerif", fontStyle: Int = Font.PLAIN, fontSize: Int = 20, color: Color = Color.BLACK, halign: Int = SwingConstants.LEFT, valign: Int = SwingConstants.BOTTOM): Unit

    Draws a string at a given location.

    Draws a string at a given location. Note that the boundaries are not checked and text may be painted outside the window

    posX

    X position of string

    posY

    Y position of string

    str

    the string to write

    fontFamily

    the font family

    fontStyle

    the font style (Font.PLAIN, Font.BOLD, Font.ITALIC, ...)

    fontSize

    the font size

    color

    the text color

    halign

    the horizontal alignment (see javax.swing.SwingConstants) Valid values: LEFT, CENTER and RIGHT

    valign

    the vertical alignment (see javax.swing.SwingConstants) Valid values: TOP, CENTER and BOTTOM

    Definition Classes
    FunGraphicsGraphics
  36. def drawString(posX: Int, posY: Int, str: String, font: Font, color: Color, halign: Int, valign: Int): Unit

    Draws a string at a given location with the given font, color and alignments.

    Draws a string at a given location with the given font, color and alignments. Note that the boundaries are not checked and text may be painted outside the window

    posX

    X position of string

    posY

    Y position of string

    str

    the string to write

    font

    the font

    color

    the text color

    halign

    the horizontal alignment (see javax.swing.SwingConstants) Valid values: LEFT, CENTER and RIGHT

    valign

    the vertical alignment (see javax.swing.SwingConstants) Valid values: TOP, CENTER and BOTTOM

    Definition Classes
    FunGraphicsGraphics
  37. def drawString(posX: Int, posY: Int, str: String, font: Font, color: Color): Unit

    Draws a string at a given location with the given font and color.

    Draws a string at a given location with the given font and color. Note that the boundaries are not checked and text may be painted outside the window

    posX

    X position of string

    posY

    Y position of string

    str

    the string to write

    font

    the font

    color

    the text color

    Definition Classes
    FunGraphicsGraphics
  38. def drawTransformedPicture(posX: Int, posY: Int, angle: Double, scale: Double, bitmap: GraphicsBitmap): Unit

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY)

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY)

    posX

    X position of the image

    posY

    Y position of the image

    angle

    The rotation angle of the image to be drawn

    scale

    The scale factor of the image to be drawn

    bitmap

    A bitmap

    Definition Classes
    FunGraphicsGraphics
  39. def drawTransformedPicture(posX: Int, posY: Int, angle: Double, scale: Double, imageName: String): Unit

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY).

    Draw a centered picture from a file (gif, jpg, png) to (posX, posY). Warning, very slow because the image has to be reloaded

    posX

    X position of the image

    posY

    Y position of the image

    angle

    The rotation angle of the image to be drawn

    scale

    The scale factor of the image to be drawn

    imageName

    path of the image file

    Definition Classes
    FunGraphicsGraphics
  40. var enableRenderingHints: Boolean
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  41. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  42. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  43. var fHeight: Int
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  44. var fWidth: Int
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  45. def forward(distance: Double): Unit

    Go forward the specified distance (writing if the pen is down)

    Go forward the specified distance (writing if the pen is down)

    distance

    The distance to move

  46. var frontBuffer: BufferedImage
    Definition Classes
    AcceleratedDisplay
  47. var frontg2d: Graphics2D
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  48. var g2d: Graphics2D
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  49. def getAvailableFonts(): Array[String]

    Returns a list of available font names on the device

    Returns a list of available font names on the device

    returns

    the list of available font names

    Definition Classes
    FunGraphicsGraphics
  50. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  51. def getFrameHeight(): Int

    Get the frame height

    Get the frame height

    returns

    the frame height

    Definition Classes
    FunGraphicsGraphics
  52. def getFrameWidth(): Int

    Get the frame width

    Get the frame width

    returns

    the frame width

    Definition Classes
    FunGraphicsGraphics
  53. def getPosition(): Point

    Gets the turtle's current position

    Gets the turtle's current position

    returns

    The location of the turtle

  54. def getStringSize(str: String): Rectangle2D

    Computes the size necessary to render a string with the current font

    Computes the size necessary to render a string with the current font

    str

    the string

    returns

    the bounding box of the rendered string

    Definition Classes
    FunGraphicsGraphics
  55. def getStringSize(str: String, font: Font): Rectangle2D

    Computes the size necessary to render a string with the given font

    Computes the size necessary to render a string with the given font

    str

    the string

    font

    the font

    returns

    the bounding box of the rendered string

    Definition Classes
    FunGraphicsGraphics
  56. def getTurtleAngle(): Double

    Gets the turtle's current angle

    Gets the turtle's current angle

    returns

    The current turtle angle (in degrees) Angle 0 is east (right). A positive angle is clockwise.

  57. def getTurtleAngleRad(): Double

    Get the turtle angle.

    Get the turtle angle. Angle 0 is east (right). A positive angle is clockwise.

    returns

    The current turtle angle in radians

  58. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  59. val height: Int
    Definition Classes
    FunGraphics
  60. val high_quality: Boolean
    Definition Classes
    FunGraphics
  61. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  62. def jump(x: Int, y: Int): Unit

    Jump to a specific location (without drawing)

    Jump to a specific location (without drawing)

    x

    X coordinate of the destination

    y

    Y coordinate of the destination

  63. var mainFrame: JFrame

    The subclass which create the windows frame

    The subclass which create the windows frame

    Definition Classes
    AcceleratedDisplay
  64. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  65. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  66. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  67. def penDown(): Unit

    Start the writing

  68. def penUp(): Unit

    Stop the drawing

  69. def setAngle(angle: Double): Unit

    Set the direction of writing to the specified angle.

    Set the direction of writing to the specified angle. Angle 0 is east (right). A positive angle is clockwise.

    angle

    specified angle in degrees

  70. def setAngleRad(angle: Double): Unit

    Set the direction of writing to the specified angle.

    Set the direction of writing to the specified angle. Angle 0 is east (right). A positive angle is clockwise.

    angle

    specified angle in radians

  71. def setColor(c: Color): Unit

    Set the color of the future drawings

    Set the color of the future drawings

    c

    Selected color for drawing

    Definition Classes
    FunGraphicsGraphics
  72. def setKeyManager(k: KeyListener): Unit

    Sets a keyboard listener

    Sets a keyboard listener

    k

    The KeyListener to listen to

    Definition Classes
    FunGraphics
  73. def setMouseMotionManager(mouseMotionListener: MouseMotionListener): Unit

    Adds a MouseMotionListener to the window to react on mouse movements

    Adds a MouseMotionListener to the window to react on mouse movements

    mouseMotionListener

    the MouseMotionListener

  74. def setPenWidth(width: Float): Unit

    Sets the width of the pen

    Sets the width of the pen

    width

    The new width of the pen

    Definition Classes
    FunGraphicsGraphics
  75. def setPixel(x: Int, y: Int, c: Int): Unit

    Draws a pixel with a given color.

    Draws a pixel with a given color. Does not change the current color

    x

    X coordinate

    y

    Y coordinate

    c

    Color to use (RGB coded)

    Definition Classes
    FunGraphicsGraphics
  76. def setPixel(x: Int, y: Int, c: Color): Unit

    Draws a pixel with a given color.

    Draws a pixel with a given color. Does not change the current color.

    x

    X coordinate

    y

    Y coordinate

    c

    Color to use for this pixel (this pixel only, see setColor(Color)

    Definition Classes
    FunGraphicsGraphics
  77. def setPixel(x: Int, y: Int): Unit

    Draw the selected pixel with the color selected with setColor.

    Draw the selected pixel with the color selected with setColor.

    x

    X coordinate of the pixel

    y

    Y coordinate of the pixel

    Definition Classes
    FunGraphicsGraphics
  78. def setWidth(w: Float): Unit

    Sets the width of the pen

    Sets the width of the pen

    w

    the new width

  79. def syncGameLogic(FPS: Int): Unit

    Call this method periodically to have a constant frame rate

    Call this method periodically to have a constant frame rate

    FPS

    the target frame rate

    Definition Classes
    AcceleratedDisplay
  80. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  81. var target_fps: Int
    Attributes
    protected
    Definition Classes
    AcceleratedDisplay
  82. val title: String
    Definition Classes
    FunGraphics
  83. def toString(): String
    Definition Classes
    AnyRef → Any
  84. def turn(angle: Double): Unit

    Turn the direction of writing with by specified angle A positive angle is clockwise.

    Turn the direction of writing with by specified angle A positive angle is clockwise.

    angle

    specified angle in degrees

  85. def turnRad(angle: Double): Unit

    Turn the direction of writing by the specified angle.

    Turn the direction of writing by the specified angle. A positive angle is clockwise.

    angle

    specified angle in radians

  86. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  87. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  88. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  89. val width: Int
    Definition Classes
    FunGraphics
  90. val xoffset: Int
    Definition Classes
    FunGraphics
  91. val yoffset: Int
    Definition Classes
    FunGraphics

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from FunGraphics

Inherited from DualLayerGraphics

Inherited from Graphics

Inherited from AcceleratedDisplay

Inherited from AnyRef

Inherited from Any

Ungrouped