「リサジュー図形」の版間の差分

vega
(具体例を2019.04.12の英語頁から追加)
(vega)
Image:Lissajous_curve_5by4.svg|{{math|1=''a'' = 5}}, {{math|1=''b'' = 4}} (5:4)
</gallery>
<graph mode="interactive">
{
"width": 450,
"height": 400,
"signals": [
{
"name": "point",
"init": 0,
"streams": [{"type": "mousemove","expr": "eventX()"}]
},
{
"name": "r",
"init": [1,1],
"streams": [
{
"type": "@w:wheel",
"expr": "[clamp(r[0]+(1-datum.data)*clamp(event.deltaY,-1,1),1,20),clamp(r[1]+datum.data*clamp(event.deltaY,-1,1),1,20)]"
}
]
}
],
"data": [
{
"name": "array",
"values": [0,1,2,3,4,5],
"transform": [
{"type": "cross"},
{
"type": "formula",
"field": "c",
"expr": "datum.a.data*6+datum.b.data"
},
{"type": "cross"},
{
"type": "formula",
"field": "c",
"expr": "datum.a.c*36+datum.b.c"
},
{
"type": "formula",
"field": "x",
"expr": "200+cos(r[0]*datum.c*PI*2/1295)*180"
},
{
"type": "formula",
"field": "y",
"expr": "200+sin(r[1]*datum.c*PI*2/1295+point*PI*2/400)*180"
}
]
},
{"name": "w","values": [0,1]}
],
"marks": [
{
"type": "line",
"from": {"data": "array"},
"properties": {
"update": {
"x": {"field": "x"},
"y": {"field": "y"},
"stroke": {"value": "black"},
"strokeWidth": {"value": 2}
}
}
},
{
"type": "rect",
"name": "w",
"from": {"data": "w"},
"properties": {
"enter": {
"x": {"value": 400},
"y": {"field": "data","mult": 120,"offset": 20},
"width": {"value": 40},
"height": {"value": 40},
"fill": {"value": "pink"},
"cursor": {"value": "pointer"}
}
}
},
{
"type": "text",
"interactive": false,
"from": {
"data": "w",
"transform": [
{
"type": "formula",
"field": "c",
"expr": "r[datum.data]"
}
]
},
"properties": {
"update": {
"x": {"value": 420},
"y": {"field": "data","mult": 120,"offset": 40},
"width": {"value": 40},
"height": {"value": 40},
"fill": {"value": "black"},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"font": {"value": "TakaoExGothic"},
"fontSize": {"value": 20},
"text": {"template": "{{datum.c}}"}
}
}
}
]
}
</graph>
 
 
== 脚注 ==
658

回編集