Platform
Resources
Pricing
Sign in
Get started
Grant Custer
Design and coding @fastforwardlabs. Lately interested in grids. Continually interested in simulations. He/him.
Workspace
Fork
Published
By
Grant Custer
Edited
Oct 30, 2019
Insert cell
Insert cell
{
let
ctx
=
DOM
.
canvas
(
width
,
height
)
.
getContext
(
"2d"
)
;
let
coords
=
wave
(
)
for
(
let
i
=
0
;
i
<
width
;
i
++
)
{
let
[
x
,
y
]
=
coords
[
i
]
ctx
.
fillRect
(
x
,
y
+
(
height
-
1
)
/
2
,
1
,
1
)
;
}
return
ctx
.
canvas
}
Insert cell
function
wave
(
)
{
let
a
=
(
height
-
1
)
/
2
;
let
f
=
(
2
*
Math
.
PI
)
/
width
;
let
p
=
0
;
let
w
=
width
;
let
coords
=
[
]
;
for
(
let
t
=
0
;
t
<
w
;
t
++
)
{
let
y
=
a
*
Math
.
sin
(
f
*
t
+
p
)
coords
.
push
(
[
t
,
y
]
)
}
return
coords
}
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
wave
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
width
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
height
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML