Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PHILIPPE-iihm
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
Lucas Philippe
PHILIPPE-iihm
Commits
bf2ab336
Commit
bf2ab336
authored
1 year ago
by
Lucas Philippe
Browse files
Options
Downloads
Patches
Plain Diff
Ajout etape 4
parent
58dc5817
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
TP5/sketch_240321a/City.pde
+9
-3
9 additions, 3 deletions
TP5/sketch_240321a/City.pde
TP5/sketch_240321a/sketch_240321a.pde
+18
-1
18 additions, 1 deletion
TP5/sketch_240321a/sketch_240321a.pde
with
27 additions
and
4 deletions
TP5/sketch_240321a/City.pde
+
9
−
3
View file @
bf2ab336
...
@@ -6,6 +6,7 @@ class City {
...
@@ -6,6 +6,7 @@ class City {
float
population
;
float
population
;
float
density
;
float
density
;
float
altitude
;
float
altitude
;
float
radius
=
0
;
// put a drawing function in here and call from main drawing loop }
// put a drawing function in here and call from main drawing loop }
public
City
(
String
postalcode
,
String
name
,
float
x
,
float
y
,
float
population
,
float
surface
,
float
altitude
)
{
public
City
(
String
postalcode
,
String
name
,
float
x
,
float
y
,
float
population
,
float
surface
,
float
altitude
)
{
...
@@ -23,14 +24,19 @@ class City {
...
@@ -23,14 +24,19 @@ class City {
float
porcentageAlt
=
map
(
this
.
altitude
,
minAltitude
,
maxAltitude
,
0
,
100
);
float
porcentageAlt
=
map
(
this
.
altitude
,
minAltitude
,
maxAltitude
,
0
,
100
);
float
hue
=
getColorForAltitude
(
porcentageAlt
);
float
hue
=
getColorForAltitude
(
porcentageAlt
);
// Set marker size based on population
// Set marker size based on population
xxxx
float
size
=
map
(
this
.
population
,
minPopulation
,
maxPopulation
,
3
,
100
);
radius
=
map
(
this
.
population
,
minPopulation
,
maxPopulation
,
3
,
100
);
// Draw marker
// Draw marker
fill
(
hue
,
100
,
100
);
fill
(
hue
,
100
,
100
);
ellipse
(
x
,
y
,
size
,
size
);
ellipse
(
x
,
y
,
radius
,
radius
);
}
}
boolean
contains
(
int
px
,
int
py
){
float
dist
=
dist
(
x
,
y
,
px
,
py
);
return
dist
<
radius
/
2
+
1
;
}
}
}
This diff is collapsed.
Click to expand it.
TP5/sketch_240321a/sketch_240321a.pde
+
18
−
1
View file @
bf2ab336
...
@@ -15,6 +15,7 @@ City cities[];
...
@@ -15,6 +15,7 @@ City cities[];
int
legendsHeight
=
100
;
int
legendsHeight
=
100
;
int
minPopulationToDisplay
=
10000
;
int
minPopulationToDisplay
=
10000
;
boolean
redrawInProgress
=
false
;
boolean
redrawInProgress
=
false
;
City
lastCitySelected
=
null
;
void
setup
()
{
void
setup
()
{
size
(
900
,
900
);
size
(
900
,
900
);
...
@@ -145,5 +146,21 @@ void keyPressed() {
...
@@ -145,5 +146,21 @@ void keyPressed() {
}
}
void
mouseMoved
()
{
void
mouseMoved
()
{
println
(
"(x: "
+
mouseX
+
", y: "
+
mouseY
+
")"
);
//println("(x: " + mouseX + ", y: " + mouseY + ")");
City
city
=
pick
(
mouseX
,
mouseY
);
if
(
city
!=
null
)
{
if
(
lastCitySelected
!=
city
)
{
lastCitySelected
=
city
;
println
(
city
.
name
);
}
}
}
City
pick
(
int
px
,
int
py
)
{
for
(
int
i
=
totalCount
-
1
;
i
>=
0
;
--
i
)
{
if
(
cities
[
i
].
contains
(
px
,
py
))
{
return
cities
[
i
];
}
}
return
null
;
}
}
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
register
or
sign in
to comment