Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
cs349-code
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sakib Rabbany Sajal
cs349-code
Commits
f61439cf
Commit
f61439cf
authored
Oct 13, 2017
by
Daniel Vogel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified Shape.java, more applicable to A2 now
parent
866a65cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
21 deletions
+9
-21
java/6-graphics/shapemodel/Shape.java
java/6-graphics/shapemodel/Shape.java
+7
-11
java/6-graphics/shapemodel/ShapeDemo.java
java/6-graphics/shapemodel/ShapeDemo.java
+2
-10
No files found.
java/6-graphics/shapemodel/Shape.java
View file @
f61439cf
...
...
@@ -76,16 +76,10 @@ class Shape {
this
.
strokeThickness
=
strokeThickness
;
}
// the model to world transform (default is identity)
AffineTransform
transform
=
new
AffineTransform
();
// shape's transform
public
AffineTransform
getTransform
()
{
return
transform
;
}
public
void
setTransform
(
AffineTransform
transform
)
{
this
.
transform
=
transform
;
}
// quick hack, get and set would be better
float
scale
=
1.0f
;
// some optimization to cache points for drawing
Boolean
pointsChanged
=
false
;
// dirty bit
...
...
@@ -118,14 +112,16 @@ class Shape {
AffineTransform
M
=
g2
.
getTransform
();
// multiply in this shape's transform
g2
.
transform
(
transform
);
// (uniform scale)
g2
.
scale
(
scale
,
scale
);
// call drawing functions
g2
.
setColor
(
colour
);
if
(
isFilled
)
{
g2
.
fillPolygon
(
xpoints
,
ypoints
,
npoints
);
}
else
{
g2
.
setStroke
(
new
BasicStroke
(
strokeThickness
));
// can adjust stroke size using scale
g2
.
setStroke
(
new
BasicStroke
(
strokeThickness
/
scale
));
if
(
isClosed
)
g2
.
drawPolygon
(
xpoints
,
ypoints
,
npoints
);
else
...
...
java/6-graphics/shapemodel/ShapeDemo.java
View file @
f61439cf
...
...
@@ -27,16 +27,8 @@ public class ShapeDemo extends JPanel {
// shape.setIsFilled(true);
shape
.
setColour
(
Color
.
BLUE
);
// try uncommenting this block ...
// // remember transformations are post-multipied ...
// // let's mirror the shape ...
// AffineTransform T = new AffineTransform();
// // then scale
// T.concatenate(AffineTransform.getScaleInstance(-1, 1));
// // translate first
// T.concatenate(AffineTransform.getTranslateInstance(-300,0));
// shape.setTransform(T);
// try setting scale to something other than 1
shape
.
scale
=
1.0f
;
repaint
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment