Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
a181503e
Commit
a181503e
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Interestingness metric
parent
4395b8ab
No related branches found
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
examples/processing/triangle16_attractor/Particle.pde
+5
-0
5 additions, 0 deletions
examples/processing/triangle16_attractor/Particle.pde
examples/processing/triangle16_attractor/triangle16_attractor.pde
+36
-7
36 additions, 7 deletions
.../processing/triangle16_attractor/triangle16_attractor.pde
with
41 additions
and
7 deletions
examples/processing/triangle16_attractor/Particle.pde
+
5
−
0
View file @
a181503e
...
...
@@ -35,5 +35,10 @@ class Particle
d
.
mult
(
coefficient
/
max
(
1
,
d
.
magSq
()));
velocity
.
add
(
d
);
}
float
energy
()
{
return
velocity
.
magSq
();
}
}
This diff is collapsed.
Click to expand it.
examples/processing/triangle16_attractor/triangle16_attractor.pde
+
36
−
7
View file @
a181503e
// Particle system with attraction to each corner of the triangle.
// Spawns centered around a random point, lives out a cycle and dies; the cycle repeats.
int
numParticles
=
2
0
;
int
numParticles
=
1
0
;
float
cornerCoefficient
=
0.2
;
int
integrationSteps
=
20
;
float
maxOpacity
=
100
;
float
epochStep
=
0.002
;
float
stepFast
=
1.0
/
40
;
float
stepSlow
=
1.0
/
1000
;
OPC
opc
;
PImage
dot
;
...
...
@@ -49,13 +50,13 @@ void beginEpoch()
epoch
=
0
;
// Center of bundle
float
s
=
0.
3
;
float
s
=
0.
5
;
float
cx
=
width
*
(
0.5
+
random
(
-
s
,
s
));
float
cy
=
height
*
(
0.5
+
random
(
-
s
,
s
));
// Half-width of particle bundle
float
w
=
width
*
0.
0
2
;
float
w
=
width
*
0.2
;
particles
=
new
Particle
[
numParticles
];
for
(
int
i
=
0
;
i
<
particles
.
length
;
i
++
)
{
color
rgb
=
colors
.
pixels
[
int
(
random
(
0
,
colors
.
width
*
colors
.
height
))];
...
...
@@ -68,12 +69,40 @@ void beginEpoch()
void
draw
()
{
background
(
0
);
epoch
+=
epochStep
;
// How much energy is still left?
float
energy
=
0
;
for
(
int
i
=
0
;
i
<
particles
.
length
;
i
++
)
{
energy
+=
particles
[
i
].
energy
();
}
// How bright is our brightest pixel?
float
brightness
=
0
;
for
(
int
i
=
0
;
i
<
opc
.
pixelLocations
.
length
;
i
++
)
{
color
rgb
=
opc
.
getPixel
(
i
);
brightness
=
max
(
brightness
,
max
(
red
(
rgb
),
max
(
blue
(
rgb
),
green
(
rgb
))));
}
brightness
/=
255.0
;
text
(
"Energy: "
+
energy
,
2
,
12
);
text
(
"Brightness: "
+
brightness
,
2
,
25
);
// What's interesting? Can we maintain high brightness and high energy?
// These are normally conflicting goals. If we've managed to balance the two,
// keep going to see how it turns out.
if
(
energy
>
1.5
&&
brightness
>
0.8
)
{
// Time moves slower when we're interested
epoch
+=
stepSlow
;
text
(
"+"
,
2
,
40
);
}
else
{
epoch
+=
stepFast
;
}
if
(
epoch
>
1
)
{
beginEpoch
();
}
for
(
int
step
=
0
;
step
<
integrationSteps
;
step
++
)
{
for
(
int
i
=
0
;
i
<
particles
.
length
;
i
++
)
{
particles
[
i
].
integrate
();
...
...
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