Module SypherEngine

Class Renderer

java.lang.Object
dev.aurumbyte.sypherengine.core.graphics.Renderer

public class Renderer extends Object
The renderer/graphics backend, containing all the rendering helper methods
Since:
v0.3.0
Author:
AurumByte
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) javafx.scene.image.Image
    The background image to be rendered, if it is not null
    (package private) javafx.scene.paint.Color
    Default background color
    (package private) javafx.scene.canvas.Canvas
    The JavaFX canvas, on which images and other stuff are rendered
    (package private) javafx.scene.text.Font
    Default font
    (package private) javafx.scene.canvas.GraphicsContext
    The GraphicsContext is used to render images and image tiles to the screen
    (package private) javafx.scene.Group
    The JavaFX group, used for adding shapes
    (package private) javafx.scene.Scene
    The Scene on which everything is rendered
  • Constructor Summary

    Constructors
    Constructor
    Description
    Renderer(javafx.scene.Group group, javafx.scene.Scene scene, javafx.scene.canvas.Canvas canvas)
    Initializing the renderer
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all objects from the renderer queue
    void
    drawCircle(Vector2 position, float radius, boolean isFilled, javafx.scene.paint.Paint paint)
    Drawing a circle of specified measurements
    void
    drawImage(javafx.scene.image.Image image, Vector2 position, float width, float height)
    Drawing a image of specified measurements
    void
    drawImageTile(ImageTile imageTile, Vector2 position, int tileX, int tileY)
    Drawing a image tile of specified measurements
    void
    drawLine(Vector2 start, Vector2 end, Optional<javafx.scene.paint.Paint> paint)
    Drawing text of specified measurements
    void
    drawPolygon(double[] coords, boolean isFilled, javafx.scene.paint.Paint paint)
    Drawing text of specified measurements
    void
    drawRectangle(Vector2 position, float width, float height, boolean isFilled, javafx.scene.paint.Paint paint)
    Drawing a rectangle of specified measurements
    void
    drawText(String textContent, Vector2 position, javafx.scene.paint.Paint paint, javafx.scene.text.Font font)
    Drawing text of specified measurements
    javafx.scene.paint.Color
    Gets the background color
    javafx.scene.text.Font
    Gets the default font
    javafx.scene.canvas.GraphicsContext
    Gets the Graphics context
    javafx.geometry.Point2D
    Gets the screen center
    void
    setBackgroundColor(javafx.scene.paint.Color backgroundColor)
    Sets the Graphics context
    void
    setDefaultFont(javafx.scene.text.Font defaultFont)
    Sets the default font
    void
    Transforms on an entity(image)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • group

      javafx.scene.Group group
      The JavaFX group, used for adding shapes
    • scene

      javafx.scene.Scene scene
      The Scene on which everything is rendered
    • canvas

      javafx.scene.canvas.Canvas canvas
      The JavaFX canvas, on which images and other stuff are rendered
    • graphicsContext

      javafx.scene.canvas.GraphicsContext graphicsContext
      The GraphicsContext is used to render images and image tiles to the screen
    • background

      javafx.scene.image.Image background
      The background image to be rendered, if it is not null
    • backgroundColor

      javafx.scene.paint.Color backgroundColor
      Default background color
    • defaultFont

      javafx.scene.text.Font defaultFont
      Default font
  • Constructor Details

    • Renderer

      public Renderer(javafx.scene.Group group, javafx.scene.Scene scene, javafx.scene.canvas.Canvas canvas)

      Initializing the renderer

      Parameters:
      group - The group
      scene - The scene
      canvas - The canvas
      Since:
      0.3.0
  • Method Details

    • clear

      public void clear()

      Clears all objects from the renderer queue

      Since:
      0.3.0
    • transformContext

      public void transformContext(Entity entity)

      Transforms on an entity(image)

      Since:
      0.3.0
    • drawRectangle

      public void drawRectangle(Vector2 position, float width, float height, boolean isFilled, javafx.scene.paint.Paint paint)

      Drawing a rectangle of specified measurements

      Parameters:
      position - The position of the rectangle
      width - The width of the rectangle
      height - The height of the rectangle
      isFilled - Specify whether the rectangle should be filled in or not
      paint - The Color or gradient to be filled in
      Since:
      0.3.0
    • drawCircle

      public void drawCircle(Vector2 position, float radius, boolean isFilled, javafx.scene.paint.Paint paint)

      Drawing a circle of specified measurements

      Parameters:
      position - The position of the circle
      radius - The radius of the circle
      isFilled - Specify whether the circle should be filled in or not
      paint - The Color or gradient to be filled in
      Since:
      0.3.0
    • drawImage

      public void drawImage(javafx.scene.image.Image image, Vector2 position, float width, float height)

      Drawing a image of specified measurements

      Parameters:
      image - The image to be rendered
      position - The position of the image
      width - The width of the image
      height - The height of the image
      Since:
      0.3.0
    • drawImageTile

      public void drawImageTile(ImageTile imageTile, Vector2 position, int tileX, int tileY)

      Drawing a image tile of specified measurements

      Parameters:
      imageTile - The image tile to be rendered
      position - The position of the image
      tileX - The tile count from left to right, starting from 0
      tileY - The tile count from the top to bottom, starting from 0
      Since:
      0.3.0
    • drawText

      public void drawText(String textContent, Vector2 position, javafx.scene.paint.Paint paint, javafx.scene.text.Font font)

      Drawing text of specified measurements

      Parameters:
      position - The position of the text
      textContent - The text to be rendered
      font - The font of the text
      paint - The Color or gradient to be filled in
      Since:
      0.3.0
    • drawLine

      public void drawLine(Vector2 start, Vector2 end, Optional<javafx.scene.paint.Paint> paint)

      Drawing text of specified measurements

      Parameters:
      start - The start position of the line
      end - The end position of the line
      paint - The Color or gradient to be filled in
      Since:
      0.3.0
    • drawPolygon

      public void drawPolygon(double[] coords, boolean isFilled, javafx.scene.paint.Paint paint)

      Drawing text of specified measurements

      Parameters:
      coords - the coordinates of the polygon vertices
      isFilled - Specify whether the polygon should be filled or not
      paint - The color or gradient to be filled in
      Since:
      0.3.0
    • getGraphicsContext

      public javafx.scene.canvas.GraphicsContext getGraphicsContext()
      Gets the Graphics context
    • getBackgroundColor

      public javafx.scene.paint.Color getBackgroundColor()
      Gets the background color
    • setBackgroundColor

      public void setBackgroundColor(javafx.scene.paint.Color backgroundColor)
      Sets the Graphics context
    • getDefaultFont

      public javafx.scene.text.Font getDefaultFont()
      Gets the default font
    • setDefaultFont

      public void setDefaultFont(javafx.scene.text.Font defaultFont)
      Sets the default font
    • getScreenCenter

      public javafx.geometry.Point2D getScreenCenter()
      Gets the screen center