Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
🚀
This server has been upgraded to GitLab release
15.7
.
🚀
Open sidebar
grains
grains-web
Commits
d28cd4ec
Commit
d28cd4ec
authored
May 17, 2017
by
Jens-Christian Fischer
Browse files
Draw lines on boids that influence their master
parent
752c6d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
mix.exs
View file @
d28cd4ec
...
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def
project
do
[
app:
:grains
,
version:
"0.0.7
0
"
,
version:
"0.0.7
1
"
,
elixir:
"~> 1.2"
,
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
...
...
web/static/js/presencesketch.js
View file @
d28cd4ec
...
...
@@ -279,10 +279,10 @@ Master.prototype.run = function(boids) {
let
list
=
_
.
filter
(
boids
,
function
(
boid
)
{
return
that
.
type
==
boid
.
type
;
});
this
.
flock
(
boids
);
this
.
flock
(
list
);
this
.
update
();
this
.
borders
();
this
.
render
();
this
.
render
(
list
);
this
.
send_osc
();
}
...
...
@@ -326,7 +326,7 @@ Boid.prototype.fillColor = function() {
return
color
;
}
Boid
.
prototype
.
render
=
function
()
{
Boid
.
prototype
.
render
=
function
(
list
)
{
this
.
p
.
fill
(
this
.
color
);
this
.
p
.
stroke
(
200
);
...
...
@@ -348,8 +348,19 @@ Boid.prototype.render = function() {
this
.
p
.
pop
();
this
.
adjust_radius
();
// the master looks at his minions and draws lines
if
(
list
)
{
let
neighbordist
=
250
;
_
.
each
(
list
,
function
(
boid
)
{
var
d
=
p5
.
Vector
.
dist
(
that
.
position
,
boid
.
position
);
if
((
d
>
0
)
&&
(
d
<
neighbordist
))
{
this
.
p
.
stroke
(
255
);
this
.
p
.
line
(
this
.
position
.
x
,
this
.
position
.
y
,
boid
.
position
.
x
,
boid
.
position
.
y
);
}
});
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment