From b39a09cc86571a237da212d3581dc8d6f098d771 Mon Sep 17 00:00:00 2001 From: msakuta Date: Tue, 14 Jun 2022 04:33:44 +0900 Subject: [PATCH] Initial commit --- .gitignore | 1 + Cargo.lock | 1701 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 18 + index.html | 24 + index.js | 8 + src/app_data.rs | 87 ++ src/lib.rs | 51 ++ src/macros.rs | 12 + src/main.rs | 40 + src/marching_squares.rs | 131 +++ src/mesh_widget.rs | 91 +++ src/paint_board.rs | 110 +++ src/perlin_noise.rs | 108 +++ src/shape.rs | 12 + src/widget.rs | 103 +++ 15 files changed, 2497 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 index.html create mode 100644 index.js create mode 100644 src/app_data.rs create mode 100644 src/lib.rs create mode 100644 src/macros.rs create mode 100644 src/main.rs create mode 100644 src/marching_squares.rs create mode 100644 src/mesh_widget.rs create mode 100644 src/paint_board.rs create mode 100644 src/perlin_noise.rs create mode 100644 src/shape.rs create mode 100644 src/widget.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d4dd03e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1701 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" + +[[package]] +name = "approx" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "as-slice" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" +dependencies = [ + "generic-array 0.12.4", + "generic-array 0.13.3", + "generic-array 0.14.5", + "stable_deref_trait", +] + +[[package]] +name = "associative-cache" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46016233fc1bb55c23b856fe556b7db6ccd05119a0a392e04f0b3b7c79058f16" + +[[package]] +name = "atk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812b4911e210bd51b24596244523c856ca749e6223c50a7fbbba3f89ee37c426" +dependencies = [ + "atk-sys", + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f530e4af131d94cc4fa15c5c9d0348f0ef28bac64ba660b6b2a1cf2605dedfce" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base-x" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc19a4937b4fbd3fe3379793130e42060d10627a360f2127802b10b87e7baf74" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cairo-rs" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5c0f2e047e8ca53d0ff249c54ae047931d7a6ebe05d00af73e0ffeb6e34bdb8" +dependencies = [ + "bitflags", + "cairo-sys-rs", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "thiserror", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed2639b9ad5f1d6efa76de95558e11339e7318426d84ac4890b86c03e828ca7" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cgmath" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317" +dependencies = [ + "approx", + "num-traits", +] + +[[package]] +name = "cocoa" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +dependencies = [ + "bitflags", + "block", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" +dependencies = [ + "log", + "web-sys", +] + +[[package]] +name = "const_fn" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + +[[package]] +name = "core-text" +version = "19.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" +dependencies = [ + "core-foundation", + "core-graphics", + "foreign-types", + "libc", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + +[[package]] +name = "druid" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839a2e96089d82842923b3822e6977a8d2aace3f3706e6db9bae4d9c765e5697" +dependencies = [ + "console_log", + "druid-derive", + "druid-shell", + "fluent-bundle", + "fluent-langneg", + "fluent-syntax", + "fnv", + "instant", + "log", + "simple_logger", + "unic-langid", + "unicode-segmentation", + "xi-unicode 0.3.0", +] + +[[package]] +name = "druid-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57b53fcfe6b4585894e0d0417dad85fd21aa7bd96c9d646d54d5a4638a484b18" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "druid-shell" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b867ffe113aa77b75c0fcd2585360a3a4d17c758c44f4e87aadc71712fd1763" +dependencies = [ + "anyhow", + "bitflags", + "block", + "cairo-rs", + "cfg-if", + "cocoa", + "core-graphics", + "foreign-types", + "gdk", + "gdk-pixbuf", + "gdk-sys", + "gio", + "glib", + "glib-sys", + "gtk", + "gtk-sys", + "instant", + "js-sys", + "keyboard-types", + "kurbo", + "lazy_static", + "log", + "objc", + "piet-common", + "scopeguard", + "time", + "wasm-bindgen", + "web-sys", + "winapi", + "wio", +] + +[[package]] +name = "dwrote" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" +dependencies = [ + "lazy_static", + "libc", + "winapi", + "wio", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "fluent-bundle" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a094d494ab2ed06077e9a95f4e47f446c376de95f6c93045dd88c499bfcd70" +dependencies = [ + "fluent-langneg", + "fluent-syntax", + "intl-memoizer", + "intl_pluralrules", + "rental", + "smallvec", + "unic-langid", +] + +[[package]] +name = "fluent-langneg" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94" +dependencies = [ + "unic-langid", +] + +[[package]] +name = "fluent-syntax" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac0f7e83d14cccbf26e165d8881dcac5891af0d85a88543c09dd72ebd31d91ba" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "futures" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-executor" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" + +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gdk" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db00839b2a68a7a10af3fa28dfb3febaba3a20c3a9ac2425a33b7df1f84a6b7d" +dependencies = [ + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6dae3cb99dd49b758b88f0132f8d401108e63ae8edd45f432d42cdff99998a" +dependencies = [ + "gdk-pixbuf-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "libc", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bfe468a7f43e97b8d193a762b6c5cf67a7d36cacbc0b9291dbcae24bfea1e8f" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a9653cfc500fd268015b1ac055ddbc3df7a5c9ea3f4ccef147b3957bd140d69" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "geo" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7e2e3be15682a45e9dfe9a04f84bff275390047204ab22f3c6b2312fcfb9e24" +dependencies = [ + "geo-types", + "geographiclib-rs", + "log", + "num-traits", + "robust", + "rstar", +] + +[[package]] +name = "geo-types" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9537881a3d2941ff3fe901e744c45f0fa4c142334f499f27d26be1d72299ba8" +dependencies = [ + "approx", + "num-traits", + "rstar", +] + +[[package]] +name = "geographiclib-rs" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdbd3cdc1856ca7736763d2784671c2c9b0093f0ee47e2bed0059feed6afca89" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "gio" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb60242bfff700772dae5d9e3a1f7aa2e4ebccf18b89662a16acb2822568561" +dependencies = [ + "bitflags", + "futures", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", + "thiserror", +] + +[[package]] +name = "gio-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e24fb752f8f5d2cf6bbc2c606fd2bc989c81c5e2fe321ab974d54f8b6344eac" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "glib" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c685013b7515e668f1b57a165b009d4d28cb139a8a989bbd699c10dad29d0c5" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", +] + +[[package]] +name = "glib-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039" +dependencies = [ + "anyhow", + "heck", + "itertools", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "glib-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e9b997a66e9a23d073f2b1abb4dbfc3925e0b8952f67efd8d9b6e168e4cdc1" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "gobject-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952133b60c318a62bf82ee75b93acc7e84028a093e06b9e27981c2b6fe68218c" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gtk" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f022f2054072b3af07666341984562c8e626a79daa8be27b955d12d06a5ad6a" +dependencies = [ + "atk", + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "cc", + "gdk", + "gdk-pixbuf", + "gdk-pixbuf-sys", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk-sys", + "libc", + "once_cell", + "pango", + "pango-sys", + "pkg-config", +] + +[[package]] +name = "gtk-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89acda6f084863307d948ba64a4b1ef674e8527dddab147ee4cdcc194c880457" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "hash32" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc" +dependencies = [ + "byteorder", +] + +[[package]] +name = "heapless" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634bd4d29cbf24424d0a4bfcbf80c6960129dc24424752a7d1d1390607023422" +dependencies = [ + "as-slice", + "generic-array 0.14.5", + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "intl-memoizer" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c310433e4a310918d6ed9243542a6b83ec1183df95dff8f23f87bb88a264a66f" +dependencies = [ + "type-map", + "unic-langid", +] + +[[package]] +name = "intl_pluralrules" +version = "7.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b18f988384267d7066cc2be425e6faf352900652c046b6971d2e228d3b1c5ecf" +dependencies = [ + "tinystr", + "unic-langid", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "js-sys" +version = "0.3.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keyboard-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a989afac88279b0482f402d234b5fbd405bf1ad051308595b58de4e6de22346b" +dependencies = [ + "bitflags", +] + +[[package]] +name = "kurbo" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16cb54cd28cb3d2e964d9444ca185676a94fd9b7cce5f02b22c717947ed8e9a2" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mesh-transform-rs" +version = "0.1.0" +dependencies = [ + "cgmath", + "console_error_panic_hook", + "druid", + "geo", + "serde_json", + "wasm-bindgen", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "once_cell" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "pango" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9937068580bebd8ced19975938573803273ccbcbd598c58d4906efd4ac87c438" +dependencies = [ + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d2650c8b62d116c020abd0cea26a4ed96526afda89b1c4ea567131fdefc890" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "pdqselect" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27" + +[[package]] +name = "piet" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f6fc8efb51e16882094fbfcd4b931f59773be4176f2512c6248e081a1b41f" +dependencies = [ + "kurbo", + "unic-bidi", +] + +[[package]] +name = "piet-cairo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91834682e7b19ae26cebc0f3ad83a36d4ae2e4f95b85f2c93a34873f38319d29" +dependencies = [ + "cairo-rs", + "piet", + "unicode-segmentation", + "xi-unicode 0.2.1", +] + +[[package]] +name = "piet-common" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77cbcec97e9c07c2a95bfa0d6c475fe2e22ae436e5209f9b7e03685c472c3976" +dependencies = [ + "cairo-rs", + "cairo-sys-rs", + "cfg-if", + "core-graphics", + "piet", + "piet-cairo", + "piet-coregraphics", + "piet-direct2d", + "piet-web", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "piet-coregraphics" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5af1ce12cf0a1dc7f894f6f90ba62467d685a39b7f1d235516c8688f98e92d18" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "core-graphics", + "core-text", + "foreign-types", + "piet", +] + +[[package]] +name = "piet-direct2d" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "019643fceb3667f79d1ed38101218cbabbfeb55c95f1a918b678e32042928418" +dependencies = [ + "associative-cache", + "dwrote", + "piet", + "utf16_lit", + "winapi", + "wio", +] + +[[package]] +name = "piet-web" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051dd0e8856c9837af0204f72b11636c8afba271a458eb877c887580208fa0ab" +dependencies = [ + "js-sys", + "piet", + "unicode-segmentation", + "wasm-bindgen", + "web-sys", + "xi-unicode 0.3.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rental" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc89fe2acac36d212474d138aaf939c04a82df5b61d07011571ebce5aef81f2e" +dependencies = [ + "rental-impl", + "stable_deref_trait", +] + +[[package]] +name = "rental-impl" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "robust" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5864e7ef1a6b7bcf1d6ca3f655e65e724ed3b52546a0d0a663c991522f552ea" + +[[package]] +name = "rstar" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a45c0e8804d37e4d97e55c6f258bc9ad9c5ee7b07437009dd152d764949a27c" +dependencies = [ + "heapless", + "num-traits", + "pdqselect", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" + +[[package]] +name = "serde_derive" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +dependencies = [ + "sha1_smol", +] + +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + +[[package]] +name = "simple_logger" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45b60258a35dc3cb8a16890b8fd6723349bfa458d7960e25e633f1b1c19d7b5e" +dependencies = [ + "atty", + "log", + "winapi", +] + +[[package]] +name = "slab" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + +[[package]] +name = "strum" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" + +[[package]] +name = "strum_macros" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-deps" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b" +dependencies = [ + "heck", + "pkg-config", + "strum", + "strum_macros", + "thiserror", + "toml", + "version-compare", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "type-map" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d3364c5e96cb2ad1603037ab253ddd34d7fb72a58bdddf4b7350760fc69a46" +dependencies = [ + "rustc-hash", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unic-bidi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1356b759fb6a82050666f11dce4b6fe3571781f1449f3ef78074e408d468ec09" +dependencies = [ + "matches", + "unic-ucd-bidi", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-langid" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5" +dependencies = [ + "unic-langid-impl", +] + +[[package]] +name = "unic-langid-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d" +dependencies = [ + "tinystr", +] + +[[package]] +name = "unic-ucd-bidi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d568b51222484e1f8209ce48caa6b430bf352962b877d592c29ab31fb53d8c" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "utf16_lit" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403231d2fb8f0f55daf24cd03571f4fc1bb856e0fa98c1832bbae3f6ff7e7a07" + +[[package]] +name = "version-compare" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" + +[[package]] +name = "web-sys" +version = "0.3.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi", +] + +[[package]] +name = "xi-unicode" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e71b85d8b1b8bfaf4b5c834187554d201a8cd621c2bbfa33efd41a3ecabd48b2" + +[[package]] +name = "xi-unicode" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a67300977d3dc3f8034dae89778f502b6ba20b269527b3223ba59c0cf393bb8a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0cad349 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "mesh-transform-rs" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +druid = "0.7.0" +cgmath = "0.18.0" +geo = "0.20.1" +serde_json = "1.0" + +wasm-bindgen = "0.2.67" +console_error_panic_hook = "0.1.6" diff --git a/index.html b/index.html new file mode 100644 index 0000000..daf8dd0 --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + Druid web example + + + + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..59cb483 --- /dev/null +++ b/index.js @@ -0,0 +1,8 @@ +import init, { wasm_main } from "./pkg/mesh_transform_rs.js"; + +async function run() { + await init(); + wasm_main(); +} + +run(); diff --git a/src/app_data.rs b/src/app_data.rs new file mode 100644 index 0000000..bd9ea31 --- /dev/null +++ b/src/app_data.rs @@ -0,0 +1,87 @@ +use crate::perlin_noise::{gen_terms, perlin_noise_pixel, Xor128}; +use druid::{Data, Lens, Vec2}; +use std::{ + cell::{Cell, RefCell}, + rc::Rc, +}; + +#[allow(dead_code)] +pub(crate) type Polygon = geo::Polygon; + +#[derive(Clone, PartialEq, Eq, Data)] +pub(crate) enum LineMode { + Line, + Polygon, +} + +#[derive(Clone, Lens, Data)] +pub(crate) struct AppData { + pub(crate) rows_text: String, + pub(crate) columns_text: String, + pub(crate) width_text: String, + pub(crate) vertex_edit: bool, + pub(crate) group_edit: bool, + pub(crate) group_radius_text: String, + pub(crate) xs: usize, + pub(crate) ys: usize, + pub(crate) board: Rc>, + pub(crate) line_mode: LineMode, + pub(crate) origin: Vec2, + pub(crate) scale: f64, + pub(crate) message: String, + pub(crate) get_mesh_time: f64, + #[data(ignore)] + pub(crate) render_mesh_time: Cell, + pub(crate) render_stats: Rc>, +} + +impl AppData { + pub(crate) fn new() -> Self { + let rows = 8; + let columns = 8; + let width = 100.; + let group_radius = 100.; + + let xs = 128; + let ys = 128; + + let bits = 6; + let mut xor128 = Xor128::new(123513); + let terms = gen_terms(&mut xor128, bits); + + let mut board = vec![false; xs * ys]; + for (i, cell) in board.iter_mut().enumerate() { + let xi = i % xs; + let yi = i / ys; + let dx = (xi as isize - xs as isize / 2) as f64; + let dy = (yi as isize - ys as isize / 2) as f64; + let noise_val = perlin_noise_pixel(xi as f64, yi as f64, bits, &terms, 0.5); + *cell = 0. + (noise_val - 0.5 * (dx * dx + dy * dy).sqrt() / xs as f64) > -0.125; + } + + println!( + "true: {}, false: {}", + board.iter().filter(|c| **c).count(), + board.iter().filter(|c| !**c).count() + ); + + Self { + rows_text: rows.to_string(), + columns_text: columns.to_string(), + width_text: width.to_string(), + vertex_edit: true, + group_edit: true, + group_radius_text: group_radius.to_string(), + xs, + ys, + board: Rc::new(board), + line_mode: LineMode::Line, + origin: Vec2::new(400., 400.), + scale: 1., + message: "".to_string(), + render_mesh_time: Cell::new(0.), + get_mesh_time: 0., + render_stats: Rc::new(RefCell::new("".to_string())), + } + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..dbc8be1 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,51 @@ +mod app_data; +mod marching_squares; +mod mesh_widget; +mod paint_board; +mod perlin_noise; +mod shape; +mod widget; +#[macro_use] +mod macros; + +use crate::{app_data::AppData, widget::make_widget}; +use druid::{AppLauncher, Data, Lens, LocalizedString, Size, WindowDesc}; +use wasm_bindgen::prelude::*; + +#[derive(Clone, Data, Lens)] +struct HelloState { + name: String, +} + +#[wasm_bindgen] +pub fn wasm_main() { + // This hook is necessary to get panic messages in the console + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + main() +} + +pub fn main() { + let window = WindowDesc::new(make_widget) + .window_size(Size { + width: 1200.0, + height: 800.0, + }) + .resizable(true) + .title( + LocalizedString::new("custom-widget-demo-window-title") + .with_placeholder("Mesh Transform Editor"), + ); + + AppLauncher::with_window(window) + .use_simple_logger() + .launch(AppData::new()) + .expect("launch failed"); +} + +#[macro_export] +macro_rules! measure_time { + {$exec:expr} => {{ + $exec; + 0. + }} +} diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..b5a1f59 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,12 @@ +#[macro_export] +macro_rules! unwrap_return { + {$result:expr} => { + match $result { + Ok(res) => res, + Err(err) => { + println!("Oops: {:?}", err); + return; + } + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..2b4e2da --- /dev/null +++ b/src/main.rs @@ -0,0 +1,40 @@ +mod app_data; +mod marching_squares; +mod mesh_widget; +mod paint_board; +mod perlin_noise; +mod shape; +mod widget; +#[macro_use] +mod macros; + +use crate::{app_data::AppData, widget::make_widget}; +use druid::widget::prelude::*; +use druid::{AppLauncher, LocalizedString, WindowDesc}; + +pub fn main() { + let window = WindowDesc::new(make_widget) + .window_size(Size { + width: 1200.0, + height: 800.0, + }) + .resizable(true) + .title( + LocalizedString::new("custom-widget-demo-window-title") + .with_placeholder("Mesh Transform Editor"), + ); + + AppLauncher::with_window(window) + .use_simple_logger() + .launch(AppData::new()) + .expect("launch failed"); +} + +#[macro_export] +macro_rules! measure_time { + {$exec:expr} => {{ + let start = std::time::Instant::now(); + $exec; + start.elapsed().as_micros() as f64 / 1e6 + }} +} diff --git a/src/marching_squares.rs b/src/marching_squares.rs new file mode 100644 index 0000000..6d691a1 --- /dev/null +++ b/src/marching_squares.rs @@ -0,0 +1,131 @@ +use crate::shape::Shape; + +/// A trait for objects that can behave like a field of booleans. +pub(crate) trait AsBoolField { + fn get(&self, pos: (isize, isize)) -> bool; +} + +/// A concrete type of a boolean field. +#[derive(Clone, Copy)] +pub(crate) struct BoolField<'a> { + field: &'a [bool], + shape: Shape, +} + +impl<'a> BoolField<'a> { + pub(crate) fn new(field: &'a [bool], shape: Shape) -> Self { + Self { field, shape } + } +} + +impl<'a> AsBoolField for BoolField<'a> { + fn get(&self, pos: (isize, isize)) -> bool { + self.field[pos.0 as usize + pos.1 as usize * self.shape.0 as usize] + } +} + +/// A concrete type of a boolean field. +/// Since we need a threshold value to compare, we have an extra field compared to [`BoolField`]. +#[derive(Clone, Copy)] +pub(crate) struct F64Field<'a> { + field: &'a [f64], + shape: Shape, + threshold: f64, +} + +impl<'a> F64Field<'a> { + fn _new(field: &'a [f64], shape: Shape, threshold: f64) -> Self { + Self { + field, + shape, + threshold, + } + } +} + +impl<'a> AsBoolField for F64Field<'a> { + fn get(&self, pos: (isize, isize)) -> bool { + self.threshold < self.field[pos.0 as usize + pos.1 as usize * self.shape.0 as usize] + } +} + +pub(crate) fn pick_bits(f: T, pos: (isize, isize)) -> u8 { + (f.get((pos.0, pos.1))) as u8 + | ((f.get((pos.0 + 1, pos.1)) as u8) << 1) + | ((f.get((pos.0 + 1, pos.1 + 1)) as u8) << 2) + | ((f.get((pos.0, pos.1 + 1)) as u8) << 3) +} + +/// LINE_WIDTH won't work well with cargo fmt +const LW: f32 = 0.4; + +/// buffer for vertex shader, use with SliceFlatExt::flat() +pub(crate) const CELL_POLYGON_BUFFER: [[f32; 8]; 7] = [ + [1., 1., -1., 1., -1., -1., 1., -1.], + [1., LW, -1., LW, -1., -LW, 1., -LW], + [LW, 1., -LW, 1.0, -LW, -1., LW, -1.], + [-1., -LW, -LW, -1., LW, -1., -1., LW], + [LW, -1., 1., -LW, 1., LW, -LW, -1.], + [1., LW, LW, 1., -LW, 1., 1., -LW], + [-LW, 1., -1., LW, -1., -LW, LW, 1.], +]; + +/// Index into CELL_POLYGON_BUFFER +pub(crate) fn cell_polygon_index(bits: u8) -> i32 { + match bits { + 1 | 14 => 12, + 2 | 13 => 16, + 4 | 11 => 20, + 8 | 7 => 24, + 3 | 12 => 4, + 9 | 6 => 8, + _ => 0, + } +} + +/// Whether the pixel is a border +pub(crate) fn _border_pixel(idx: u8) -> bool { + match idx { + 0 => false, + 1..=14 => true, + 15 => false, + _ => panic!("index must be in 0-15!"), + } +} + +pub(crate) fn cell_lines(bits: u8) -> Vec<[[f32; 2]; 2]> { + match bits { + 1 | 14 => vec![[[0.5, 0.], [0., 0.5]]], + 2 | 13 => vec![[[0.5, 0.], [1., 0.5]]], + 4 | 11 => vec![[[1., 0.5], [0.5, 1.]]], + 8 | 7 => vec![[[0.5, 1.], [0., 0.5]]], + 3 | 12 => vec![[[1., 0.5], [0., 0.5]]], + 9 | 6 => vec![[[0.5, 1.], [0.5, 0.]]], + 5 | 10 => vec![[[0.5, 0.], [0., 0.5]], [[1., 0.5], [0.5, 1.]]], + _ => vec![], + } +} + +#[test] +fn test_bits() { + assert_eq!( + pick_bits(F64Field::new(&[0., 0., 0., 0.], (2, 2), 0.5), (0, 0)), + 0 + ); + assert_eq!( + pick_bits(F64Field::new(&[1., 0., 0., 0.], (2, 2), 0.5), (0, 0)), + 1 + ); + assert_eq!( + pick_bits(F64Field::new(&[0., 1., 0., 0.], (2, 2), 0.5), (0, 0)), + 2 + ); + assert_eq!( + pick_bits(F64Field::new(&[0., 0., 1., 0.], (2, 2), 0.5), (0, 0)), + 8 + ); + assert_eq!( + pick_bits(F64Field::new(&[0., 0., 0., 1.], (2, 2), 0.5), (0, 0)), + 4 + ); +} diff --git a/src/mesh_widget.rs b/src/mesh_widget.rs new file mode 100644 index 0000000..59951ed --- /dev/null +++ b/src/mesh_widget.rs @@ -0,0 +1,91 @@ +use crate::{app_data::AppData, paint_board::paint_board}; +use druid::widget::prelude::*; +use druid::{Affine, Vec2}; + +pub(crate) struct MeshWidget { + panning: Option, +} + +impl MeshWidget { + pub(crate) fn new() -> Self { + Self { panning: None } + } +} + +impl AppData { + pub(crate) fn view_transform(&self) -> Affine { + Affine::scale(self.scale) * Affine::translate(self.origin) + } +} + +impl Widget for MeshWidget { + fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut AppData, _env: &Env) { + match event { + Event::WindowConnected => { + ctx.request_paint(); + // let deadline = Duration::from_millis(data.iter_interval() as u64); + // self.timer_id = ctx.request_timer(deadline); + } + Event::MouseDown(e) => { + self.panning = Some(e.pos.to_vec2()); + } + Event::MouseUp(_e) => { + self.panning = None; + } + Event::MouseMove(e) => { + if let Some(ref mut panning) = self.panning { + let newpos = Vec2::new(e.pos.x, e.pos.y); + let delta = (newpos - *panning) / data.scale; + data.origin += delta; + *panning = newpos; + return; + } + } + Event::Wheel(e) => { + let old_offset = data.view_transform().inverse() * e.pos; + if e.wheel_delta.y < 0. { + data.scale *= 1.2; + } else if 0. < e.wheel_delta.y { + data.scale /= 1.2; + } + let new_offset = data.view_transform().inverse() * e.pos; + let diff = new_offset.to_vec2() - old_offset.to_vec2(); + data.origin += diff; + } + _ => {} + } + } + + fn lifecycle( + &mut self, + _ctx: &mut LifeCycleCtx, + _event: &LifeCycle, + _data: &AppData, + _env: &Env, + ) { + } + + fn update(&mut self, ctx: &mut UpdateCtx, _old_data: &AppData, _data: &AppData, _env: &Env) { + ctx.request_paint(); + } + + fn layout( + &mut self, + _layout_ctx: &mut LayoutCtx, + bc: &BoxConstraints, + _data: &AppData, + _env: &Env, + ) -> Size { + bc.max() + // let max_size = bc.max(); + // let min_side = max_size.height.min(max_size.width);//.min(800.); + // Size { + // width: min_side, + // height: min_side, + // } + } + + fn paint(&mut self, ctx: &mut PaintCtx, data: &AppData, _env: &Env) { + paint_board(ctx, data); + } +} diff --git a/src/paint_board.rs b/src/paint_board.rs new file mode 100644 index 0000000..01e71f3 --- /dev/null +++ b/src/paint_board.rs @@ -0,0 +1,110 @@ +use crate::{ + app_data::{AppData, LineMode}, + marching_squares::{cell_lines, cell_polygon_index, pick_bits, BoolField, CELL_POLYGON_BUFFER}, +}; +use druid::widget::prelude::*; +use druid::{ + piet::kurbo::{BezPath, Line}, + Affine, Color, Point, Rect, +}; + +const OBSTACLE_COLOR: Color = Color::rgb8(63, 63, 63); +const BACKGROUND_COLOR: Color = Color::rgb8(127, 127, 127); + +pub(crate) fn paint_board(ctx: &mut PaintCtx, data: &AppData) { + let (w0, h0) = (32., 32.); + let cell_size = (28., 28.); + + let view_transform = data.view_transform(); + + ctx.save().unwrap(); + ctx.transform(view_transform); + + let (xs, ys) = (data.xs, data.ys); + for (i, cell) in data.board.iter().enumerate() { + let xi = i % xs; + let yi = i / ys; + let point = Point { + x: w0 * xi as f64, + y: h0 * yi as f64, + }; + let rect = Rect::from_origin_size(point, cell_size); + ctx.fill( + rect, + if *cell { + &BACKGROUND_COLOR + } else { + &OBSTACLE_COLOR + }, + ); + } + + let shape = (xs as isize, ys as isize); + + let scale_transform = /*view_transform*/ Affine::scale(w0); + + const RED_COLOR: Color = Color::rgb8(255, 0, 0); + + let field = BoolField::new(data.board.as_ref(), shape); + + let mut contours = 0; + match data.line_mode { + LineMode::Line => { + ctx.restore().unwrap(); + for y in 0..ys - 1 { + for x in 0..xs - 1 { + let bits = pick_bits(field, (x as isize, y as isize)); + + if bits == 0 || bits == 15 { + continue; + } + + let lines = cell_lines(bits); + let to_point = |p: [f32; 2]| { + Point::new( + (p[0] as f64 + x as f64 + 0.5) * w0, + (p[1] as f64 + y as f64 + 0.5) * h0, + ) + }; + for line in lines { + let line = view_transform * Line::new(to_point(line[0]), to_point(line[1])); + ctx.stroke(line, &RED_COLOR, 2.0); + } + contours += 1; + } + } + } + LineMode::Polygon => { + for y in 0..ys - 1 { + for x in 0..xs - 1 { + let bits = pick_bits(field, (x as isize, y as isize)); + + if bits == 0 || bits == 15 { + continue; + } + + let idx = (cell_polygon_index(bits) / 4) as usize; + + let poly = CELL_POLYGON_BUFFER[idx as usize]; + let mut path = BezPath::new(); + let to_point = |i: usize| { + Point::new( + (poly[i * 2] as f64) / 2. + 1. + x as f64, + (poly[i * 2 + 1] as f64) / 2. + 1. + y as f64, + ) + }; + path.move_to(scale_transform * to_point(0)); + path.line_to(scale_transform * to_point(1)); + path.line_to(scale_transform * to_point(2)); + path.line_to(scale_transform * to_point(3)); + path.close_path(); + ctx.fill(path, &RED_COLOR); + contours += 1; + } + } + ctx.restore().unwrap(); + } + } + + *data.render_stats.borrow_mut() = format!("Drawn {} contours", contours); +} diff --git a/src/perlin_noise.rs b/src/perlin_noise.rs new file mode 100644 index 0000000..5475738 --- /dev/null +++ b/src/perlin_noise.rs @@ -0,0 +1,108 @@ +//! Perlin noise implementation from Wikipedia https://en.wikipedia.org/wiki/Perlin_noise + +pub(crate) fn perlin_noise_pixel( + x: f64, + y: f64, + bit: u32, + terms: &[[f64; 6]], + persistence: f64, +) -> f64 { + let mut sum = 0.; + let [mut maxv, mut f] = [0., 1.]; + for i in (0..bit).rev() { + let cell = 1 << i; + let fcell = cell as f64; + let dx = x / fcell; + let dy = y / fcell; + let x0 = dx.floor(); + let x1 = x0 + 1.; + let y0 = dy.floor(); + let y1 = y0 + 1.; + let a00 = noise_pixel(x0, y0, dx, dy, &terms[i as usize]); + let a01 = noise_pixel(x0, y1, dx, dy, &terms[i as usize]); + let a10 = noise_pixel(x1, y0, dx, dy, &terms[i as usize]); + let a11 = noise_pixel(x1, y1, dx, dy, &terms[i as usize]); + let fx = dx - x0; + let fy = dy - y0; + sum += ((a00 * (1. - fx) + a10 * fx) * (1. - fy) + (a01 * (1. - fx) + a11 * fx) * fy) * f; + maxv += f; + f *= persistence; + } + sum / maxv +} + +pub(crate) fn gen_terms(rng: &mut Xor128, bit: u32) -> Vec<[f64; 6]> { + (0..bit) + .map(|_| { + [ + 10000. * rng.next(), + 10000. * rng.next(), + std::f64::consts::PI * rng.next(), + 10000. * rng.next(), + 10000. * rng.next(), + std::f64::consts::PI * rng.next(), + ] + }) + .collect() +} + +fn random_gradient(x: f64, y: f64, terms: &[f64; 6]) -> [f64; 2] { + let random = 2920. + * (x * terms[0] + y * terms[1] + terms[2]).sin() + * (x * terms[3] * y * terms[4] + terms[5]).cos(); + [random.cos(), random.sin()] +} + +fn noise_pixel(ix: f64, iy: f64, x: f64, y: f64, terms: &[f64; 6]) -> f64 { + // Get gradient from integer coordinates + let gradient = random_gradient(ix, iy, terms); + + // Compute the distance vector + let dx = x - ix; + let dy = y - iy; + + // Compute the dot-product + dx * gradient[0] + dy * gradient[1] +} + +pub(crate) struct Xor128 { + x: u32, + y: u32, + z: u32, + w: u32, +} + +impl Xor128 { + pub fn new(seed: u32) -> Self { + let mut ret = Xor128 { + x: 294742812, + y: 3863451937, + z: 2255883528, + w: 824091511, + }; + if 0 < seed { + ret.x ^= seed; + ret.y ^= ret.x; + ret.z ^= ret.y; + ret.w ^= ret.z; + ret.nexti(); + } + ret.nexti(); + ret + } + + pub fn nexti(&mut self) -> u32 { + // T = (I + L^a)(I + R^b)(I + L^c) + // a = 13, b = 17, c = 5 + let t = self.x ^ (self.x << 15); + self.x = self.y; + self.y = self.z; + self.z = self.w; + self.w ^= (self.w >> 21) ^ (t ^ (t >> 4)); + self.w + } + + pub fn next(&mut self) -> f64 { + self.nexti() as f64 / 0xffffffffu32 as f64 + } +} diff --git a/src/shape.rs b/src/shape.rs new file mode 100644 index 0000000..b242767 --- /dev/null +++ b/src/shape.rs @@ -0,0 +1,12 @@ +pub(crate) trait Idx { + fn idx(&self, x: isize, y: isize) -> usize; +} + +pub(crate) type Shape = (isize, isize); + +impl Idx for Shape { + fn idx(&self, x: isize, y: isize) -> usize { + let (width, height) = self; + ((x + width) % width + (y + height) % height * width) as usize + } +} diff --git a/src/widget.rs b/src/widget.rs new file mode 100644 index 0000000..f2de490 --- /dev/null +++ b/src/widget.rs @@ -0,0 +1,103 @@ +use crate::{ + app_data::{AppData, LineMode}, + mesh_widget::MeshWidget, +}; +use druid::widget::prelude::*; +use druid::widget::{ + Button, Checkbox, CrossAxisAlignment, Flex, Label, RadioGroup, TextBox, WidgetExt, +}; +use druid::Color; + +const BG: Color = Color::rgb8(0, 0, 53 as u8); + +pub(crate) fn make_widget() -> impl Widget { + Flex::row() + .cross_axis_alignment(CrossAxisAlignment::Start) + .with_flex_child(MeshWidget::new(), 1.) + .with_flex_child( + Flex::column() + .cross_axis_alignment(CrossAxisAlignment::Start) + .with_child( + Flex::row() + .with_child( + Button::new("Create mesh") + .on_click(|ctx, data: &mut AppData, _: &Env| { + data.message = + "Define transform mesh by dragging vertices".to_string(); + ctx.request_paint(); + }) + .padding(5.0), + ) + .with_child( + Button::new("Cancel") + .on_click(|ctx, data: &mut AppData, _: &Env| { + data.message = "".to_string(); + ctx.request_paint(); + }) + .padding(5.0), + ), + ) + .with_child( + // Validity label + Label::new(|data: &AppData, _env: &_| data.message.clone()).padding(5.), + ) + .with_child( + Flex::row() + .with_child(Label::new("Line mode:").padding(3.0)) + .with_child( + RadioGroup::new([ + ("line", LineMode::Line), + ("polygon", LineMode::Polygon), + ]) + .lens(AppData::line_mode) + .padding(5.), + ), + ) + .with_child( + Flex::row() + .with_child(Label::new("Rows:").padding(3.0)) + .with_child(TextBox::new().lens(AppData::rows_text)) + .with_child(Label::new("Columns: ").padding(3.0)) + .with_child(TextBox::new().lens(AppData::columns_text)) + .padding(5.0), + ) + .with_child( + Flex::row() + .with_child( + Checkbox::new("Vertex edit") + .lens(AppData::vertex_edit) + .padding(3.0), + ) + .with_child( + Checkbox::new("Group edit") + .lens(AppData::group_edit) + .padding(3.0), + ) + .padding(5.0), + ) + .with_child( + Flex::row() + .with_child(Label::new("Group radius: ").padding(3.0)) + .with_child(TextBox::new().lens(AppData::group_radius_text)) + .padding(5.0), + ) + .with_child(Flex::row().with_flex_child( + Label::new(|data: &AppData, _: &_| data.render_stats.borrow().clone()), + 1., + )) + .with_child(Flex::row().with_flex_child( + Label::new(|data: &AppData, _: &_| { + format!( + "Render mesh: {:.06}s, Get mesh: {:.06}s", + data.render_mesh_time.get(), + &data.get_mesh_time + ) + }), + 1., + )) + .fix_width(400.) + .background(BG) + .expand_height(), + 0., + ) +}