Platform
Resources
Pricing
Sign in
Get started
Ryo Sakai
Workspace
Fork
Published
By
Ryo Sakai
Edited
Feb 26, 2020
1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
iamge_width
=
+
arr
[
0
]
.
width
Insert cell
iamge_hight
=
arr
.
length
/
iamge_width
Insert cell
i_center_range
=
d3
.
extent
(
arr
,
d
=>
d
.
i_center
)
Insert cell
j_center_range
=
d3
.
extent
(
arr
,
d
=>
d
.
j_center
)
Insert cell
intensity_range
=
d3
.
extent
(
arr
,
d
=>
d
.
intensity_avg
)
Insert cell
Insert cell
color_scale
=
d3
.
scaleSequential
(
d3
.
interpolateGreys
)
.
domain
(
[
0
,
255
]
)
Insert cell
{
const
context
=
DOM
.
context2d
(
194
,
146
)
;
arr
.
forEach
(
d
=>
{
context
.
fillStyle
=
color_scale
(
d
.
intensity_avg
)
;
context
.
fillRect
(
d
.
i_center
,
d
.
j_center
,
1
,
1
)
;
}
)
;
return
context
.
canvas
;
}
Insert cell
{
const
mag
=
2
;
const
context
=
DOM
.
context2d
(
194
*
mag
,
146
*
mag
)
;
arr
.
forEach
(
(
d
,
i
)
=>
{
context
.
fillStyle
=
color_scale
(
d
.
intensity_avg
)
;
context
.
fillRect
(
d
.
i_center
*
mag
,
d
.
j_center
*
mag
,
mag
,
mag
)
;
}
)
;
return
context
.
canvas
;
}
Insert cell
d3
=
require
(
"d3@5"
)
Insert cell
md
`
* https://observablehq.com/@duncangeere/how-to-use-html5-canvas-part-one
* using p5
* https://observablehq.com/@jermspeaks/p5-test
`
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
arr
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
iamge_width
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
iamge_hight
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
i_center_range
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
j_center_range
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
intensity_range
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
color_scale
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
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML