Skip to content
Snippets Groups Projects
Commit 5d3b795f authored by Edvard Granheim Harbo's avatar Edvard Granheim Harbo
Browse files

Merge branch 'Task.2.3' into 'dev'

Task.2.3

See merge request !13
parents 054f4061 e89fd15f
Branches
No related tags found
3 merge requests!54Final release,!17Part 2,!13Task.2.3
Showing
with 143 additions and 61 deletions
This folder contains libraries copied from the "mappevurderingprog2" project.
It is managed by the CheckStyle-IDEA IDE plugin.
Do not modify this folder while the IDE is running.
When the IDE is stopped, you may delete this folder at any time. It will be recreated as needed.
In order to prevent the CheckStyle-IDEA IDE plugin from creating this folder,
uncheck the "Copy libraries from project directory" option in the CheckStyle-IDEA settings dialog.
t
java:S1104"RMake random a static final constant or non-public and provide accessors if needed.(۾8ɘ1
\ No newline at end of file
K
java:S1068")Remove this unused "width" private field.(81
G
java:S1068"*Remove this unused "height" private field.(ŜԘ81
J
java:S1068"-Remove this unused "minCoords" private field.(81
J
java:S1068"-Remove this unused "maxCoords" private field.(Ӎ̰81
\ No newline at end of file

Rsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosCanvas.java,d\7\d76d5eb7ebfbf238873844dff69ea1eef6dfce50

[src/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosGameDescription.java,4\7\47e34523397788c03243d64074d52920465d78d7

Psrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosGame.java,8\c\8cfab28119a3cabc48fd065616b0f4b69fe24606

Osrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/JuliaTransform.java,3\5\354ebf246fe4c64c2e7de36906c67e9693bbb4ba
y
Isrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/Vector2D.java,3\1\318a69fca7eadd51de0d98636a4dfd0de9ddfdd7
|
Lsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/Transform2D.java,7\2\725abaab0f0d8d1b5456ee53c9daf32bc708589b

Rsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/AffineTransform2D.java,b\9\b97c992741c2e72c365f499c7feee5681e7fe0d6
\ No newline at end of file

Rsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosCanvas.java,d\7\d76d5eb7ebfbf238873844dff69ea1eef6dfce50

[src/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosGameDescription.java,4\7\47e34523397788c03243d64074d52920465d78d7

Psrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosGame.java,8\c\8cfab28119a3cabc48fd065616b0f4b69fe24606

Osrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/JuliaTransform.java,3\5\354ebf246fe4c64c2e7de36906c67e9693bbb4ba
y
Isrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/Vector2D.java,3\1\318a69fca7eadd51de0d98636a4dfd0de9ddfdd7
|
Lsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/Transform2D.java,7\2\725abaab0f0d8d1b5456ee53c9daf32bc708589b

Rsrc/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/AffineTransform2D.java,b\9\b97c992741c2e72c365f499c7feee5681e7fe0d6
\ No newline at end of file
......@@ -56,27 +56,25 @@ public class ChaosCanvas{
return canvas[x][y];
}
/**
* Sets the color of the pixel at the given point.
* Puts a pixel at the given point.
* @param point the point to set the color of
* @param color the color to set
* @return the color of the pixel after setting
* @param point the point at which to put the pixel
*/
public int usePixel(Vector2D point, int color){
public void putPixel(Vector2D point){
Vector2D indices = transformCoordsToIndices.transform(point);
int x = (int) indices.getX0();
int y = (int) indices.getX1();
canvas[x][y] = color;
return canvas[x][y];
canvas[x][y] = 1;
}
/**
* Gets the canvas.
* Gets the canvas array.
* @return the canvas
* @return the canvas array
*/
public int[][] getCanvas(){
public int[][]getCanvasArray(){
return canvas;
}
......
package edu.ntnu.idatt2003.mappevurderingprog2.models.chaos;
import edu.ntnu.idatt2003.mappevurderingprog2.models.Transform2D;
import edu.ntnu.idatt2003.mappevurderingprog2.models.Vector2D;
import java.util.Random;
/**
* The ChaosGame class represents a chaos game.
* The class simulate a chaos game with a given description on a canvas.
*/
public class ChaosGame {
private ChaosCanvas canvas;
private ChaosGameDescription description;
private Vector2D currentPoint;
public Random random;
public ChaosGame(ChaosGameDescription description, int width, int height) {
this.description = description;
this.canvas = new ChaosCanvas(width, height, description.getMinCoords(), description.getMaxCoords());
this.currentPoint = new Vector2D(0, 0);
this.random = new Random();
}
public ChaosCanvas getCanvas() {
return canvas;
}
public void runSteps(int steps) {
for (int i = 0; i < steps; i++) {
int randomIndex = random.nextInt(description.getTransforms().size());
Transform2D transform = description.getTransforms().get(randomIndex);
currentPoint = transform.transform(currentPoint);
canvas.putPixel(currentPoint);
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package edu.ntnu.idatt2003.mappevurderingprog2.models.chaos;
import edu.ntnu.idatt2003.mappevurderingprog2.models.Transform2D;
import edu.ntnu.idatt2003.mappevurderingprog2.models.Vector2D;
import java.util.List;
/**
......@@ -23,7 +22,7 @@ public class ChaosGameDescription {
/**
* Constructs a ChaosGameDescription object with the given list of transforms
* and the minimum and maximum coordinates.
*
* @param transforms the list of transforms
* @param minCoords the minimum of the x and y coordinates of the game area
* @param maxCoords the maximum of the x and y coordinates of the game area
......@@ -36,7 +35,7 @@ public class ChaosGameDescription {
/**
* Gets the list of transformations associated with the chaos game.
*
* @return the list of transforms
*/
public List<Transform2D> getTransforms() {
......@@ -45,7 +44,7 @@ public class ChaosGameDescription {
/**
* Gets the minimum of the x and y coordinates of the game area.
*
* @return the minimum of the x and y coordinates
*/
public Vector2D getMinCoords() {
......@@ -54,7 +53,7 @@ public class ChaosGameDescription {
/**
* Gets the maximum of the x and y coordinates of the game area.
*
* @return the maximum of the x and y coordinates
*/
public Vector2D getMaxCoords() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment