Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mappevurderingprog2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tam Minh Le
mappevurderingprog2
Commits
9dcf09df
Commit
9dcf09df
authored
Feb 29, 2024
by
Tam Le
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: Implemented Chaoscanvas class and methods for the class
parent
b363a5b1
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!54
Final release
,
!17
Part 2
,
!7
Refactor: Implemented ChaosCanvas class and implemented methods for the class
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosCanvas.java
+49
-0
49 additions, 0 deletions
...att2003/mappevurderingprog2/models/chaos/ChaosCanvas.java
with
49 additions
and
0 deletions
src/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosCanvas.java
0 → 100644
+
49
−
0
View file @
9dcf09df
package
edu.ntnu.idatt2003.mappevurderingprog2.models.chaos
;
import
edu.ntnu.idatt2003.mappevurderingprog2.models.AffineTransform2D
;
import
edu.ntnu.idatt2003.mappevurderingprog2.models.Vector2D
;
public
class
ChaosCanvas
{
private
int
[][]
canvas
;
private
int
width
;
private
int
height
;
private
Vector2D
minCoords
;
private
Vector2D
maxCoords
;
private
AffineTransform2D
transformCoordsToIndices
;
public
ChaosCanvas
(
int
width
,
int
height
,
Vector2D
minCoords
,
Vector2D
maxCoords
)
{
this
.
width
=
width
;
this
.
height
=
height
;
this
.
minCoords
=
minCoords
;
this
.
maxCoords
=
maxCoords
;
this
.
canvas
=
new
int
[
width
][
height
];
}
public
int
getPixel
(
Vector2D
point
){
Vector2D
indices
=
transformCoordsToIndices
.
transform
(
point
);
int
x
=
(
int
)
indices
.
getX0
();
int
y
=
(
int
)
indices
.
getX1
();
return
canvas
[
x
][
y
];
}
public
int
usePixel
(
Vector2D
point
,
int
color
){
Vector2D
indices
=
transformCoordsToIndices
.
transform
(
point
);
int
x
=
(
int
)
indices
.
getX0
();
int
y
=
(
int
)
indices
.
getX1
();
canvas
[
x
][
y
]
=
color
;
return
canvas
[
x
][
y
];
}
public
int
[][]
getCanvas
(){
return
canvas
;
}
public
void
clear
(){
for
(
int
i
=
0
;
i
<
canvas
.
length
;
i
++){
for
(
int
j
=
0
;
j
<
canvas
[
i
].
length
;
j
++){
canvas
[
i
][
j
]
=
0
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment