Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

展示用インタラクティブ #130

Merged
merged 25 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
107b009
ファイルを追加
mitsuyoshi-yamazaki Oct 19, 2021
56d7f3e
通常の描画を実装
mitsuyoshi-yamazaki Oct 19, 2021
a19e4ef
クリック位置にDrawerを追加
mitsuyoshi-yamazaki Oct 19, 2021
de87e5d
タップによる模様生成を実装
mitsuyoshi-yamazaki Oct 23, 2021
c48d2b6
パラメータ数計数の問題を修正
mitsuyoshi-yamazaki Oct 23, 2021
2d95464
展示用ページを追加
mitsuyoshi-yamazaki Oct 24, 2021
db86c03
canvas範囲外のタップに反応する問題を修正
mitsuyoshi-yamazaki Oct 24, 2021
661f2eb
web閲覧用のレイアウトに変更
mitsuyoshi-yamazaki Oct 24, 2021
057bd42
インターフェースを表示
mitsuyoshi-yamazaki Oct 24, 2021
e1123b5
QRコード生成ライブラリを追加
mitsuyoshi-yamazaki Oct 24, 2021
bbc312a
QRコードの描画
mitsuyoshi-yamazaki Oct 24, 2021
b23e7b3
ルールに枝量の情報を付与できるよう変更
mitsuyoshi-yamazaki Oct 30, 2021
e52a15f
fix lint violation
mitsuyoshi-yamazaki Oct 30, 2021
71de9b2
Resultを実装
mitsuyoshi-yamazaki Oct 30, 2021
fd23495
パラメータエンコーダを実装
mitsuyoshi-yamazaki Oct 30, 2021
813336a
描画終了後にQRコードを表示
mitsuyoshi-yamazaki Oct 31, 2021
78d4a6d
停止条件を修正
mitsuyoshi-yamazaki Oct 31, 2021
9d487e5
共有用URLの生成
mitsuyoshi-yamazaki Oct 31, 2021
bdfa3ee
自動描画の切り替えを実装
mitsuyoshi-yamazaki Oct 31, 2021
db7c47e
フルスクリーン有効化フラグを実装
mitsuyoshi-yamazaki Oct 31, 2021
9c8f1fb
QRコードの最小解像度を設定
mitsuyoshi-yamazaki Oct 31, 2021
8252738
模様の再現を実装
mitsuyoshi-yamazaki Oct 31, 2021
52dbd35
シェア機能を一時無効化
mitsuyoshi-yamazaki Oct 31, 2021
3973f94
ルール一覧を復元
mitsuyoshi-yamazaki Oct 31, 2021
f6b337a
タップ不能期間はタップ指示を非表示
mitsuyoshi-yamazaki Oct 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins:
- '@typescript-eslint'
ignorePatterns:
- webpack.config.js
- libraries/
rules:
indent:
- warn
Expand Down
991 changes: 991 additions & 0 deletions libraries/qrcodegen.ts

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions pages/la_interactive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<html>
<head prefix="og: http://ogp.me/ns#">
<title></title>
<meta property="og:title" content="" />
<meta property="og:description" content="" />
<meta property="og:type" content="article" />
<meta property="og:image" content="" />
<meta property="og:url" content="https://mitsuyoshi-yamazaki.github.io/ALifeLab/pages/la_interactive.html" />

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-154586552-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', 'UA-154586552-1');
</script>

<meta http-equiv="content-type" charset="utf-8">
</head>

<body>
<div id="root"></div>

<script src="../dist/la_interactive.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions pages/la_interactive_fullscreen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<html>
<head prefix="og: http://ogp.me/ns#">
<title>Title</title>
<meta property="og:title" content="Title" />
<meta property="og:description" content="Description" />
<meta property="og:type" content="article" />
<meta property="og:image" content="" />
<meta property="og:url" content="https://mitsuyoshi-yamazaki.github.io/ALifeLab/pages/la_interactive_fullscreen.html" />

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-154586552-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', 'UA-154586552-1');
</script>

<meta http-equiv="content-type" charset="utf-8">
</head>

