Platform
Resources
Pricing
Sign in
Get started
Harry Stevens
News and graphics at @ClimateLab, a project of @PostGraphics.
Workspace
Fork
Published
WebGL Utilities
By
Harry Stevens
Edited
Jun 30, 2020
Importers
WebGL Utilities
WebGL Coordinate Conversion
Insert cell
Insert cell
Insert cell
Insert cell
function
convert
(
p
,
w
=
300
,
h
=
150
)
{
return
[
p
[
0
]
/
w
*
2
-
1
,
p
[
1
]
/
h
*
2
-
1
]
;
}
Insert cell
convert
(
[
300
,
150
]
)
Insert cell
convert
(
[
150
,
75
]
)
Insert cell
convert
(
[
0
,
0
]
)
Insert cell
convert
(
[
1
,
1
]
,
1
,
1
)
;
Insert cell
convert
(
[
.5
,
.5
]
,
1
,
1
)
Insert cell
convert
(
[
0
,
0
]
,
1
,
1
)
;
Insert cell
Insert cell
function
convertAll
(
points
,
width
,
height
)
{
const
out
=
[
]
;
for
(
let
i
=
0
,
l
=
points
.
length
;
i
<
l
;
i
++
)
{
const
c
=
convert
(
points
[
i
]
,
width
,
height
)
;
out
.
push
(
c
[
0
]
)
;
out
.
push
(
c
[
1
]
)
;
}
return
new
Float32Array
(
out
)
;
}
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
convert
Add comment
Copy import
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
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
convertAll
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
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML