Compare commits
11 Commits
ba2e782af5
...
dab002bd15
| Author | SHA1 | Date | |
|---|---|---|---|
| dab002bd15 | |||
| f9480fac7c | |||
| 44fea82aaa | |||
| e9b8433117 | |||
| 957c286e59 | |||
| 63bd73e444 | |||
| c9eff77dff | |||
| 9677e8f8b4 | |||
| 8a5d9f1cd5 | |||
| 53d90b7328 | |||
| b59f214c67 |
476
Cargo.lock
generated
476
Cargo.lock
generated
@ -66,6 +66,56 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aliasable"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd"
|
||||
|
||||
[[package]]
|
||||
name = "alloc-no-stdlib"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
|
||||
|
||||
[[package]]
|
||||
name = "alloc-stdlib"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allsorts"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ec6442ceba5ea9d0201cd0afe96ecac4e8253e5f5be725e074747e6f4238735"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitreader",
|
||||
"brotli-decompressor",
|
||||
"byteorder",
|
||||
"crc32fast",
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
"glyph-names",
|
||||
"itertools 0.10.5",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"num-traits",
|
||||
"ouroboros",
|
||||
"pathfinder_geometry",
|
||||
"rustc-hash 1.1.0",
|
||||
"tinyvec",
|
||||
"ucd-trie",
|
||||
"unicode-canonical-combining-class",
|
||||
"unicode-general-category",
|
||||
"unicode-joining-type",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-activity"
|
||||
version = "0.6.0"
|
||||
@ -217,6 +267,15 @@ version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "bitreader"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "886559b1e163d56c765bc3a985febb4eee8009f625244511d8ee3c432e08c066"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.5.1"
|
||||
@ -226,6 +285,16 @@ dependencies = [
|
||||
"objc2 0.5.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli-decompressor"
|
||||
version = "4.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
@ -249,9 +318,15 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
version = "0.1.0"
|
||||
@ -415,7 +490,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad"
|
||||
dependencies = [
|
||||
"const_format_proc_macros",
|
||||
"konst",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -633,7 +707,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -666,12 +740,6 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.33.2"
|
||||
@ -815,6 +883,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumn"
|
||||
version = "0.1.14"
|
||||
@ -823,7 +900,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -867,12 +944,12 @@ checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59"
|
||||
|
||||
[[package]]
|
||||
name = "exmex"
|
||||
version = "0.17.5"
|
||||
version = "0.20.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf72d771d16d46af27985c8daa1ea6557ea4bcbd51f90a85285acdcd56072331"
|
||||
checksum = "114e4321fcb0242ffe3092e29a7a41c11fc119f1fa8e61cd21b72a68dd004aaa"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num",
|
||||
"num-traits",
|
||||
"regex",
|
||||
"smallvec",
|
||||
]
|
||||
@ -900,7 +977,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -932,11 +1009,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.5"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb"
|
||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"libz-sys",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
@ -964,7 +1042,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -982,16 +1060,6 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fsio"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4944f16eb6a05b4b2b79986b4786867bb275f52882adea798f17cc2588f25b2"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"rand 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "1.1.0"
|
||||
@ -1110,6 +1178,12 @@ dependencies = [
|
||||
"gl_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glyph-names"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3531d702d6c1a3ba92a5fb55a404c7b8c476c8e7ca249951077afcbe4bc807f"
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.3"
|
||||
@ -1137,6 +1211,12 @@ dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
@ -1326,18 +1406,6 @@ dependencies = [
|
||||
"str_stack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.17"
|
||||
@ -1421,37 +1489,12 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json5"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dadca0807203e4dad79bc9229663ea382d7e809eeb2213496a1ae4aff0069d6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "khronos_api"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||
|
||||
[[package]]
|
||||
name = "konst"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330f0e13e6483b8c34885f7e6c9f19b1a7bd449c673fbb948a51c99d66ef74f4"
|
||||
dependencies = [
|
||||
"konst_macro_rules",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "konst_macro_rules"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@ -1697,39 +1740,6 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-complex",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
@ -1746,37 +1756,6 @@ dependencies = [
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@ -1806,7 +1785,7 @@ dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2119,6 +2098,30 @@ dependencies = [
|
||||
"libredox",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ouroboros"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2ba07320d39dfea882faa70554b4bd342a5f273ed59ba7c1c6b4c840492c954"
|
||||
dependencies = [
|
||||
"aliasable",
|
||||
"ouroboros_macro",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ouroboros_macro"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec4c6225c69b4ca778c0aea097321a64c421cf4577b331c61b229267edabb6f8"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "owned_ttf_parser"
|
||||
version = "0.25.1"
|
||||
@ -2160,6 +2163,25 @@ dependencies = [
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pathfinder_geometry"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b7e7b4ea703700ce73ebf128e1450eb69c3a8329199ffbfb9b2a0418e5ad3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pathfinder_simd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pathfinder_simd"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf9027960355bf3afff9841918474a81a5f972ac6d226d518060bba758b5ad57"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.2"
|
||||
@ -2168,18 +2190,19 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
|
||||
checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
@ -2187,19 +2210,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
||||
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"phf_shared",
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
||||
checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
@ -2221,7 +2244,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2342,15 +2365,6 @@ dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.4.0"
|
||||
@ -2360,6 +2374,30 @@ dependencies = [
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[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 1.0.109",
|
||||
"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-macro2"
|
||||
version = "1.0.103"
|
||||
@ -2423,50 +2461,6 @@ version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||
dependencies = [
|
||||
"rand_chacha",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.6.2"
|
||||
@ -2555,15 +2549,6 @@ dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "run_script"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8f982753d06bafa2d1e5c1bd5be496bcb3cd02919a89f07e7f21c7a6ecb4e1a"
|
||||
dependencies = [
|
||||
"fsio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.26"
|
||||
@ -2582,6 +2567,15 @@ version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
@ -2650,6 +2644,12 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
@ -2687,7 +2687,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2886,6 +2886,16 @@ dependencies = [
|
||||
"symbolic-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.111"
|
||||
@ -2905,7 +2915,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2956,7 +2966,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2967,7 +2977,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3046,6 +3056,21 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.3"
|
||||
@ -3096,7 +3121,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3198,12 +3223,30 @@ version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-canonical-combining-class"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6925586af9268182c711e47c0853ed84131049efaca41776d0ca97f983865c32"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-general-category"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-joining-type"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22f8cb47ccb8bc750808755af3071da4a10dcd147b68fc874b7ae4b12543f6f5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
@ -3312,7 +3355,7 @@ dependencies = [
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@ -3347,7 +3390,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
@ -3686,7 +3729,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3697,7 +3740,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4090,7 +4133,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@ -4098,22 +4141,19 @@ dependencies = [
|
||||
name = "ytbn_graphing_software"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"allsorts",
|
||||
"base64",
|
||||
"benchmarks",
|
||||
"bincode",
|
||||
"cfg-if",
|
||||
"const_format",
|
||||
"eframe",
|
||||
"egui",
|
||||
"egui_plot",
|
||||
"emath",
|
||||
"epaint",
|
||||
"instant",
|
||||
"itertools 0.14.0",
|
||||
"json5",
|
||||
"lol_alloc",
|
||||
"parsing",
|
||||
"run_script",
|
||||
"ruzstd",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -4145,7 +4185,7 @@ checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4165,7 +4205,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@ -4199,7 +4239,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
10
Cargo.toml
10
Cargo.toml
@ -10,7 +10,7 @@ description = "Crossplatform (and web-compatible) graphing calculator"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
wayland-native = ["eframe/wayland"]
|
||||
default = ["eframe/wayland"]
|
||||
|
||||
[profile.release]
|
||||
debug = false
|
||||
@ -48,9 +48,6 @@ epaint = { git = "https://github.com/titaniumtown/egui.git", default-features =
|
||||
emath = { git = "https://github.com/titaniumtown/egui.git", default-features = false }
|
||||
egui_plot = { version = "0.34.0", default-features = false }
|
||||
|
||||
|
||||
shadow-rs = { version = "1.4", default-features = false }
|
||||
const_format = { version = "0.2", default-features = false, features = ["fmt"] }
|
||||
cfg-if = "1"
|
||||
ruzstd = "0.8"
|
||||
tracing = "0.1"
|
||||
@ -75,16 +72,13 @@ bincode = "1.3"
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
zstd = { version = "0.13", default-features = false, features = ["pkg-config"] }
|
||||
run_script = "0.11"
|
||||
json5 = "1.0"
|
||||
itertools = "0.14"
|
||||
allsorts = "0.15"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
instant = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
instant = { version = "0.1", features = ["wasm-bindgen"] }
|
||||
lol_alloc = "0.4.1"
|
||||
wasm-bindgen = { version = "0.2", default-features = false, features = ["std"] }
|
||||
web-sys = "0.3"
|
||||
|
||||
103
build.rs
103
build.rs
@ -1,3 +1,14 @@
|
||||
use allsorts::{
|
||||
binary::read::ReadScope,
|
||||
font::{Font, MatchingPresentation},
|
||||
font_data::FontData as AllsortsFontData,
|
||||
subset::subset,
|
||||
tag,
|
||||
};
|
||||
use epaint::{
|
||||
text::{FontData, FontDefinitions, FontTweak},
|
||||
FontFamily,
|
||||
};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
env,
|
||||
@ -7,75 +18,55 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use epaint::{
|
||||
FontFamily,
|
||||
text::{FontData, FontDefinitions, FontTweak},
|
||||
};
|
||||
|
||||
use run_script::ScriptOptions;
|
||||
use shadow_rs::ShadowBuilder;
|
||||
|
||||
include!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/src/unicode_helper.rs"
|
||||
));
|
||||
|
||||
fn font_stripper(from: &str, out: &str, unicodes: Vec<char>) -> Result<Vec<u8>, String> {
|
||||
let unicodes: Vec<String> = unicodes.iter().map(|c| to_unicode_hash(*c)).collect();
|
||||
let font_path = format!("{}/assets/{}", env!("CARGO_MANIFEST_DIR"), from);
|
||||
let font_data = std::fs::read(&font_path).map_err(|e| e.to_string())?;
|
||||
let scope = ReadScope::new(&font_data);
|
||||
let font_file = scope
|
||||
.read::<AllsortsFontData>()
|
||||
.map_err(|e| format!("Failed to read font data: {}", e))?;
|
||||
let provider = font_file
|
||||
.table_provider(0)
|
||||
.map_err(|e| format!("Failed to get table provider: {}", e))?;
|
||||
let mut font = Font::new(provider).map_err(|e| format!("Failed to create font: {:?}", e))?;
|
||||
|
||||
let mut glyph_ids = Vec::new();
|
||||
for &ch in &unicodes {
|
||||
let mut glyph_ids_curr = font
|
||||
.map_glyphs(
|
||||
&ch.to_string(),
|
||||
tag::LATN,
|
||||
MatchingPresentation::NotRequired,
|
||||
)
|
||||
.into_iter()
|
||||
.map(|glyph| glyph.glyph_index)
|
||||
.collect();
|
||||
|
||||
glyph_ids.append(&mut glyph_ids_curr);
|
||||
}
|
||||
// Include .notdef glyph
|
||||
glyph_ids.push(0);
|
||||
glyph_ids.sort();
|
||||
glyph_ids.dedup();
|
||||
|
||||
let subset_data = subset(&font.font_table_provider, &glyph_ids)
|
||||
.map_err(|e| format!("Failed to subset font: {}", e))?;
|
||||
|
||||
let new_path = [&env::var("OUT_DIR").unwrap(), out].concat();
|
||||
let unicodes_formatted = unicodes
|
||||
.iter()
|
||||
.map(|u| format!("U+{}", u))
|
||||
.collect::<Vec<String>>()
|
||||
.join(",");
|
||||
std::fs::write(&new_path, &subset_data)
|
||||
.map_err(|e| format!("Failed to write subset font: {}", e))?;
|
||||
|
||||
// Test to see if pyftsubset is found
|
||||
let pyftsubset_detect = run_script::run("whereis pyftsubset", &(vec![]), &ScriptOptions::new());
|
||||
match pyftsubset_detect {
|
||||
Ok((_i, s1, _s2)) => {
|
||||
if s1 == "pyftsubset: " {
|
||||
return Err(String::from("pyftsubset not found"));
|
||||
}
|
||||
}
|
||||
// It was not, return an error and abort
|
||||
Err(x) => return Err(x.to_string()),
|
||||
}
|
||||
|
||||
let script_result = run_script::run(
|
||||
&format!(
|
||||
"pyftsubset {}/assets/{} --unicodes={}
|
||||
mv {}/assets/{} {}",
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
from,
|
||||
unicodes_formatted,
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
from.replace(".ttf", ".subset.ttf"),
|
||||
new_path
|
||||
),
|
||||
&(vec![]),
|
||||
&ScriptOptions::new(),
|
||||
);
|
||||
|
||||
if let Ok((_, _, error)) = script_result {
|
||||
if error.is_empty() {
|
||||
return Ok(std::fs::read(new_path).unwrap());
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
} else if let Err(error) = script_result {
|
||||
return Err(error.to_string());
|
||||
}
|
||||
unreachable!()
|
||||
Ok(subset_data)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// rebuild if new commit or contents of `assets` folder changed
|
||||
println!("cargo:rerun-if-changed=.git/logs/HEAD");
|
||||
// rebuild if contents of `assets` folder changed
|
||||
println!("cargo:rerun-if-changed=assets/*");
|
||||
ShadowBuilder::builder()
|
||||
.build()
|
||||
.expect("Could not initialize shadow_rs");
|
||||
|
||||
let mut main_chars: Vec<char> =
|
||||
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzsu0123456789?.,!(){}[]-_=+-/<>'\\ :^*`@#$%&|~;"
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
''
|
||||
runHook preCheck
|
||||
export LD_LIBRARY_PATH="${libPath}:$LD_LIBRARY_PATH"
|
||||
cargo test --workspace --features wayland-native
|
||||
cargo test --workspace
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
@ -169,7 +169,6 @@
|
||||
rustToolchain
|
||||
wasm-bindgen-cli
|
||||
binaryen
|
||||
python3Packages.fonttools
|
||||
rust-analyzer
|
||||
pkg-config
|
||||
clang
|
||||
|
||||
@ -10,11 +10,11 @@ description = "Parsing library for YTBN-Graphing-Software"
|
||||
[lib]
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.11" }
|
||||
exmex = {version = "0.17.5", features = ["partial"]}
|
||||
phf = { version = "0.13" }
|
||||
exmex = {version = "0.20.5", features = ["partial"]}
|
||||
|
||||
[build-dependencies]
|
||||
phf_codegen = { version = "0.11" }
|
||||
phf_codegen = { version = "0.13" }
|
||||
|
||||
[package.metadata.cargo-all-features]
|
||||
skip_optional_dependencies = true #don't test optional dependencies, only features
|
||||
|
||||
30
shell.nix
30
shell.nix
@ -1,30 +0,0 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
pkgs.mkShell rec {
|
||||
libs = with pkgs; [
|
||||
# wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
wayland
|
||||
|
||||
libx11
|
||||
libxcursor
|
||||
libxi
|
||||
|
||||
clang
|
||||
];
|
||||
|
||||
nativeBuildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
rustc
|
||||
cargo
|
||||
rust-analyzer
|
||||
python3Packages.fonttools
|
||||
]
|
||||
++ libs;
|
||||
|
||||
# add libs to path
|
||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libs}";
|
||||
}
|
||||
@ -1,18 +1,4 @@
|
||||
use const_format::formatc;
|
||||
use epaint::Color32;
|
||||
use shadow_rs::shadow;
|
||||
shadow!(build);
|
||||
|
||||
/// Constant string that has a string containing information about the build.
|
||||
pub const BUILD_INFO: &str = formatc!(
|
||||
"Commit: {} ({})\nBuild Date: {}\nPackage Version: {}\nRust Channel: {}\nRust Version: {}",
|
||||
&build::SHORT_COMMIT,
|
||||
&build::BRANCH,
|
||||
&build::BUILD_TIME,
|
||||
&build::PKG_VERSION,
|
||||
&build::RUST_CHANNEL,
|
||||
&build::RUST_VERSION,
|
||||
);
|
||||
|
||||
pub const FONT_SIZE: f32 = 14.0;
|
||||
|
||||
|
||||
@ -17,9 +17,7 @@ pub struct FunctionManager {
|
||||
|
||||
impl Default for FunctionManager {
|
||||
fn default() -> Self {
|
||||
let mut d = Self {
|
||||
functions: Vec::new()
|
||||
};
|
||||
let mut d = Self::new();
|
||||
d.push_empty();
|
||||
d
|
||||
}
|
||||
@ -46,6 +44,12 @@ fn button_area_button<'a>(text: impl Into<WidgetText>) -> Button<'a> {
|
||||
}
|
||||
|
||||
impl FunctionManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
functions: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_hash(&self) -> u64 {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
|
||||
@ -6,16 +6,14 @@ mod function_entry;
|
||||
mod function_manager;
|
||||
mod math_app;
|
||||
mod misc;
|
||||
pub mod symbolic;
|
||||
mod unicode_helper;
|
||||
mod widgets;
|
||||
|
||||
pub use crate::{
|
||||
function_entry::{FunctionEntry, Riemann},
|
||||
math_app::AppSettings,
|
||||
misc::{
|
||||
EguiHelper, HashBytes, hashed_storage_create, hashed_storage_read, newtons_method,
|
||||
option_vec_printer, step_helper,
|
||||
},
|
||||
misc::{EguiHelper, newtons_method, option_vec_printer, step_helper},
|
||||
unicode_helper::{to_chars_array, to_unicode_hash},
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
consts::{BUILD_INFO, COLORS, DEFAULT_INTEGRAL_NUM, DEFAULT_MAX_X, DEFAULT_MIN_X, build},
|
||||
consts::{COLORS, DEFAULT_INTEGRAL_NUM, DEFAULT_MAX_X, DEFAULT_MIN_X},
|
||||
function_entry::Riemann,
|
||||
function_manager::FunctionManager,
|
||||
misc::option_vec_printer,
|
||||
@ -13,7 +13,6 @@ use egui_plot::Plot;
|
||||
|
||||
use emath::{Align, Align2};
|
||||
use epaint::Margin;
|
||||
use instant::Instant;
|
||||
use itertools::Itertools;
|
||||
use std::{io::Read, ops::BitXorAssign};
|
||||
|
||||
@ -74,9 +73,6 @@ struct Opened {
|
||||
/// Help window
|
||||
pub help: bool,
|
||||
|
||||
/// Info window
|
||||
pub info: bool,
|
||||
|
||||
/// Sidepanel
|
||||
pub side_panel: bool,
|
||||
|
||||
@ -88,7 +84,6 @@ impl Default for Opened {
|
||||
fn default() -> Opened {
|
||||
Self {
|
||||
help: false,
|
||||
info: false,
|
||||
side_panel: true,
|
||||
welcome: true,
|
||||
}
|
||||
@ -100,8 +95,8 @@ pub struct MathApp {
|
||||
/// Stores vector of functions
|
||||
functions: FunctionManager,
|
||||
|
||||
/// Contains the list of Areas calculated (the vector of f64) and time it took for the last frame (the Duration). Stored in a Tuple.
|
||||
last_info: (Option<String>, Option<String>),
|
||||
/// Contains the list of Areas calculated
|
||||
areas: Option<String>,
|
||||
|
||||
/// Stores opened windows/elements for later reference
|
||||
opened: Opened,
|
||||
@ -132,16 +127,7 @@ impl MathApp {
|
||||
#[allow(dead_code)] // This is used lol
|
||||
/// Create new instance of [`MathApp`] and return it
|
||||
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
||||
#[cfg(threading)]
|
||||
tracing::info!("Threading: Enabled");
|
||||
|
||||
#[cfg(not(threading))]
|
||||
tracing::info!("Threading: Disabled");
|
||||
|
||||
tracing::info!("commit: {}", build::SHORT_COMMIT);
|
||||
|
||||
tracing::info!("Initializing...");
|
||||
let start = Instant::now();
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
@ -150,26 +136,24 @@ impl MathApp {
|
||||
|
||||
fn get_storage_decompressed() -> Option<Vec<u8>> {
|
||||
let data = get_localstorage().get_item(DATA_NAME).ok()??;
|
||||
let (commit, cached_data) = crate::misc::hashed_storage_read(&data)?;
|
||||
let cached_data = crate::misc::hashed_storage_read(&data)?;
|
||||
|
||||
if commit == unsafe { std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT) } {
|
||||
tracing::info!("Reading decompression cache. Bytes: {}", cached_data.len());
|
||||
return Some(cached_data);
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn load_functions() -> Option<FunctionManager> {
|
||||
let data = get_localstorage().get_item(FUNC_NAME).ok()??;
|
||||
let (commit, func_data) = crate::misc::hashed_storage_read(&data)?;
|
||||
let func_data = crate::misc::hashed_storage_read(&data)?;
|
||||
|
||||
|
||||
if commit == unsafe { std::mem::transmute::<&str, &[u8]>(build::SHORT_COMMIT) } {
|
||||
tracing::info!("Reading previous function data");
|
||||
let function_manager: FunctionManager = bincode::deserialize(&func_data).ok()?;
|
||||
if let Ok(Some(function_manager)) = bincode::deserialize(&func_data) {
|
||||
return Some(function_manager);
|
||||
} else {
|
||||
None
|
||||
tracing::info!("Unable to load functionManager instance");
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,12 +175,8 @@ impl MathApp {
|
||||
#[cfg(target = "wasm32")]
|
||||
{
|
||||
tracing::info!("Setting decompression cache");
|
||||
let commit: crate::misc::HashBytes = const {
|
||||
unsafe {
|
||||
std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT)
|
||||
}
|
||||
};
|
||||
let saved_data = commit.hashed_storage_create(data);
|
||||
|
||||
let saved_data = hashed_storage_create(data);
|
||||
tracing::info!("Bytes: {}", saved_data.len());
|
||||
get_localstorage()
|
||||
.set_item(DATA_NAME, saved_data)
|
||||
@ -230,7 +210,7 @@ impl MathApp {
|
||||
// Set spacing
|
||||
// cc.egui_ctx.set_spacing(crate::style::SPACING);
|
||||
|
||||
tracing::info!("Initialized! Took: {:?}", start.elapsed());
|
||||
tracing::info!("Initialized!");
|
||||
|
||||
Self {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@ -239,7 +219,7 @@ impl MathApp {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
functions: FunctionManager::default(),
|
||||
|
||||
last_info: (None, None),
|
||||
areas: None,
|
||||
opened: Opened::default(),
|
||||
settings: AppSettings::default(),
|
||||
}
|
||||
@ -362,11 +342,8 @@ impl MathApp {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
tracing::info!("Saving function data");
|
||||
use crate::misc::{HashBytes, hashed_storage_create};
|
||||
let hash: HashBytes =
|
||||
unsafe { std::mem::transmute::<&str, HashBytes>(build::SHORT_COMMIT) };
|
||||
let saved_data = hashed_storage_create(
|
||||
hash,
|
||||
|
||||
let saved_data = crate::misc::hashed_storage_create(
|
||||
&bincode::serialize(&self.functions)
|
||||
.expect("unable to deserialize functions"),
|
||||
);
|
||||
@ -396,16 +373,6 @@ impl MathApp {
|
||||
impl App for MathApp {
|
||||
/// Called each time the UI needs repainting.
|
||||
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
|
||||
// start timer
|
||||
let start = if self.opened.info {
|
||||
Some(instant::Instant::now())
|
||||
} else {
|
||||
// if disabled, clear the stored formatted time
|
||||
self.last_info.1 = None;
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
// If keyboard input isn't being grabbed, check for key combos
|
||||
if !ctx.wants_keyboard_input() {
|
||||
// If `H` key is pressed, toggle Side Panel
|
||||
@ -449,18 +416,8 @@ impl App for MathApp {
|
||||
.clicked(),
|
||||
);
|
||||
|
||||
// Toggles opening the Info window
|
||||
self.opened.info.bitxor_assign(
|
||||
ui.add(Button::new("Info"))
|
||||
.on_hover_text(match self.opened.info {
|
||||
true => "Close Info Window",
|
||||
false => "Open Info Window",
|
||||
})
|
||||
.clicked(),
|
||||
);
|
||||
|
||||
// Display Area and time of last frame
|
||||
if let Some(ref area) = self.last_info.0 {
|
||||
if let Some(ref area) = self.areas {
|
||||
ui.label(area);
|
||||
}
|
||||
});
|
||||
@ -513,20 +470,6 @@ impl App for MathApp {
|
||||
}
|
||||
}
|
||||
|
||||
// Window with information about the build and current commit
|
||||
Window::new("Info")
|
||||
.open(&mut self.opened.info)
|
||||
.default_pos([200.0, 200.0])
|
||||
.resizable(false)
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.add(egui::Label::new(BUILD_INFO));
|
||||
|
||||
if let Some(ref took) = self.last_info.1 {
|
||||
ui.label(took);
|
||||
}
|
||||
});
|
||||
|
||||
// If side panel is enabled, show it.
|
||||
if self.opened.side_panel {
|
||||
self.side_panel(ctx);
|
||||
@ -609,15 +552,12 @@ impl App for MathApp {
|
||||
})
|
||||
.collect();
|
||||
|
||||
self.last_info.0 = if area.iter().any(|e| e.is_some()) {
|
||||
self.areas = if area.iter().any(|e| e.is_some()) {
|
||||
Some(format!("Area: {}", option_vec_printer(area.as_slice())))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// Calculate and store the last time it took to draw the frame
|
||||
self.last_info.1 = start.map(|a| format!("Took: {}ms", a.elapsed().as_micros()));
|
||||
}
|
||||
}
|
||||
|
||||
45
src/misc.rs
45
src/misc.rs
@ -1,4 +1,5 @@
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose;
|
||||
use egui_plot::{Line, PlotPoint, PlotPoints, Points};
|
||||
use emath::Pos2;
|
||||
use itertools::Itertools;
|
||||
@ -150,48 +151,14 @@ pub fn step_helper(max_i: usize, min_x: f64, step: f64) -> Vec<f64> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
// TODO: use in hovering over points
|
||||
/// Attempts to see what variable `x` is almost
|
||||
#[allow(dead_code)]
|
||||
pub fn almost_variable(x: f64) -> Option<char> {
|
||||
const EPSILON: f32 = f32::EPSILON * 2.0;
|
||||
if emath::almost_equal(x as f32, std::f32::consts::E, EPSILON) {
|
||||
Some('e')
|
||||
} else if emath::almost_equal(x as f32, std::f32::consts::PI, EPSILON) {
|
||||
Some('π')
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub const HASH_LENGTH: usize = 8;
|
||||
|
||||
/// Represents bytes used to represent hash info
|
||||
pub type HashBytes = [u8; HASH_LENGTH];
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn hashed_storage_create(hashbytes: HashBytes, data: &[u8]) -> String {
|
||||
let combined_data = [hashbytes.to_vec(), data.to_vec()].concat();
|
||||
general_purpose::STANDARD.encode(combined_data)
|
||||
pub fn hashed_storage_create(data: &[u8]) -> String {
|
||||
general_purpose::STANDARD.encode(data)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn hashed_storage_read(data: &str) -> Option<(HashBytes, Vec<u8>)> {
|
||||
// Decode base64 data
|
||||
let decoded_bytes = general_purpose::STANDARD.decode(data).ok()?;
|
||||
|
||||
// Make sure data is long enough to decode
|
||||
if HASH_LENGTH > decoded_bytes.len() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Split hash and data
|
||||
let (hash_bytes, data_bytes) = decoded_bytes.split_at(HASH_LENGTH);
|
||||
|
||||
// Convert hash bytes to HashBytes
|
||||
let hash: HashBytes = hash_bytes.try_into().ok()?;
|
||||
|
||||
Some((hash, data_bytes.to_vec()))
|
||||
pub fn hashed_storage_read(data: &str) -> Option<Vec<u8>> {
|
||||
general_purpose::STANDARD.decode(data).ok()
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/valid_chars.rs"));
|
||||
|
||||
210
src/symbolic.rs
Normal file
210
src/symbolic.rs
Normal file
@ -0,0 +1,210 @@
|
||||
use std::fmt;
|
||||
|
||||
/// Maximum denominator to consider when checking for rational approximations.
|
||||
const MAX_DENOMINATOR: i64 = 12;
|
||||
|
||||
/// Maximum coefficient to consider for multiples of special constants.
|
||||
const MAX_COEFFICIENT: i64 = 12;
|
||||
|
||||
/// Represents a symbolic mathematical value.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SymbolicValue {
|
||||
/// The original numeric value
|
||||
value: f64,
|
||||
/// The symbolic representation
|
||||
repr: SymbolicRepr,
|
||||
}
|
||||
|
||||
/// The type of symbolic representation.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
enum SymbolicRepr {
|
||||
/// An integer value
|
||||
Integer(i64),
|
||||
/// A simple fraction: numerator / denominator
|
||||
Fraction { numerator: i64, denominator: i64 },
|
||||
/// A multiple of a constant: (numerator / denominator) * constant
|
||||
ConstantMultiple {
|
||||
numerator: i64,
|
||||
denominator: i64,
|
||||
constant: Constant,
|
||||
},
|
||||
}
|
||||
|
||||
/// Known mathematical constants.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
enum Constant {
|
||||
Pi,
|
||||
E,
|
||||
Sqrt(i64),
|
||||
}
|
||||
|
||||
impl Constant {
|
||||
fn value(self) -> f64 {
|
||||
match self {
|
||||
Constant::Pi => std::f64::consts::PI,
|
||||
Constant::E => std::f64::consts::E,
|
||||
Constant::Sqrt(n) => (n as f64).sqrt(),
|
||||
}
|
||||
}
|
||||
|
||||
fn name(self) -> String {
|
||||
match self {
|
||||
Constant::Pi => "pi".to_string(),
|
||||
Constant::E => "e".to_string(),
|
||||
Constant::Sqrt(n) => format!("sqrt({})", n),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All constants to try, in order of priority.
|
||||
const CONSTANTS: &[Constant] = &[
|
||||
Constant::Pi,
|
||||
Constant::E,
|
||||
Constant::Sqrt(2),
|
||||
Constant::Sqrt(3),
|
||||
Constant::Sqrt(5),
|
||||
Constant::Sqrt(6),
|
||||
Constant::Sqrt(7),
|
||||
];
|
||||
|
||||
impl SymbolicValue {
|
||||
/// Returns the original numeric value.
|
||||
pub fn numeric_value(&self) -> f64 {
|
||||
self.value
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SymbolicValue {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.repr {
|
||||
SymbolicRepr::Integer(n) => write!(f, "{}", n),
|
||||
SymbolicRepr::Fraction {
|
||||
numerator,
|
||||
denominator,
|
||||
} => write!(f, "{}/{}", numerator, denominator),
|
||||
SymbolicRepr::ConstantMultiple {
|
||||
numerator,
|
||||
denominator,
|
||||
constant,
|
||||
} => format_constant_multiple(f, *numerator, *denominator, &constant.name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to format a constant multiple like "2pi/3" or "-pi/2"
|
||||
fn format_constant_multiple(
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
numerator: i64,
|
||||
denominator: i64,
|
||||
constant: &str,
|
||||
) -> fmt::Result {
|
||||
let sign = if numerator < 0 { "-" } else { "" };
|
||||
let abs_num = numerator.abs();
|
||||
|
||||
match (abs_num, denominator) {
|
||||
(1, 1) => write!(f, "{}{}", sign, constant),
|
||||
(_, 1) => write!(f, "{}{}{}", sign, abs_num, constant),
|
||||
(1, _) => write!(f, "{}{}/{}", sign, constant, denominator),
|
||||
(_, _) => write!(f, "{}{}{}/{}", sign, abs_num, constant, denominator),
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to find a symbolic representation for the given numeric value.
|
||||
///
|
||||
/// Returns `Some(SymbolicValue)` if the value can be represented symbolically,
|
||||
/// or `None` if no suitable symbolic representation is found.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use ytbn_graphing_software::symbolic::try_symbolic;
|
||||
/// use std::f64::consts::PI;
|
||||
///
|
||||
/// let sym = try_symbolic(PI).unwrap();
|
||||
/// assert_eq!(sym.to_string(), "pi");
|
||||
///
|
||||
/// let sym = try_symbolic(PI / 2.0).unwrap();
|
||||
/// assert_eq!(sym.to_string(), "pi/2");
|
||||
/// ```
|
||||
pub fn try_symbolic(x: f64) -> Option<SymbolicValue> {
|
||||
if !x.is_finite() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Check for zero
|
||||
if x.abs() < f64::EPSILON {
|
||||
return Some(SymbolicValue {
|
||||
value: x,
|
||||
repr: SymbolicRepr::Integer(0),
|
||||
});
|
||||
}
|
||||
|
||||
// Try each constant in order of preference
|
||||
for &constant in CONSTANTS {
|
||||
if let Some(repr) = try_constant_multiple(x, constant) {
|
||||
return Some(SymbolicValue { value: x, repr });
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to rational approximation
|
||||
try_rational(x).map(|repr| SymbolicValue { value: x, repr })
|
||||
}
|
||||
|
||||
/// Try to represent x as (numerator/denominator) * constant
|
||||
fn try_constant_multiple(x: f64, constant: Constant) -> Option<SymbolicRepr> {
|
||||
let c = constant.value();
|
||||
|
||||
for denom in 1..=MAX_DENOMINATOR {
|
||||
let num_f = x * (denom as f64) / c;
|
||||
let num = num_f.round() as i64;
|
||||
|
||||
// Skip if coefficient is zero or too large
|
||||
if num == 0 || num.abs() > MAX_COEFFICIENT * denom {
|
||||
continue;
|
||||
}
|
||||
|
||||
let expected = (num as f64) * c / (denom as f64);
|
||||
if (x - expected).abs() < f64::EPSILON {
|
||||
let g = gcd(num.abs(), denom);
|
||||
return Some(SymbolicRepr::ConstantMultiple {
|
||||
numerator: num / g,
|
||||
denominator: denom / g,
|
||||
constant,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Try to represent x as a simple fraction: numerator/denominator
|
||||
fn try_rational(x: f64) -> Option<SymbolicRepr> {
|
||||
for denom in 1..=MAX_DENOMINATOR {
|
||||
let num_f = x * (denom as f64);
|
||||
let num = num_f.round() as i64;
|
||||
|
||||
if (x - (num as f64) / (denom as f64)).abs() < f64::EPSILON {
|
||||
let g = gcd(num.abs(), denom);
|
||||
let (num, denom) = (num / g, denom / g);
|
||||
|
||||
return Some(if denom == 1 {
|
||||
SymbolicRepr::Integer(num)
|
||||
} else {
|
||||
SymbolicRepr::Fraction {
|
||||
numerator: num,
|
||||
denominator: denom,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Compute the greatest common divisor using Euclidean algorithm.
|
||||
fn gcd(mut a: i64, mut b: i64) -> i64 {
|
||||
while b != 0 {
|
||||
(a, b) = (b, a % b);
|
||||
}
|
||||
a
|
||||
}
|
||||
@ -60,34 +60,6 @@ fn option_vec_printer() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashed_storage() {
|
||||
use ytbn_graphing_software::{hashed_storage_create, hashed_storage_read};
|
||||
|
||||
let commit = "abcdefeg".chars().map(|c| c as u8).collect::<Vec<u8>>();
|
||||
let data = "really cool data"
|
||||
.chars()
|
||||
.map(|c| c as u8)
|
||||
.collect::<Vec<u8>>();
|
||||
let storage_tmp: [u8; 8] = commit
|
||||
.as_slice()
|
||||
.try_into()
|
||||
.expect("cannot turn into [u8; 8]");
|
||||
let storage = hashed_storage_create(storage_tmp, data.as_slice());
|
||||
|
||||
let read = hashed_storage_read(&storage);
|
||||
assert_eq!(
|
||||
read.map(|(a, b)| (a.to_vec(), b.to_vec())),
|
||||
Some((commit.to_vec(), data.to_vec()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_hashed_storage() {
|
||||
use ytbn_graphing_software::hashed_storage_read;
|
||||
assert_eq!(hashed_storage_read("aaaa"), None);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn to_values() {
|
||||
// use egui::plot::{Value, Values};
|
||||
|
||||
229
tests/symbolic.rs
Normal file
229
tests/symbolic.rs
Normal file
@ -0,0 +1,229 @@
|
||||
use std::f64::consts::{E, PI, SQRT_2};
|
||||
use ytbn_graphing_software::symbolic::try_symbolic;
|
||||
|
||||
#[test]
|
||||
fn exact_pi() {
|
||||
let result = try_symbolic(PI);
|
||||
assert!(result.is_some());
|
||||
let sym = result.unwrap();
|
||||
assert_eq!(sym.to_string(), "pi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiples_of_pi() {
|
||||
// 2*pi
|
||||
let result = try_symbolic(2.0 * PI);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "2pi");
|
||||
|
||||
// 3*pi
|
||||
let result = try_symbolic(3.0 * PI);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "3pi");
|
||||
|
||||
// -pi
|
||||
let result = try_symbolic(-PI);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-pi");
|
||||
|
||||
// -2*pi
|
||||
let result = try_symbolic(-2.0 * PI);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-2pi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fractions_of_pi() {
|
||||
// pi/2
|
||||
let result = try_symbolic(PI / 2.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "pi/2");
|
||||
|
||||
// pi/3
|
||||
let result = try_symbolic(PI / 3.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "pi/3");
|
||||
|
||||
// pi/4
|
||||
let result = try_symbolic(PI / 4.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "pi/4");
|
||||
|
||||
// pi/6
|
||||
let result = try_symbolic(PI / 6.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "pi/6");
|
||||
|
||||
// 2pi/3
|
||||
let result = try_symbolic(2.0 * PI / 3.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "2pi/3");
|
||||
|
||||
// 3pi/4
|
||||
let result = try_symbolic(3.0 * PI / 4.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "3pi/4");
|
||||
|
||||
// 5pi/6
|
||||
let result = try_symbolic(5.0 * PI / 6.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "5pi/6");
|
||||
|
||||
// -pi/2
|
||||
let result = try_symbolic(-PI / 2.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-pi/2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exact_e() {
|
||||
let result = try_symbolic(E);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "e");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiples_of_e() {
|
||||
// 2e
|
||||
let result = try_symbolic(2.0 * E);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "2e");
|
||||
|
||||
// -e
|
||||
let result = try_symbolic(-E);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-e");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sqrt_2() {
|
||||
let result = try_symbolic(SQRT_2);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "sqrt(2)");
|
||||
|
||||
// -sqrt(2)
|
||||
let result = try_symbolic(-SQRT_2);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-sqrt(2)");
|
||||
|
||||
// 2*sqrt(2)
|
||||
let result = try_symbolic(2.0 * SQRT_2);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "2sqrt(2)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sqrt_3() {
|
||||
let sqrt_3 = 3.0_f64.sqrt();
|
||||
let result = try_symbolic(sqrt_3);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "sqrt(3)");
|
||||
|
||||
// sqrt(3)/2 - common in trigonometry
|
||||
let result = try_symbolic(sqrt_3 / 2.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "sqrt(3)/2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_fractions() {
|
||||
// 1/2
|
||||
let result = try_symbolic(0.5);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "1/2");
|
||||
|
||||
// 1/3
|
||||
let result = try_symbolic(1.0 / 3.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "1/3");
|
||||
|
||||
// 2/3
|
||||
let result = try_symbolic(2.0 / 3.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "2/3");
|
||||
|
||||
// 1/4
|
||||
let result = try_symbolic(0.25);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "1/4");
|
||||
|
||||
// 3/4
|
||||
let result = try_symbolic(0.75);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "3/4");
|
||||
|
||||
// -1/2
|
||||
let result = try_symbolic(-0.5);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-1/2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn integers() {
|
||||
// 0
|
||||
let result = try_symbolic(0.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "0");
|
||||
|
||||
// 1
|
||||
let result = try_symbolic(1.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "1");
|
||||
|
||||
// -1
|
||||
let result = try_symbolic(-1.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "-1");
|
||||
|
||||
// 5
|
||||
let result = try_symbolic(5.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_symbolic_values() {
|
||||
// Some arbitrary irrational number that isn't special
|
||||
let result = try_symbolic(1.234567890123);
|
||||
assert!(result.is_none());
|
||||
|
||||
// A number that's close to but not quite pi
|
||||
let result = try_symbolic(3.15);
|
||||
assert!(result.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numeric_value() {
|
||||
// SymbolicValue should provide the original numeric value
|
||||
let sym = try_symbolic(PI).unwrap();
|
||||
assert!((sym.numeric_value() - PI).abs() < 1e-10);
|
||||
|
||||
let sym = try_symbolic(PI / 2.0).unwrap();
|
||||
assert!((sym.numeric_value() - PI / 2.0).abs() < 1e-10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero() {
|
||||
let result = try_symbolic(0.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "0");
|
||||
|
||||
// Also test -0.0
|
||||
let result = try_symbolic(-0.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn special_trig_values() {
|
||||
// Common values that appear in trigonometry
|
||||
// sin(pi/4) = cos(pi/4) = sqrt(2)/2
|
||||
let result = try_symbolic(SQRT_2 / 2.0);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "sqrt(2)/2");
|
||||
|
||||
// sin(pi/6) = cos(pi/3) = 1/2
|
||||
let result = try_symbolic(0.5);
|
||||
assert!(result.is_some());
|
||||
assert_eq!(result.unwrap().to_string(), "1/2");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user