<body>
<div id="root"></div>

<script src="../dist/la_interactive_fullscreen.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions src/classes/result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type Succeeded<T> = {
readonly resultType: "succeeded"
readonly value: T
}

type Failed<T> = {
readonly resultType: "failed"
readonly reason: T
}

export type Result<T, U> = Succeeded<T> | Failed<U>
export const Result = {
Succeeded<T>(value: T): Succeeded<T> {
return {
resultType: "succeeded",
value,
}
},

Failed<T>(reason: T): Failed<T> {
return {
resultType: "failed",
reason,
}
},
}
28 changes: 14 additions & 14 deletions src/classes/url_parameter_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ export class URLParameterParser {
}

public hasKey(key: string, shortKey?: string): boolean {
if ((shortKey != undefined) && (this.rawParameters.get(shortKey) != undefined)) {
if ((shortKey != null) && (this.rawParameters.get(shortKey) != null)) {
return true
}

return this.rawParameters.get(key) != undefined
return this.rawParameters.get(key) != null
}

public int(key: string, defaultValue: number, shortKey?: string): number {
let rawValue: string | undefined
if (shortKey != undefined) {
if (shortKey != null) {
this.usedKeys.push(shortKey)
rawValue = this.rawParameters.get(shortKey)
}
this.usedKeys.push(key)
if (rawValue == undefined) {
if (rawValue == null) {
rawValue = this.rawParameters.get(key)
}
if (rawValue == undefined) {
if (rawValue == null) {
this.parameters.set(key, defaultValue)

return defaultValue
Expand All @@ -56,15 +56,15 @@ export class URLParameterParser {

public float(key: string, defaultValue: number, shortKey?: string): number {
let rawValue: string | undefined
if (shortKey != undefined) {
if (shortKey != null) {
this.usedKeys.push(shortKey)
rawValue = this.rawParameters.get(shortKey)
}
this.usedKeys.push(key)
if (rawValue == undefined) {
if (rawValue == null) {
rawValue = this.rawParameters.get(key)
}
if (rawValue == undefined) {
if (rawValue == null) {
this.parameters.set(key, defaultValue)

return defaultValue
Expand All @@ -82,15 +82,15 @@ export class URLParameterParser {

public boolean(key: string, defaultValue: boolean, shortKey?: string): boolean {
let rawValue: string | undefined
if (shortKey != undefined) {
if (shortKey != null) {
this.usedKeys.push(shortKey)
rawValue = this.rawParameters.get(shortKey)
}
this.usedKeys.push(key)
if (rawValue == undefined) {
if (rawValue == null) {
rawValue = this.rawParameters.get(key)
}
if (rawValue == undefined) {
if (rawValue == null) {
this.parameters.set(key, defaultValue)

return defaultValue
Expand All @@ -109,15 +109,15 @@ export class URLParameterParser {

public string(key: string, defaultValue: string, shortKey?: string): string {
let rawValue: string | undefined
if (shortKey != undefined) {
if (shortKey != null) {
this.usedKeys.push(shortKey)
rawValue = this.rawParameters.get(shortKey)
}
this.usedKeys.push(key)
if (rawValue == undefined) {
if (rawValue == null) {
rawValue = this.rawParameters.get(key)
}
if (rawValue == undefined) {
if (rawValue == null) {
this.parameters.set(key, defaultValue)

return defaultValue
Expand Down
189 changes: 125 additions & 64 deletions src/simulations/drawer/rule_examples.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,125 @@
export const exampleRules: string[] = [
// favorite
"A:-88,A,-152,A",

// 木
"A:119,I,121,H,-72,B;B:.;E:43,H;F:23,B,-26,B,127,E;I:153,F,-52,H;H:-20,A,-75,I,-149,E",

// 星
"A:-142,D;C:.;D:-31,S,-117,I;I:-99,J,-95,C;H:20,L,-30,A,90,H,-50,M,-27,H;J:.;M:.;L:.;S:135,H",

// 落書き
"A:116,E,-120,A,101,F,7,G,-99,D,-8,C;C:35,C;E:-32,F;D:.;G:-121,F,107,A;F:-122,C",

// 羽毛1
"A:-101,A,101,A,5,A",

// 羽毛2
"A:65,C,1,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
"A:65,C,289,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
"A:65,C,250,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
"A:65,C,220,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",

// 鱗
// "A:-28,A,117,A",

// ヒトデ1
"A:55,E,-97,D;B:-55,A,104,I;E:60,I,-133,E,-144,E,55,E,15,F,-40,E,-138,A;D:.;F:-39,B,-124,I,-143,H,96,B;I:.;H:.",

// ヒトデ2
"A:93,E;B:-113,H,-173,H,-76,E,152,C,62,C;C:-106,B;D:.;E:-34,F,-18,C,-41,B;F:-112,E,37,E,104,B;G:.;H:-155,F,130,D",

// ヒトデ3
"A:-64,C,120,A;C:125,B;B:-122,C,155,A",

// 珊瑚
"A:131,B;B:51,A,141,A",

// オウムガイ1
// "A:58,A,2,A,-65,A",

// オウムガイ2
"A:24,A,-21,A",

// 銀杏
"A:-12,A,25,A",

// 化石
"A:16,E,-41,B,-34,C;E:-172,H,167,E,141,B;B:.;C:-57,F;H:175,H,139,H,-121,D,140,H,-78,D,-65,A;F:.;D:.",

// 生痕化石
// "A:30,C,87,C;C:-179,C,-52,B;B:-136,B,-5,A",

// ウミユリ
"A:25,F,122,H,81,M;B:-155,G;D:-20,B,58,K,167,G;G:.;F:-39,N,145,F,161,J;H:.;K:.;J:.;M:104,D;N:-74,P;P:116,F,-8,P",

// ハンドスピナー
"A:17,C,121,B,-142,A,120,A,-162,D,103,B,164,C,-106,C;C:.;B:140,B,2,B,49,B;D:-169,A,-108,D,30,D,3,D,-174,B",

// 角
"A:4,A,154,B,-60,A;B:33,B",

// ウミウシ
"A:175,B,-114,A,41,B,132,D,-54,F;B:12,D,-63,C,62,F,-32,D,-144,C,101,C;C:51,A;D:133,A;E:143,A,-44,E;F:-112,B,5,A,82,B",
]
type RuleDefinition = {
readonly name: string
readonly rule: string
readonly preferredLineCountMultiplier: number
}

export const exampleRuleDefinitions: RuleDefinition[] = [
{
name: "お気に入り",
rule: "A:-88,A,-152,A",
preferredLineCountMultiplier: 1,
},
{
name: "木",
rule: "A:119,I,121,H,-72,B;B:.;E:43,H;F:23,B,-26,B,127,E;I:153,F,-52,H;H:-20,A,-75,I,-149,E",
preferredLineCountMultiplier: 1,
},
{
name: "星",
rule: "A:-142,D;C:.;D:-31,S,-117,I;I:-99,J,-95,C;H:20,L,-30,A,90,H,-50,M,-27,H;J:.;M:.;L:.;S:135,H",
preferredLineCountMultiplier: 1,
},
// { // 描画時間が長いので一時的に除外
// name: "落書き",
// rule: "A:116,E,-120,A,101,F,7,G,-99,D,-8,C;C:35,C;E:-32,F;D:.;G:-121,F,107,A;F:-122,C",
// preferredLineCountMultiplier: 1,
// },
{
name: "羽毛1",
rule: "A:-101,A,101,A,5,A",
preferredLineCountMultiplier: 1,
},
{
name: "Caduceus1",
rule: "A:65,C,1,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
preferredLineCountMultiplier: 1,
},
{
name: "Caduceus2",
rule: "A:65,C,289,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
preferredLineCountMultiplier: 1,
},
{
name: "Caduceus3",
rule: "A:65,C,250,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
preferredLineCountMultiplier: 1,
},
{
name: "Caduceus4",
rule: "A:65,C,220,D,137,B;B:174,C;C:66,C,2,A,118,B;D:14,A",
preferredLineCountMultiplier: 1,
},
// {
// name: "鱗",
// rule: "A:-28,A,117,A",
// preferredLineCountMultiplier: 1,
// },
{
name: "ヒトデ1",
rule: "A:55,E,-97,D;B:-55,A,104,I;E:60,I,-133,E,-144,E,55,E,15,F,-40,E,-138,A;D:.;F:-39,B,-124,I,-143,H,96,B;I:.;H:.",
preferredLineCountMultiplier: 1,
},
{
name: "ヒトデ2",
rule: "A:93,E;B:-113,H,-173,H,-76,E,152,C,62,C;C:-106,B;D:.;E:-34,F,-18,C,-41,B;F:-112,E,37,E,104,B;G:.;H:-155,F,130,D",
preferredLineCountMultiplier: 1,
},
{
name: "ヒトデ3",
rule: "A:-64,C,120,A;C:125,B;B:-122,C,155,A",
preferredLineCountMultiplier: 1,
},
{
name: "珊瑚",
rule: "A:131,B;B:51,A,141,A",
preferredLineCountMultiplier: 1,
},
{
name: "オウムガイ1",
rule: "A:58,A,2,A,-65,A",
preferredLineCountMultiplier: 1,
},
{
name: "オウムガイ2",
rule: "A:24,A,-21,A",
preferredLineCountMultiplier: 1,
},
{
name: "銀杏",
rule: "A:-12,A,25,A",
preferredLineCountMultiplier: 1,
},
{
name: "化石",
rule: "A:16,E,-41,B,-34,C;E:-172,H,167,E,141,B;B:.;C:-57,F;H:175,H,139,H,-121,D,140,H,-78,D,-65,A;F:.;D:.",
preferredLineCountMultiplier: 1,
},
{
name: "生痕化石",
rule: "A:30,C,87,C;C:-179,C,-52,B;B:-136,B,-5,A",
preferredLineCountMultiplier: 1,
},
{
name: "ウミユリ",
rule: "A:25,F,122,H,81,M;B:-155,G;D:-20,B,58,K,167,G;G:.;F:-39,N,145,F,161,J;H:.;K:.;J:.;M:104,D;N:-74,P;P:116,F,-8,P",
preferredLineCountMultiplier: 1,
},
{
name: "ハンドスピナー",
rule: "A:17,C,121,B,-142,A,120,A,-162,D,103,B,164,C,-106,C;C:.;B:140,B,2,B,49,B;D:-169,A,-108,D,30,D,3,D,-174,B",
preferredLineCountMultiplier: 1,
},
{
name: "角",
rule: "A:4,A,154,B,-60,A;B:33,B",
preferredLineCountMultiplier: 1,
},
{
name: "ウミウシ",
rule: "A:175,B,-114,A,41,B,132,D,-54,F;B:12,D,-63,C,62,F,-32,D,-144,C,101,C;C:51,A;D:133,A;E:143,A,-44,E;F:-112,B,5,A,82,B",
preferredLineCountMultiplier: 1,
},
]

export const exampleRules: string[] = exampleRuleDefinitions.map(definition => definition.rule)
5 changes: 0 additions & 5 deletions src/simulations/la_fullscreen/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export const main = (p: p5): void => {

p.draw = () => {
drawer.next(p)

// p.noFill()
// p.strokeWeight(10)
// p.stroke(0xff, 0,0)
// p.rect(10, 10, fieldSize.x - 20, fieldSize.y - 20)
}

p.mousePressed = () => {
Expand Down
11 changes: 11 additions & 0 deletions src/simulations/la_interactive/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { URLParameterParser } from "../../classes/url_parameter_parser"

const parameters = new URLParameterParser()

// 指定できるURLパラメータの一覧
// parameters.boolean/int/float/string("パラメータ名", 指定されない場合のデフォルト値, "パラメータ名省略記法")
export const constants = {
fullscreen: parameters.boolean("fullscreen", false, undefined),
fieldSize: parameters.int("size", 600, undefined),
rules: parameters.string("rules", "", undefined),
}
Loading