Class ChaosCanvas
java.lang.Object
edu.ntnu.stud.chaosgame.model.game.ChaosCanvas
Class representing the canvas for the display of the chaos game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[][]
Table representing the canvas.private final int[][]
This array keeps track of how many times a pixel has been visited, to be used to determine the color of the pixel when displayed.private final int
Height of the canvas.private final Vector2D
The maximum coordinates of the canvas.private final Vector2D
The minimum coordinates of the canvas.private final AffineTransform2D
Affine transformation for converting coordinates to canvas indices.private final int
Width of the canvas. -
Constructor Summary
ConstructorsConstructorDescriptionChaosCanvas
(int width, int height, Vector2D minCoords, Vector2D maxCoords) Parameterized constructor for the class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the canvas of all content.int[][]
Get the array defining the size of the canvas.int[][]
Get the canvas intensity array.int
Get the height of the ChaosCanvas.int
getIntensityPixel
(Vector2D point) Get the intensity of a pixel located at a point.Get the vector storing the maximum coordinates.Get the vector storing the minimum coordinates.int
Get a pixel located at a point.int[]
getSize()
Get the width and height of the canvas in the form of an array where the first index stores the width and the second stores the height.int
getWidth()
Get the width of the ChaosCanvas.boolean
isPointInCanvasRange
(Vector2D point) Checks whether a given point is within the current subsection of the coordinate space.void
Place a pixel on the canvas.
-
Field Details
-
canvas
private final int[][] canvasTable representing the canvas. -
canvasIntensityArray
private final int[][] canvasIntensityArrayThis array keeps track of how many times a pixel has been visited, to be used to determine the color of the pixel when displayed. -
width
private final int widthWidth of the canvas. -
height
private final int heightHeight of the canvas. -
minCoords
The minimum coordinates of the canvas. -
maxCoords
The maximum coordinates of the canvas. -
transformCoordsToIndices
Affine transformation for converting coordinates to canvas indices.
-
-
Constructor Details
-
ChaosCanvas
Parameterized constructor for the class.- Parameters:
width
- width of the canvasheight
- height of the canvasminCoords
- minimum coordinates of the canvasmaxCoords
- maximum coordinates of the canvas
-
-
Method Details
-
putPixel
Place a pixel on the canvas. If the pixel is out of bounds, it is ignored.- Parameters:
point
- the point where the pixel is to be placed.
-
getSize
public int[] getSize()Get the width and height of the canvas in the form of an array where the first index stores the width and the second stores the height.- Returns:
- an array of two numbers containing both the width and height.
-
getMinCoords
Get the vector storing the minimum coordinates.- Returns:
- the vector.
-
getMaxCoords
Get the vector storing the maximum coordinates.- Returns:
- the vector.
-
getPixel
Get a pixel located at a point.- Parameters:
point
- point at which the pixel is located- Returns:
- the pixel
-
getIntensityPixel
Get the intensity of a pixel located at a point.- Parameters:
point
- the point to check for.- Returns:
- the intensity at the point.
-
getCanvasIntensityArray
public int[][] getCanvasIntensityArray()Get the canvas intensity array.- Returns:
- the canvas intensity array.
-
clearCanvas
public void clearCanvas()Clear the canvas of all content. -
getCanvasArray
public int[][] getCanvasArray()Get the array defining the size of the canvas.- Returns:
- the array.
-
isPointInCanvasRange
Checks whether a given point is within the current subsection of the coordinate space.- Parameters:
point
- the point to check- Returns:
- true if the point is within the subsection, false otherwise
-
getWidth
public int getWidth()Get the width of the ChaosCanvas.- Returns:
- the width of the ChaosCanvas.
-
getHeight
public int getHeight()Get the height of the ChaosCanvas.- Returns:
- the height of the ChaosCanvas.
-