Platform
Resources
Pricing
Sign in
Get started
Jeremy Wong
Software Engineer, Marathoner, Novice Baker, Reader and Writer.
Workspace
Fork
Public
By
Jeremy Wong
Edited
Feb 5, 2018
4 forks
Importers
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
p5
=
require
(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sketch
=
function
(
sketch
)
{
var
x
=
100
;
var
y
=
100
;
sketch
.
setup
=
function
(
)
{
sketch
.
createCanvas
(
container
.
width
,
container
.
height
)
;
}
;
sketch
.
draw
=
function
(
)
{
sketch
.
background
(
0
)
;
sketch
.
fill
(
100
,
100
,
200
)
;
sketch
.
rect
(
x
,
y
,
50
,
50
)
;
}
;
}
Insert cell
Insert cell
{
sketch
=>
{
// ...
// in setup function
const
canvas
=
sketch
.
createCanvas
(
container
.
width
,
container
.
height
)
;
canvas
.
parent
(
container
.
id
)
;
// ...
}
}
Insert cell
Insert cell
Insert cell
myP5
=
{
// Resets div container
p5Container
.
innerHTML
=
""
;
// Reinstantiate the p5 with the sketch
return
new
p5
(
sketch
,
p5Container
)
;
}
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
p5
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
container
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
p5Container
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sketch
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
myP5
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML