Platform
Resources
Pricing
Sign in
Get started
Pablo Navarro
Mathematical engineer. Software developer at Act Now Coalition.
Workspace
Fork
Public
By
Pablo Navarro
Edited
Jun 11, 2023
1 fork
1 star
Insert cell
Insert cell
koch
=
new
LSystem
(
"F"
,
{
F
:
"F+F--F+F"
,
"+"
:
"+"
,
"-"
:
"-"
}
)
Insert cell
Insert cell
{
const
width
=
500
;
const
height
=
250
;
const
turtle
=
new
Turtle
(
{
width
,
height
,
x
:
0
,
y
:
height
}
)
;
const
d
=
2
;
const
t
=
85
;
const
n
=
7
;
drawSequence
(
turtle
,
koch
.
iteration
(
n
)
,
d
,
t
)
;
return
turtle
.
draw
(
)
;
}
Insert cell
{
const
width
=
500
;
const
height
=
250
;
const
turtle
=
new
Turtle
(
{
width
,
height
,
x
:
width
/
2
,
y
:
height
/
2
}
)
;
const
d
=
40
;
const
t
=
120
;
const
n
=
8
;
drawSequence
(
turtle
,
koch
.
iteration
(
n
)
,
d
,
t
)
;
return
turtle
.
draw
(
)
;
}
Insert cell
Insert cell
function
drawSequence
(
turtle
,
iteration
,
dist
,
angle
)
{
iteration
.
split
(
""
)
.
forEach
(
(
c
)
=>
{
switch
(
c
)
{
case
"F"
:
turtle
.
forward
(
dist
)
;
break
;
case
"+"
:
turtle
.
left
(
angle
)
;
break
;
case
"-"
:
turtle
.
right
(
angle
)
;
break
;
}
}
)
;
}
Insert cell
import
{
Turtle
}
from
"@pnavarrc/turtle-graphics"
Insert cell
import
{
LSystem
}
from
"@pnavarrc/l-systems"
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
koch
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
drawSequence
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML