convert_base
This commit is contained in:
parent
bc023d38b8
commit
4168c645ec
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -859,6 +859,12 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert-base"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e56a404f2112d00ba80a516b60ca3744ef6bd776baa14126eb7d7c11b42cac8a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "convert_case"
|
name = "convert_case"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -1414,6 +1420,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
|
||||||
name = "fastwave"
|
name = "fastwave"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"convert-base",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"shared",
|
"shared",
|
||||||
|
@ -1499,6 +1506,7 @@ dependencies = [
|
||||||
name = "frontend"
|
name = "frontend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"convert-base",
|
||||||
"gloo-file",
|
"gloo-file",
|
||||||
"shared",
|
"shared",
|
||||||
"wasm-bindgen-test",
|
"wasm-bindgen-test",
|
||||||
|
|
|
@ -16,6 +16,7 @@ readme = "../README.md"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
convert-base = "1.1.2"
|
||||||
# wellen = { version = "0.9.9", features = ["serde1"] }
|
# wellen = { version = "0.9.9", features = ["serde1"] }
|
||||||
# wellen = { path = "../wellen/wellen", features = ["serde1"] }
|
# wellen = { path = "../wellen/wellen", features = ["serde1"] }
|
||||||
wellen = { git = "https://github.com/MartinKavik/wellen", features = ["serde1"], branch = "new_pub_types" }
|
wellen = { git = "https://github.com/MartinKavik/wellen", features = ["serde1"], branch = "new_pub_types" }
|
||||||
|
|
|
@ -13,6 +13,7 @@ wasm-bindgen-test = "0.3.19"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zoon.workspace = true
|
zoon.workspace = true
|
||||||
wellen.workspace = true
|
wellen.workspace = true
|
||||||
|
convert-base.workspace = true
|
||||||
shared = { path = "../shared", features = ["frontend"] }
|
shared = { path = "../shared", features = ["frontend"] }
|
||||||
web-sys = { version = "*", features = ["FileSystemFileHandle"] }
|
web-sys = { version = "*", features = ["FileSystemFileHandle"] }
|
||||||
gloo-file = { version = "0.3.0", features = ["futures"] }
|
gloo-file = { version = "0.3.0", features = ["futures"] }
|
||||||
|
|
|
@ -35152,12 +35152,12 @@ var PixiController = class {
|
||||||
// Default automatic Pixi resizing according to the parent is not reliable
|
// Default automatic Pixi resizing according to the parent is not reliable
|
||||||
// and the `app.renderer`'s `resize` event is fired on every browser window size change
|
// and the `app.renderer`'s `resize` event is fired on every browser window size change
|
||||||
async resize(width, height) {
|
async resize(width, height) {
|
||||||
|
this.app.resize();
|
||||||
const width_changed = width !== this.previous_parent_width;
|
const width_changed = width !== this.previous_parent_width;
|
||||||
this.previous_parent_width = width;
|
this.previous_parent_width = width;
|
||||||
if (width_changed) {
|
if (width_changed) {
|
||||||
await this.redraw_rows();
|
await this.redraw_rows();
|
||||||
}
|
}
|
||||||
this.app.resize();
|
|
||||||
}
|
}
|
||||||
destroy() {
|
destroy() {
|
||||||
const rendererDestroyOptions = {
|
const rendererDestroyOptions = {
|
||||||
|
|
|
@ -46,14 +46,13 @@ export class PixiController {
|
||||||
// Default automatic Pixi resizing according to the parent is not reliable
|
// Default automatic Pixi resizing according to the parent is not reliable
|
||||||
// and the `app.renderer`'s `resize` event is fired on every browser window size change
|
// and the `app.renderer`'s `resize` event is fired on every browser window size change
|
||||||
async resize(width: number, height: number) {
|
async resize(width: number, height: number) {
|
||||||
|
this.app.resize();
|
||||||
// -- FastWave-specific --
|
// -- FastWave-specific --
|
||||||
const width_changed = width !== this.previous_parent_width;
|
const width_changed = width !== this.previous_parent_width;
|
||||||
this.previous_parent_width = width;
|
this.previous_parent_width = width;
|
||||||
if (width_changed) {
|
if (width_changed) {
|
||||||
await this.redraw_rows();
|
await this.redraw_rows();
|
||||||
}
|
}
|
||||||
// -- // --
|
|
||||||
this.app.resize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ tauri-build = { version = "=2.0.0-beta.17", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wellen.workspace = true
|
wellen.workspace = true
|
||||||
|
convert-base.workspace = true
|
||||||
shared = { path = "../shared", features = ["backend"] }
|
shared = { path = "../shared", features = ["backend"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
|
@ -116,8 +116,8 @@ fn signal_to_timeline(
|
||||||
})
|
})
|
||||||
.peekable();
|
.peekable();
|
||||||
|
|
||||||
|
// @TODO parallelize?
|
||||||
let mut blocks = Vec::new();
|
let mut blocks = Vec::new();
|
||||||
|
|
||||||
while let Some((block_x, value)) = x_value_pairs.next() {
|
while let Some((block_x, value)) = x_value_pairs.next() {
|
||||||
let next_block_x = if let Some((next_block_x, _)) = x_value_pairs.peek() {
|
let next_block_x = if let Some((next_block_x, _)) = x_value_pairs.peek() {
|
||||||
*next_block_x
|
*next_block_x
|
||||||
|
@ -130,10 +130,13 @@ fn signal_to_timeline(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = value.to_string();
|
|
||||||
// @TODO dynamic formatter
|
// @TODO dynamic formatter
|
||||||
let value = u128::from_str_radix(&value, 2).unwrap();
|
// @TODO optimize it by not using `.to_string` if possible
|
||||||
let value = format!("{value:x}");
|
let value = value.to_string();
|
||||||
|
let ones_and_zeros = value.chars().rev().map(|char| char.to_digit(2).unwrap()).collect::<Vec<_>>();
|
||||||
|
let mut base = convert_base::Convert::new(2, 16);
|
||||||
|
let output = base.convert::<u32, u32>(&ones_and_zeros);
|
||||||
|
let value: String = output.into_iter().map(|number| char::from_digit(number, 16).unwrap()).collect();
|
||||||
|
|
||||||
let value_width = value.chars().count() as u32 * LETTER_WIDTH;
|
let value_width = value.chars().count() as u32 * LETTER_WIDTH;
|
||||||
let label = if (value_width + (2 * LABEL_X_PADDING)) <= block_width {
|
let label = if (value_width + (2 * LABEL_X_PADDING)) <= block_width {
|
||||||
|
|
Loading…
Reference in a new issue