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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tam Minh Le
mappevurderingprog2
Merge requests
!7
Refactor: Implemented ChaosCanvas class and implemented methods for the class
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Refactor: Implemented ChaosCanvas class and implemented methods for the class
task.2.2
into
dev
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Tam Minh Le
requested to merge
task.2.2
into
dev
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
Finished the creation of constructor for ChaosCanvas class and implemented methods
0
0
Merge request reports
Compare
dev
dev (base)
and
latest version
latest version
9dcf09df
1 commit,
1 year ago
1 file
+
49
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/main/java/edu/ntnu/idatt2003/mappevurderingprog2/models/chaos/ChaosCanvas.java
0 → 100644
+
49
−
0
Options
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
Loading