diff --git a/crates/engine/src/cmd/params.rs b/crates/engine/src/cmd/params.rs index 64ce29e337..ea2c3568a1 100644 --- a/crates/engine/src/cmd/params.rs +++ b/crates/engine/src/cmd/params.rs @@ -698,6 +698,7 @@ pub const UNCHECKED: &[&str] = &[ "document.exportForScreens", "document.exportForWeb", "document.exportForWeb.preview", + "document.exportForWeb.saveColorTable", "document.exportPdf", "document.find", "document.inspect", @@ -803,6 +804,7 @@ pub const UNCHECKED: &[&str] = &[ "transparency.setOpacityMask", "transparency.unlinkOpacityMask", "type.pathOptions", + "webExport.loadColorTable", "webExport.optimizeToFileSize", "webExport.presets.save", "webExport.settings", diff --git a/crates/engine/src/cmd/webexport.rs b/crates/engine/src/cmd/webexport.rs index 498982a7f9..0f77411cd8 100644 --- a/crates/engine/src/cmd/webexport.rs +++ b/crates/engine/src/cmd/webexport.rs @@ -21,7 +21,7 @@ use vectorcraft_render::encode::quantize::{self, Dither, Indexed, PaletteOptions use vectorcraft_render::encode::web::{self, ColorSort}; use vectorcraft_render::encode::{gif, jpeg, png}; -use super::{CommandSpec, Result, Session, always, bad, bool_or, cmd, f64_or, has_doc, str_param, unique_name_from}; +use super::{CommandSpec, Result, Session, always, bad, bool_or, cmd, f64_or, has_doc, str_param, text_param, unique_name_from}; const C: &str = "document.exportForWeb"; @@ -45,6 +45,24 @@ pub fn specs() -> Vec { has_doc, preview ), + cmd!( + "document.exportForWeb.saveColorTable", + "Save Color Table", + [], + None, + "{path?: the .act file (.act is added to a name without an extension), …the settings of document.exportForWeb (preset?, format?: gif|png8…), slice?: n (1-based, from slice.list; default the whole image)} write the GIF or PNG-8 color table the preview shows as a color table file: 772 bytes, the colors as written (red, green, blue) in file order, zero bytes up to 256 colors, then the number of colors and the transparent entry's index (65535 for none), two bytes each, most significant byte first → {path, colors (how many), transparentIndex (null for none), bytes, warnings}; no path → {dataBase64, colors, transparentIndex, bytes, warnings}. jpg and png24 are an error; the document and the settings do not change", + has_doc, + save_color_table + ), + cmd!( + query "webExport.loadColorTable", + "Load Color Table", + [], + None, + "{path | dataBase64: a color table file (.act: 768 bytes of 256 colors, or 772 bytes with the number of colors used, 1–256, and the transparent entry's index), …the settings of document.exportForWeb (preset?, format?: gif|png8…)} the settings with the table loaded: its colors other than the transparent entry become colorTable.customPalette, colors becomes the number of colors it uses (at least 2), the table's other edits (locked, transparent, deleted, shifted, webShift and sort) are cleared and webSnap becomes 0 →{colors: [\"#rrggbb\"…] (the colors it uses, in file order), transparentIndex (null for none; an index past the colors used names none), settings}. Give exactly one of path and dataBase64; another file size, a count of 0 or above 256, jpg and png24 are errors; nothing is remembered", + always, + load_color_table + ), cmd!( query "webExport.optimizeToFileSize", "Optimize to File Size", @@ -1196,24 +1214,7 @@ fn preview(s: &mut Session, p: &Value) -> Result { if !(kbps.is_finite() && kbps > 0.0) { return Err(bad(P, format!("kbps must be a positive number, not {kbps}"))); } - let st = s.doc()?; - let doc = &st.doc; - let failed = vectorcraft_render::decode_failures(); - let r = render(doc, &settings).map_err(|e| bad(P, e))?; - let warnings = undecoded(failed); - let areas = doc.slice_layout(); - let selected = super::slices::selected_slices(doc, &st.selection); - let cells = cells(&areas, &selected, &settings, &r).map_err(|e| bad(P, e))?; - let images = cells.iter().filter(|c| c.area.id.and_then(|id| doc.slice_options(id)).is_none_or(|o| o.kind == SliceKind::Image)).count().max(1); - let o = match p.get("slice").and_then(Value::as_u64) { - Some(n) => { - let c = cells.iter().find(|c| c.area.number as u64 == n).ok_or_else(|| bad(P, format!("no slice {n} in the image (see slice.list)")))?; - let [x0, y0, x1, y1] = c.px; - optimize(doc, &crop(&r, c.px), x1 - x0, y1 - y0, &settings) - } - None => optimize(doc, &r.rgba, r.width, r.height, &settings), - } - .map_err(|e| bad(P, e))?; + let Shown { o, images, warnings } = shown(s, &settings, p, P)?; let mut out = json!({ "format": settings.format.id(), "width": o.width, "height": o.height, "bytes": o.bytes.len(), "seconds": download_seconds(o.bytes.len(), kbps), "kbps": kbps, "slices": images, "warnings": warnings, @@ -1237,6 +1238,184 @@ fn preview(s: &mut Session, p: &Value) -> Result { Ok(out) } +/// The file Save writes with some settings, as the preview shows it. +struct Shown { + o: Optimized, + /// The images an export writes. + images: usize, + /// The export's warnings. + warnings: Vec<&'static str>, +} + +/// What Save writes with `settings` for the whole image, or for the slice `p.slice` names (1-based, +/// from `slice.list`), for the command `cmd`. A `slice` that is not a whole number from 1 up is an +/// error. +fn shown(s: &mut Session, settings: &WebSettings, p: &Value, cmd: &str) -> Result { + let slice = match p.get("slice") { + None | Some(Value::Null) => None, + Some(v) => Some(v.as_u64().filter(|n| *n >= 1).ok_or_else(|| bad(cmd, "`slice` is a slice number from `slice.list`"))?), + }; + let st = s.doc()?; + let doc = &st.doc; + let failed = vectorcraft_render::decode_failures(); + let r = render(doc, settings).map_err(|e| bad(cmd, e))?; + let warnings = undecoded(failed); + let areas = doc.slice_layout(); + let selected = super::slices::selected_slices(doc, &st.selection); + let cells = cells(&areas, &selected, settings, &r).map_err(|e| bad(cmd, e))?; + let images = cells.iter().filter(|c| c.area.id.and_then(|id| doc.slice_options(id)).is_none_or(|o| o.kind == SliceKind::Image)).count().max(1); + let o = match slice { + Some(n) => { + let c = + cells.iter().find(|c| c.area.number as u64 == n).ok_or_else(|| bad(cmd, format!("no slice {n} in the image (see slice.list)")))?; + let [x0, y0, x1, y1] = c.px; + optimize(doc, &crop(&r, c.px), x1 - x0, y1 - y0, settings) + } + None => optimize(doc, &r.rgba, r.width, r.height, settings), + } + .map_err(|e| bad(cmd, e))?; + Ok(Shown { o, images, warnings }) +} + +// ---------- color table files ---------- + +/// The extension of a color table file. +pub const COLOR_TABLE_EXT: &str = "act"; +/// The size of a color table file with its color count and transparent entry: 256 RGB triples +/// (768 bytes), then the two numbers, each two bytes, most significant byte first. +pub const ACT_LEN: usize = 772; +/// The size of a color table file of 256 RGB triples alone. +const ACT_COLORS_LEN: usize = 768; +/// The transparent entry of a color table file that has none. +const ACT_NO_TRANSPARENT: u16 = 0xFFFF; + +/// The error for bytes that are not a color table file. +const NOT_A_TABLE: &str = "not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors"; + +/// A color table file (`.act`) of `colors`, a palette format's color table in file order: each +/// color as written, red, green and blue, one byte each; zero bytes up to 256 colors; the number +/// of colors and the index of the transparent entry (`0xFFFF` for none), two bytes each, most +/// significant byte first. Colors past the 256th are left out. +pub fn act_bytes(colors: &[TableColor]) -> Vec { + let colors = &colors[..colors.len().min(256)]; + let mut out = vec![0u8; ACT_LEN]; + for (slot, c) in out.as_chunks_mut::<3>().0.iter_mut().zip(colors) { + *slot = c.color; + } + // At most 256 colors: both numbers fit in two bytes. + let count = colors.len() as u16; + let transparent = colors.iter().position(|c| c.transparent).map_or(ACT_NO_TRANSPARENT, |i| i as u16); + out[ACT_COLORS_LEN..ACT_COLORS_LEN + 2].copy_from_slice(&count.to_be_bytes()); + out[ACT_COLORS_LEN + 2..].copy_from_slice(&transparent.to_be_bytes()); + out +} + +/// The colors of a color table file and its transparent entry. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ActTable { + /// The colors the file uses, in its order. + pub colors: Vec<[u8; 3]>, + /// The index of the transparent entry, when the file names one of `colors`. + pub transparent: Option, +} + +/// Read a color table file: 768 bytes are 256 colors; 772 bytes add the number of colors used +/// (1 to 256) and the transparent entry's index. A transparent index past the colors used names +/// no entry. Any other size, or a count of 0 or above 256, is an error. +pub fn read_act(bytes: &[u8]) -> std::result::Result { + let (count, transparent) = match bytes.len() { + ACT_COLORS_LEN => (256, None), + ACT_LEN => { + let at = |i: usize| usize::from(u16::from_be_bytes([bytes[i], bytes[i + 1]])); + (at(ACT_COLORS_LEN), Some(at(ACT_COLORS_LEN + 2))) + } + _ => return Err(NOT_A_TABLE.into()), + }; + if !(1..=256).contains(&count) { + return Err(NOT_A_TABLE.into()); + } + let colors: Vec<[u8; 3]> = bytes[..count * 3].as_chunks::<3>().0.to_vec(); + Ok(ActTable { colors, transparent: transparent.filter(|i| *i < count) }) +} + +/// `settings` with the color table `t` loaded: its colors other than the transparent entry become +/// the fixed palette (`colorTable.customPalette`), and `colors` becomes the number of colors the +/// file uses (at least 2). The table's other edits (locked, transparent, deleted, shifted and +/// web-shifted colors, and its sort) are cleared and Web Snap is set to 0, so every loaded color is +/// written as it is, in the file's order. A table whose only color is its transparent entry loads +/// that color. +pub fn with_table(settings: &WebSettings, t: &ActTable) -> WebSettings { + let mut s = settings.clone(); + let mut palette: Vec = t.colors.iter().enumerate().filter(|(i, _)| Some(*i) != t.transparent).map(|(_, c)| hex(*c)).collect(); + if palette.is_empty() { + palette = t.colors.iter().map(|c| hex(*c)).collect(); + } + s.colors = (t.colors.len() as u16).clamp(2, 256); + s.web_snap = 0; + s.color_table = ColorTable { custom_palette: palette, ..ColorTable::default() }; + s +} + +/// `cmd`'s error for a format without a color table. +fn no_table(cmd: &str, f: WebFormat) -> super::EngineError { + let format = f.id(); + bad(cmd, format!("`{format}` has no color table: use gif or png8")) +} + +fn save_color_table(s: &mut Session, p: &Value) -> Result { + const P: &str = "document.exportForWeb.saveColorTable"; + let settings = s.web_settings(p).map_err(|e| bad(P, e))?; + if !settings.format.palette() { + return Err(no_table(P, settings.format)); + } + let path = text_param(p, "path", P)? + .filter(|p| !p.trim().is_empty()) + .map(|p| if std::path::Path::new(p).extension().is_none() { format!("{p}.{COLOR_TABLE_EXT}") } else { p.to_string() }); + let Shown { o, warnings, .. } = shown(s, &settings, p, P)?; + let bytes = act_bytes(&o.colors); + let mut out = json!({ + "colors": o.colors.len().min(256), + "transparentIndex": o.colors.iter().position(|c| c.transparent), + "bytes": bytes.len(), + "warnings": warnings, + }); + match path { + Some(path) => { + super::fileio::write_file(&path, &bytes)?; + out["path"] = json!(path); + } + None => out["dataBase64"] = json!(vectorcraft_format::base64_encode(&bytes)), + } + Ok(out) +} + +fn load_color_table(s: &mut Session, p: &Value) -> Result { + const L: &str = "webExport.loadColorTable"; + let settings = s.web_settings(p).map_err(|e| bad(L, e))?; + if !settings.format.palette() { + return Err(no_table(L, settings.format)); + } + // One byte more than a color table shows a file that is too long. + let bytes = match (text_param(p, "path", L)?, text_param(p, "dataBase64", L)?) { + (Some(path), None) => super::fileio::read_file_head(path, ACT_LEN + 1)?, + (None, Some(b64)) => { + // Text past the base64 of the longest table makes the file too long. + if b64.bytes().filter(|b| !b.is_ascii_whitespace()).count() > ACT_LEN.div_ceil(3) * 4 { + return Err(bad(L, NOT_A_TABLE)); + } + super::scripts::decode_head(b64, ACT_LEN + 1).ok_or_else(|| bad(L, "bad dataBase64"))? + } + _ => return Err(bad(L, "give exactly one of `path` and `dataBase64`")), + }; + let t = read_act(&bytes).map_err(|e| bad(L, e))?; + let loaded = with_table(&settings, &t); + Ok(json!({ + "colors": t.colors.iter().map(|c| hex(*c)).collect::>(), + "transparentIndex": t.transparent, + "settings": loaded.to_json(), + })) +} + // ---------- Optimize to File Size ---------- /// The most trial settings `webExport.optimizeToFileSize` encodes. Each trial encodes every image diff --git a/crates/engine/src/tests/webexport.rs b/crates/engine/src/tests/webexport.rs index fe3deecbef..150ea1f67a 100644 --- a/crates/engine/src/tests/webexport.rs +++ b/crates/engine/src/tests/webexport.rs @@ -1011,3 +1011,194 @@ fn optimize_to_file_size_finds_a_fit_when_a_lower_setting_gives_a_larger_file() assert!(highest_within(&mut size, &start, (1, 90), set_quality, 100, &mut smallest).unwrap().is_none()); assert_eq!(smallest.map(|(s, n)| (s.quality, n)), Some((36, 415))); } + +/// The bytes of a `document.exportForWeb.saveColorTable` reply without a path. +fn color_table_file(s: &mut Session, p: Value) -> (Value, Vec) { + let v = run(s, "document.exportForWeb.saveColorTable", p); + let bytes = vectorcraft_format::base64_decode(v["dataBase64"].as_str().unwrap()).unwrap(); + (v, bytes) +} + +/// The color table file of `colors` (`#rrggbb`) and transparent entry `transparent`, as the +/// published layout gives it: 256 RGB triples (zero past the colors used), then the number of +/// colors and the transparent index (0xFFFF for none), two bytes each, most significant first. +fn act_layout(colors: &[&str], transparent: Option) -> Vec { + let mut out = vec![]; + for c in colors { + let rgb = u32::from_str_radix(c.trim_start_matches('#'), 16).unwrap(); + out.extend_from_slice(&[(rgb >> 16) as u8, (rgb >> 8) as u8, rgb as u8]); + } + out.resize(768, 0); + out.extend_from_slice(&(colors.len() as u16).to_be_bytes()); + out.extend_from_slice(&transparent.unwrap_or(0xFFFF).to_be_bytes()); + out +} + +/// Save Color Table writes the table the preview shows as a 772-byte color table file: the colors +/// as written, in file order, zero bytes after them, the count and the transparent entry. +#[test] +fn save_color_table_writes_the_act_layout() { + let mut s = two_colours(); + for format in ["gif", "png8"] { + let p = json!({"format": format, "dither": "none", "transparency": false}); + let pv = run(&mut s, "document.exportForWeb.preview", p.clone()); + let colors: Vec<&str> = pv["colors"].as_array().unwrap().iter().map(|c| c["color"].as_str().unwrap()).collect(); + assert_eq!(colors.len(), 2, "{pv}"); + let (v, bytes) = color_table_file(&mut s, p); + assert_eq!(bytes, act_layout(&colors, None), "{format}"); + assert_eq!((v["colors"].as_u64(), v["transparentIndex"].is_null(), v["bytes"].as_u64()), (Some(2), true, Some(772)), "{v}"); + } + // Transparent pixels: the trailer names the transparent entry. + let mut s = session(40.0, 30.0); + rect(&mut s, [10.0, 5.0, 10.0, 20.0], "#ff0000"); + let p = json!({"format": "gif", "antiAlias": "none", "dither": "none"}); + let pv = run(&mut s, "document.exportForWeb.preview", p.clone()); + let table = pv["colors"].as_array().unwrap(); + let at = table.iter().position(|c| c["transparent"] == true).expect("a transparent entry") as u16; + let colors: Vec<&str> = table.iter().map(|c| c["color"].as_str().unwrap()).collect(); + let (v, bytes) = color_table_file(&mut s, p); + assert_eq!(bytes, act_layout(&colors, Some(at))); + assert_eq!(v["transparentIndex"].as_u64(), Some(u64::from(at))); +} + +/// A color shifted by hand goes into the file as the color it is written as. +#[test] +fn save_color_table_writes_shifted_colors_as_written() { + let mut s = two_colours(); + let p = json!({"format": "gif", "dither": "none", "transparency": false, "colorTable": {"shifted": {"#ff0000": "#123456"}}}); + let (_, bytes) = color_table_file(&mut s, p); + let colors: Vec<[u8; 3]> = bytes[..6].chunks(3).map(|c| [c[0], c[1], c[2]]).collect(); + assert!(colors.contains(&[0x12, 0x34, 0x56]) && !colors.contains(&[255, 0, 0]), "{colors:?}"); +} + +/// Save Color Table writes the file at `path`, adding `.act` to a name without an extension and +/// keeping another extension, and refuses formats without a color table and bad params. +#[test] +fn save_color_table_writes_the_path_and_refuses_bad_params() { + let dir = std::env::temp_dir().join(format!("vc-color-table-save-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let mut s = two_colours(); + let p = json!({"format": "gif", "dither": "none"}); + let (_, bytes) = color_table_file(&mut s, p.clone()); + let bare = dir.join("table").to_string_lossy().into_owned(); + let v = run(&mut s, "document.exportForWeb.saveColorTable", merge(&p, json!({"path": bare}))); + let written = format!("{bare}.act"); + assert_eq!(v["path"].as_str(), Some(written.as_str())); + assert_eq!(std::fs::read(&written).unwrap(), bytes); + let other = dir.join("table.tbl").to_string_lossy().into_owned(); + run(&mut s, "document.exportForWeb.saveColorTable", merge(&p, json!({"path": other}))); + assert_eq!(std::fs::read(&other).unwrap(), bytes); + for (bad, says) in [ + (json!({"format": "jpg"}), "`jpg` has no color table"), + (json!({"format": "png24"}), "`png24` has no color table"), + (json!({"path": 5}), "`path` must be a string"), + (json!({"slice": "1"}), "`slice` is a slice number"), + (json!({"slice": 0}), "`slice` is a slice number"), + ] { + let e = s.execute("document.exportForWeb.saveColorTable", &bad).unwrap_err().to_string(); + assert!(e.contains(says), "{bad}: {e}"); + } + let _ = std::fs::remove_dir_all(dir); +} + +/// The preview refuses a `slice` that is not a slice number instead of previewing the whole image. +#[test] +fn preview_refuses_a_slice_that_is_not_a_number() { + let mut s = two_colours(); + for slice in [json!("1"), json!(0), json!(-1), json!(1.5)] { + let e = s.execute("document.exportForWeb.preview", &json!({"slice": slice})).unwrap_err().to_string(); + assert!(e.contains("`slice` is a slice number"), "{slice}: {e}"); + } + assert!(s.execute("document.exportForWeb.preview", &json!({"slice": null})).is_ok()); +} + +/// Color table files are read as the published layout gives them: 768 bytes are 256 colors without +/// a transparent entry; 772 bytes add the count and the transparent index. +#[test] +fn color_table_files_are_read_by_the_published_layout() { + use cmd::webexport::read_act; + let long: Vec = (0..768).map(|i| (i % 251) as u8).collect(); + let t = read_act(&long).unwrap(); + assert_eq!((t.colors.len(), t.colors[0], t.colors[255], t.transparent), (256, [0, 1, 2], [12, 13, 14], None)); + let t = read_act(&act_layout(&["#ff0000", "#00ff00", "#0000ff"], Some(1))).unwrap(); + assert_eq!((t.colors, t.transparent), (vec![[255, 0, 0], [0, 255, 0], [0, 0, 255]], Some(1))); + assert_eq!(read_act(&act_layout(&["#ff0000", "#00ff00"], None)).unwrap().transparent, None); + // An index past the colors used names no entry. + assert_eq!(read_act(&act_layout(&["#ff0000", "#00ff00"], Some(2))).unwrap().transparent, None); + let mut zero = act_layout(&["#ff0000"], None); + zero[768..770].copy_from_slice(&0u16.to_be_bytes()); + let mut over = act_layout(&["#ff0000"], None); + over[768..770].copy_from_slice(&257u16.to_be_bytes()); + for bad in [vec![], vec![0; 767], vec![0; 769], vec![0; 771], vec![0; 773], zero, over] { + assert!(read_act(&bad).unwrap_err().contains("not a color table"), "{} bytes", bad.len()); + } +} + +/// Load Color Table makes the file's colors the fixed palette, other than its transparent entry, +/// with the file's color count; the preview of the loaded settings writes those colors. +#[test] +fn load_color_table_makes_the_file_the_fixed_palette() { + let mut s = two_colours(); + let file = act_layout(&["#00ff00", "#ffffff", "#ff0000"], Some(1)); + let table = json!({ + "deleted": ["#0000ff"], "shifted": {"#ff0000": "#111111"}, "webShift": ["#ff0000"], "locked": ["#ff0000"], + "transparent": ["#00ff00"], "sort": "hue", + }); + let p = json!({"format": "gif", "dither": "none", "transparency": false, "webSnap": 100, "colorTable": table}); + let v = run(&mut s, "webExport.loadColorTable", merge(&p, json!({"dataBase64": vectorcraft_format::base64_encode(&file)}))); + assert_eq!((&v["colors"], &v["transparentIndex"]), (&json!(["#00ff00", "#ffffff", "#ff0000"]), &json!(1))); + let settings = &v["settings"]; + assert_eq!((&settings["colors"], &settings["webSnap"]), (&json!(3), &json!(0))); + let table = &settings["colorTable"]; + assert_eq!( + (&table["customPalette"], &table["deleted"], &table["shifted"], &table["webShift"]), + (&json!(["#00ff00", "#ff0000"]), &json!([]), &json!({}), &json!([])) + ); + assert_eq!((&table["locked"], &table["transparent"], &table["sort"]), (&json!([]), &json!([]), &json!("none"))); + // The loaded palette is what the image is written with: blue takes the nearest loaded color. + let pv = run(&mut s, "document.exportForWeb.preview", settings.clone()); + let written: Vec<&str> = pv["colors"].as_array().unwrap().iter().map(|c| c["color"].as_str().unwrap()).collect(); + assert!(!written.is_empty() && written.iter().all(|c| ["#00ff00", "#ff0000"].contains(c)), "{pv}"); + // A table saved and loaded again keeps its colors. + let opaque = json!({"format": "png8", "dither": "none", "transparency": false}); + let saved = color_table_file(&mut s, opaque.clone()).1; + let again = run(&mut s, "webExport.loadColorTable", json!({"format": "png8", "dataBase64": vectorcraft_format::base64_encode(&saved)})); + let shown = run(&mut s, "document.exportForWeb.preview", opaque); + let before: Vec<&Value> = shown["colors"].as_array().unwrap().iter().map(|c| &c["color"]).collect(); + assert_eq!(again["colors"].as_array().unwrap().iter().collect::>(), before); + // A table whose only color is its transparent entry loads that color. + let only = act_layout(&["#336699"], Some(0)); + let v = run(&mut s, "webExport.loadColorTable", json!({"dataBase64": vectorcraft_format::base64_encode(&only)})); + assert_eq!((&v["settings"]["colorTable"]["customPalette"], &v["settings"]["colors"]), (&json!(["#336699"]), &json!(2))); +} + +/// Load Color Table reads a path, reads no more of a file than a color table takes, and refuses +/// bad params without changing the remembered settings. +#[test] +fn load_color_table_reads_a_path_and_refuses_bad_params() { + let dir = std::env::temp_dir().join(format!("vc-color-table-load-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let mut s = two_colours(); + let path = dir.join("t.act").to_string_lossy().into_owned(); + std::fs::write(&path, act_layout(&["#010203", "#040506"], None)).unwrap(); + let v = run(&mut s, "webExport.loadColorTable", json!({"path": path})); + assert_eq!(v["settings"]["colorTable"]["customPalette"], json!(["#010203", "#040506"])); + let large = dir.join("large.act").to_string_lossy().into_owned(); + std::fs::write(&large, vec![0u8; 1 << 20]).unwrap(); + let b64 = vectorcraft_format::base64_encode(&act_layout(&["#010203"], None)); + for (bad, says) in [ + (json!({"path": large}), "not a color table"), + (json!({"dataBase64": vectorcraft_format::base64_encode(&[0u8; 100])}), "not a color table"), + // A whole table with more data after it is too long. + (json!({"dataBase64": format!("{b64}AAAA")}), "not a color table"), + (json!({}), "give exactly one of `path` and `dataBase64`"), + (json!({"path": path, "dataBase64": b64}), "give exactly one of `path` and `dataBase64`"), + (json!({"dataBase64": "%%%"}), "bad dataBase64"), + (json!({"dataBase64": b64, "format": "jpg"}), "`jpg` has no color table"), + ] { + let e = s.execute("webExport.loadColorTable", &bad).unwrap_err().to_string(); + assert!(e.contains(says), "{bad}: {e}"); + } + assert!(s.last_web_settings().color_table.custom_palette.is_empty(), "nothing is remembered"); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/dialogs/save_for_web.rs b/crates/ui-egui/src/dialogs/save_for_web.rs index 7376973d6f..0e05bf9ede 100644 --- a/crates/ui-egui/src/dialogs/save_for_web.rs +++ b/crates/ui-egui/src/dialogs/save_for_web.rs @@ -4,8 +4,8 @@ //! PNG-24), colour reduction, colours, dither, transparency and matte, interlacing, web snap, //! lossy, JPEG quality, the colour table (lock, map to transparent, web shift, sort, Delete Color, //! Restore Generated Table, a double-click that shifts a color to one picked in the Color Picker, -//! and Unshift All Colors), image size and anti-aliasing, Clip to Artboard, sRGB, metadata, -//! slices and HTML output, and presets. +//! Unshift All Colors, and Load Color Table… and Save Color Table… for `.act` files), image size +//! and anti-aliasing, Clip to Artboard, sRGB, metadata, slices and HTML output, and presets. //! //! Fields are the `document.exportForWeb` settings (`webExport.settings` gives them; set one with //! `ui.dialog.set`, or `preset` to load a preset), plus the dialog's own: `__view` (`original`, @@ -17,8 +17,9 @@ //! preset) and `__hasSlices`. Optimize to File Size… (`__optimizeOpen: true`) shows `__optimizeK` (the desired size in K), //! `__optimizeStart` (`current`, `auto`) and with slices `__optimizeUse` (`allSlices`, //! `eachSlice`, `currentSlice`); `__optimizeGo: true` runs `webExport.optimizeToFileSize` and -//! takes the settings it finds, and `__optimized` holds its result. Save… remembers -//! the settings and writes the files (`file.saveForWeb`); Done only remembers them; Preview in +//! takes the settings it finds, and `__optimized` holds its result. `__loadColorTable: true` and +//! `__saveColorTable: true` run the color table menu's Load Color Table… and Save Color Table…. +//! Save… remembers the settings and writes the files (`file.saveForWeb`); Done only remembers them; Preview in //! Browser opens the HTML page (`file.saveForWeb.browser`). While Alt (Option on macOS) is held, //! Cancel reads Reset, which puts the remembered settings back and leaves the dialog open //! (`ui.dialogReset`). The previews are what Save writes: @@ -568,6 +569,15 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { { app.status(e); } + // The color table menu's Load and Save, whose file dialogs answer later on some systems. + for (key, f) in [("__loadColorTable", load_color_table as ColorTableAction), ("__saveColorTable", save_color_table)] { + if d.fields.remove(key).is_some_and(|v| v == json!(true)) + && let Err(e) = crate::picks::in_dialog(app, d, f) + && e != "cancelled" + { + app.status(e); + } + } take_shift(d); let settings = settings_of(app, d); let mut browser = false; @@ -844,7 +854,7 @@ fn side(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, s: Option<& choice(ui, d, "metadata", tl!("Metadata:"), &pairs(&WebMetadata::ALL, WebMetadata::key, WebMetadata::label)); if format.palette() { widgets::divider(ui); - if let Err(e) = color_table(ui, d, s) { + if let Err(e) = color_table(ui, d, s, io::is_web(app)) { app.status(e); } } @@ -1130,9 +1140,10 @@ fn matte_row(ui: &mut egui::Ui, d: &mut Dialog) { /// selects one color, a Shift-click the colors from the anchor, and a Ctrl-click /// (Command-click on macOS) adds or removes one; a double-click on an opaque color asks for the /// Color Picker (`__editColor`), and a color shifted by hand shows its source color at the upper -/// left and its new color at the lower right. Returns an error for a deletion that would leave -/// no color. -fn color_table(ui: &mut egui::Ui, d: &mut Dialog, s: Option<&WebSettings>) -> Result<(), String> { +/// left and its new color at the lower right. The menu's Load Color Table… and Save Color Table… +/// set `__loadColorTable` and `__saveColorTable` (Load is off on the `web`). Returns an error for a +/// deletion that would leave no color. +fn color_table(ui: &mut egui::Ui, d: &mut Dialog, s: Option<&WebSettings>, web: bool) -> Result<(), String> { let t = Tokens::get(ui.ctx()); let cache: Option = ui.ctx().data(|m| m.get_temp(cache_id())); let key = s.map(|s| s.to_json().to_string()); @@ -1293,6 +1304,14 @@ fn color_table(ui: &mut egui::Ui, d: &mut Dialog, s: Option<&WebSettings>) -> Re unshift_all = true; ui.close(); } + if widgets::menu_item(ui, tl!("Load Color Table…"), !web, false) { + d.fields.insert("__loadColorTable".into(), json!(true)); + ui.close(); + } + if widgets::menu_item(ui, tl!("Save Color Table…"), !shot.colors.is_empty(), false) { + d.fields.insert("__saveColorTable".into(), json!(true)); + ui.close(); + } }); }); let sort = table.sort; @@ -1495,6 +1514,37 @@ pub(super) fn unshift_all_colors(d: &mut Dialog) { set_table(d, "webShift", json!([])); } +/// A color table menu action that asks for a file. +type ColorTableAction = fn(&mut VectorcraftApp, &mut Dialog) -> Result<(), String>; + +/// The dialog's settings without the image's `path`. +pub(super) fn table_params(d: &Dialog) -> Value { + let mut p = params(d); + if let Some(o) = p.as_object_mut() { + o.remove("path"); + } + p +} + +/// Save Color Table…: the color table the preview shows, written to a picked `.act` file +/// (`document.exportForWeb.saveColorTable`; the web downloads it). The dialog does not change. +pub(super) fn save_color_table(app: &mut VectorcraftApp, d: &mut Dialog) -> Result<(), String> { + io::save_command_output(app, "document.exportForWeb.saveColorTable", webexport::COLOR_TABLE_EXT, table_params(d)).map(|_| ()) +} + +/// Load Color Table…: a picked `.act` file becomes the table's fixed palette, with its color count +/// (`webExport.loadColorTable`). +pub(super) fn load_color_table(app: &mut VectorcraftApp, d: &mut Dialog) -> Result<(), String> { + let pick = crate::FilePick { filters: vec![crate::FilePick::filter("Color tables", &[webexport::COLOR_TABLE_EXT])], ..Default::default() }; + let path = crate::picks::open(app, &pick).ok_or("cancelled")?; + let mut p = table_params(d); + p["path"] = json!(path); + let r = app.run("webExport.loadColorTable", p)?; + let settings: WebSettings = serde_json::from_value(r["settings"].clone()).map_err(|e| e.to_string())?; + d.fields.extend(settings_fields(&settings)); + Ok(()) +} + /// Add `color` to the colour table's `list`, or take it out. pub(super) fn toggle(d: &mut Dialog, list: &str, color: &str, add: bool) { let mut v: Vec = d.fields.get("colorTable").and_then(|t| t.get(list)).and_then(Value::as_array).cloned().unwrap_or_default(); diff --git a/crates/ui-egui/src/dialogs/tests_save_for_web.rs b/crates/ui-egui/src/dialogs/tests_save_for_web.rs index 63ed3e2ded..3ebdbee12a 100644 --- a/crates/ui-egui/src/dialogs/tests_save_for_web.rs +++ b/crates/ui-egui/src/dialogs/tests_save_for_web.rs @@ -844,6 +844,53 @@ fn colour_table_shift_unshift_and_unshift_all() { assert_eq!((&d.fields["colorTable"]["shifted"], &d.fields["colorTable"]["deleted"]), (&json!({}), &json!(["#222222"]))); } +/// Save Color Table… writes the table the preview shows to a picked `.act` file without changing +/// the dialog or the image's `path`; Load Color Table… makes a picked file the fixed palette. +#[test] +fn color_table_menu_saves_and_loads_act_files() { + let dir = vectorcraft_testkit::temp_dir("sfw-color-table"); + let (mut app, _) = app(&dir, false); + let picked = dir.join("loaded.act").to_string_lossy().into_owned(); + let open = picked.clone(); + app.services.pick_open = Some(Box::new(move |p: &crate::FilePick| { + assert_eq!(p.filters, [("Color tables".to_string(), vec!["act".to_string()])]); + Some(open.clone()) + })); + app.services.write = Some(Box::new(|p: &str, b: &[u8]| std::fs::write(p, b).map_err(|e| e.to_string()))); + app.run("file.saveForWeb", json!({})).unwrap(); + for (k, v) in [("format", json!("gif")), ("dither", json!("none")), ("transparency", json!(false)), ("path", json!("/elsewhere/page.gif"))] { + set(&mut app, k, v); + } + frame(&mut app); + let settings = save_for_web::table_params(app.ui.dialog.as_ref().unwrap()); + let want = app.run("document.exportForWeb.saveColorTable", settings).unwrap(); + let want = vectorcraft_format::base64_decode(want["dataBase64"].as_str().unwrap()).unwrap(); + let before = app.ui.dialog.as_ref().unwrap().fields.clone(); + set(&mut app, "__saveColorTable", json!(true)); + frame(&mut app); + let written = std::fs::read(dir.join("Untitled-1.act")).unwrap_or_else(|e| panic!("{e}: {}", app.ui.status)); + assert_eq!((written.len(), &written), (772, &want)); + assert_eq!(app.ui.dialog.as_ref().unwrap().fields, before, "the dialog does not change"); + assert!(app.ui.status.contains("Untitled-1.act"), "{}", app.ui.status); + // Load: three colors, the second one transparent. + let mut file = vec![0x11, 0x22, 0x33, 0, 0, 0, 0x44, 0x55, 0x66]; + file.resize(768, 0); + file.extend_from_slice(&[0, 3, 0, 1]); + std::fs::write(&picked, &file).unwrap(); + set(&mut app, "__loadColorTable", json!(true)); + frame(&mut app); + let fields = &app.ui.dialog.as_ref().unwrap().fields; + assert_eq!((&fields["colors"], &fields["colorTable"]["customPalette"]), (&json!(3), &json!(["#112233", "#445566"]))); + assert_eq!(fields["path"], "/elsewhere/page.gif"); + // A file that is not a color table changes nothing and says why. + std::fs::write(&picked, [0u8; 10]).unwrap(); + let before = app.ui.dialog.as_ref().unwrap().fields.clone(); + set(&mut app, "__loadColorTable", json!(true)); + frame(&mut app); + assert_eq!(app.ui.dialog.as_ref().unwrap().fields, before); + assert!(app.ui.status.contains("not a color table"), "{}", app.ui.status); +} + /// One frame of `app` in `ctx`, 50 ms after the last. fn tick(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) { let time = ctx.input(|i| i.time) + 0.05; diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 167737554d..16e30f44b2 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -826,6 +826,10 @@ font-technology Variable Променливи Delete Color Изтриване на цвят Restore Generated Table Възстановяване на генерираната таблица Unshift All Colors Преместване назад на всички цветове + Load Color Table… Зареди цветова таблица… + Load Color Table Зареди цветова таблица + Save Color Table… Запази цветова таблица… + Save Color Table Запази цветова таблица Delete Character Style Изтриване на стил за знаци Delete Empty Artboards Изтриване на празни работни области Delete Freeform Point Изтриване на свободна точка diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index a9d6e35ed8..4ef9e5ecf3 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -3638,6 +3638,10 @@ theme Appearance Izgled Delete Color Izbriši boju Restore Generated Table Vrati generisanu tabelu Unshift All Colors Poništi pomak svih boja + Load Color Table… Učitaj tabelu boja… + Load Color Table Učitaj tabelu boja + Save Color Table… Sačuvaj tabelu boja… + Save Color Table Sačuvaj tabelu boja Delete Symbol Izbriši simbol Delete the selected symbol? Izbrisati odabrani simbol? Delete the selected symbols? Izbrisati odabrane simbole? diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index e4271f7926..021ab71e35 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -1216,6 +1216,14 @@ arrowhead Target Diana Delete Color Suprimeix el color Restore Generated Table Restaura la taula generada Unshift All Colors Desfés el desplaçament de tots els colors + Load Color Table… Carrega la taula de colors… + Load Color Table Carrega la taula de colors + Save Color Table… Desa la taula de colors… + Save Color Table Desa la taula de colors +@msg `{format}` has no color table: use gif or png8 `{format}` no té taula de colors: utilitza gif o png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors no és una taula de colors: un fitxer .act té 768 o 772 bytes i fa servir entre 1 i 256 colors +@msg give exactly one of `path` and `dataBase64` indica exactament un de `path` i `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` és un número de tall de `slice.list` Delete Character Style Suprimeix l’estil de caràcter Delete Data Set Suprimeix el conjunt de dades Delete Data Sets Suprimeix els conjunts de dades diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 488df173c3..f52d449cce 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3739,6 +3739,14 @@ theme Appearance Motiv Delete Color Odstranit barvu Restore Generated Table Obnovit vygenerovanou tabulku Unshift All Colors Zrušit posun všech barev + Load Color Table… Načíst tabulku barev… + Load Color Table Načíst tabulku barev + Save Color Table… Uložit tabulku barev… + Save Color Table Uložit tabulku barev +@msg `{format}` has no color table: use gif or png8 `{format}` nemá tabulku barev: použijte gif nebo png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors není tabulka barev: soubor .act má 768 nebo 772 bajtů a používá 1 až 256 barev +@msg give exactly one of `path` and `dataBase64` zadejte právě jedno z `path` a `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` je číslo řezu ze `slice.list` Delete Symbol Odstranit symbol Delete the selected symbol? Odstranit vybraný symbol? Delete the selected symbols? Odstranit vybrané symboly? diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 302ab6aa69..33f17fc79b 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6219,6 +6219,14 @@ theme Appearance Udseende Delete Color Slet farve Restore Generated Table Gendan genereret tabel Unshift All Colors Fjern skift af alle farver + Load Color Table… Indlæs farvetabel… + Load Color Table Indlæs farvetabel + Save Color Table… Gem farvetabel… + Save Color Table Gem farvetabel +@msg `{format}` has no color table: use gif or png8 `{format}` har ingen farvetabel: brug gif eller png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors ikke en farvetabel: en .act-fil er 768 eller 772 byte lang og bruger 1 til 256 farver +@msg give exactly one of `path` and `dataBase64` angiv præcis én af `path` og `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` er et udsnitsnummer fra `slice.list` Delete Symbol Slet symbol Delete the selected symbol? Vil du slette det markerede symbol? Delete the selected symbols? Vil du slette de markerede symboler? diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9482345f18..c40dbbdf51 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -839,6 +839,14 @@ font-technology Variable Variabel Delete Color Farbe löschen Restore Generated Table Generierte Tabelle wiederherstellen Unshift All Colors Verschiebung aller Farben aufheben + Load Color Table… Farbtabelle laden… + Load Color Table Farbtabelle laden + Save Color Table… Farbtabelle speichern… + Save Color Table Farbtabelle speichern +@msg `{format}` has no color table: use gif or png8 `{format}` hat keine Farbtabelle: verwenden Sie gif oder png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors keine Farbtabelle: eine .act-Datei ist 768 oder 772 Byte lang und verwendet 1 bis 256 Farben +@msg give exactly one of `path` and `dataBase64` geben Sie genau eines von `path` und `dataBase64` an +@msg `slice` is a slice number from `slice.list` `slice` ist eine Slice-Nummer aus `slice.list` Delete Character Style Zeichenformat löschen Delete Empty Artboards Leere Zeichenflächen löschen Delete Freeform Point Freiformpunkt löschen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 434d0cc0b8..6b22367248 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -811,6 +811,14 @@ font-technology Variable Μεταβλητές Delete Color Διαγραφή χρώματος Restore Generated Table Επαναφορά του παραγόμενου πίνακα Unshift All Colors Αναίρεση μετατόπισης όλων των χρωμάτων + Load Color Table… Φόρτωση πίνακα χρωμάτων… + Load Color Table Φόρτωση πίνακα χρωμάτων + Save Color Table… Αποθήκευση πίνακα χρωμάτων… + Save Color Table Αποθήκευση πίνακα χρωμάτων +@msg `{format}` has no color table: use gif or png8 το `{format}` δεν έχει πίνακα χρωμάτων: χρησιμοποιήστε gif ή png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors δεν είναι πίνακας χρωμάτων: ένα αρχείο .act έχει μήκος 768 ή 772 byte και χρησιμοποιεί 1 έως 256 χρώματα +@msg give exactly one of `path` and `dataBase64` δώστε ακριβώς ένα από τα `path` και `dataBase64` +@msg `slice` is a slice number from `slice.list` το `slice` είναι αριθμός τομής από το `slice.list` Delete Character Style Διαγραφή στυλ χαρακτήρων Delete Empty Artboards Διαγραφή κενών πινάκων σχεδίασης Delete Freeform Point Διαγραφή ελεύθερου σημείου diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3f83e928e4..fb17942a85 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -857,6 +857,14 @@ font-technology Variable Variables Delete Color Eliminar color Restore Generated Table Restaurar tabla generada Unshift All Colors Deshacer cambio de todos los colores + Load Color Table… Cargar tabla de colores… + Load Color Table Cargar tabla de colores + Save Color Table… Guardar tabla de colores… + Save Color Table Guardar tabla de colores +@msg `{format}` has no color table: use gif or png8 `{format}` no tiene tabla de colores: usa gif o png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors no es una tabla de colores: un archivo .act tiene 768 o 772 bytes y usa de 1 a 256 colores +@msg give exactly one of `path` and `dataBase64` indica exactamente uno de `path` y `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` es un número de sector de `slice.list` Delete Character Style Eliminar estilo de carácter Delete Empty Artboards Eliminar mesas de trabajo vacías Delete Freeform Point Eliminar punto libre diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a4d85b23e8..266205c3c2 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3676,6 +3676,14 @@ theme Appearance Ulkoasu Delete Color Poista väri Restore Generated Table Palauta luotu taulukko Unshift All Colors Peru kaikkien värien siirto + Load Color Table… Lataa väritaulukko… + Load Color Table Lataa väritaulukko + Save Color Table… Tallenna väritaulukko… + Save Color Table Tallenna väritaulukko +@msg `{format}` has no color table: use gif or png8 muodossa `{format}` ei ole väritaulukkoa: käytä muotoa gif tai png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors ei väritaulukko: .act-tiedosto on 768 tai 772 tavua pitkä ja käyttää vähintään 1 ja enintään 256 väriä +@msg give exactly one of `path` and `dataBase64` anna täsmälleen yksi näistä: `path` tai `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` on siivun numero luettelosta `slice.list` Delete Symbol Poista symboli Delete the selected symbol? Poistetaanko valittu symboli? Delete the selected symbols? Poistetaanko valitut symbolit? diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8f56486157..b924859a61 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -859,6 +859,14 @@ font-technology Variable Variables Delete Color Supprimer la couleur Restore Generated Table Restaurer la table générée Unshift All Colors Annuler le décalage de toutes les couleurs + Load Color Table… Charger la table des couleurs… + Load Color Table Charger la table des couleurs + Save Color Table… Enregistrer la table des couleurs… + Save Color Table Enregistrer la table des couleurs +@msg `{format}` has no color table: use gif or png8 `{format}` n’a pas de table des couleurs, utilisez gif ou png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors ce n’est pas une table des couleurs (un fichier .act fait 768 ou 772 octets et utilise de 1 à 256 couleurs) +@msg give exactly one of `path` and `dataBase64` indiquez exactement un paramètre parmi `path` et `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` est un numéro de tranche de `slice.list` Delete Character Style Supprimer le style de caractère Delete Empty Artboards Supprimer les plans de travail vides Delete Freeform Point Supprimer le point libre diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 0bb7c9b71f..fa4da5ca99 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -981,6 +981,10 @@ Delete Color રંગ કાઢી નાખો Restore Generated Table જનરેટ થયેલું ટેબલ પુનઃસ્થાપિત કરો Unshift All Colors બધા રંગોનું શિફ્ટ રદ કરો + Load Color Table… રંગ ટેબલ લોડ કરો… + Load Color Table રંગ ટેબલ લોડ કરો + Save Color Table… રંગ ટેબલ સાચવો… + Save Color Table રંગ ટેબલ સાચવો Delete Character Style અક્ષર સ્ટાઇલ કાઢી નાખો Delete Data Set ડેટા સેટ કાઢી નાખો Delete Data Sets ડેટા સેટ્સ કાઢી નાખો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index e9509d9202..21ee78d672 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -1634,6 +1634,14 @@ arrowhead Feather पंख Delete Color रंग हटाएँ Restore Generated Table जनरेट की गई तालिका पुनर्स्थापित करें Unshift All Colors सभी रंग अनशिफ़्ट करें + Load Color Table… रंग तालिका लोड करें… + Load Color Table रंग तालिका लोड करें + Save Color Table… रंग तालिका सेव करें… + Save Color Table रंग तालिका सेव करें +@msg `{format}` has no color table: use gif or png8 `{format}` में रंग तालिका नहीं है: gif या png8 का उपयोग करें +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors यह रंग तालिका नहीं है: .act फ़ाइल 768 या 772 बाइट लंबी होती है और 1 से 256 रंगों का उपयोग करती है +@msg give exactly one of `path` and `dataBase64` `path` और `dataBase64` में से ठीक एक दें +@msg `slice` is a slice number from `slice.list` `slice`, `slice.list` से स्लाइस संख्या है Delete Character Style कैरेक्टर स्टाइल हटाएँ Delete Data Set डेटा सेट हटाएँ Delete Data Sets डेटा सेट्स हटाएँ diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 87f050ef0d..46d10b4970 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -1106,6 +1106,14 @@ arrowhead Target Céltábla Delete Color Szín törlése Restore Generated Table Előállított tábla visszaállítása Unshift All Colors Az összes szín eltolásának visszavonása + Load Color Table… Színtábla betöltése… + Load Color Table Színtábla betöltése + Save Color Table… Színtábla mentése… + Save Color Table Színtábla mentése +@msg `{format}` has no color table: use gif or png8 a(z) `{format}` formátumnak nincs színtáblája: használj gif vagy png8 formátumot +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors nem színtábla: egy .act fájl 768 vagy 772 bájt hosszú, és 1 és 256 közötti számú színt használ +@msg give exactly one of `path` and `dataBase64` pontosan egyet adj meg ezek közül: `path`, `dataBase64` +@msg `slice` is a slice number from `slice.list` a `slice` egy szeletszám a `slice.list` listából Delete Character Style Karakterstílus törlése Delete Data Set Adatkészlet törlése Delete Empty Artboards Üres rajztáblák törlése diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 924d3d80b5..1e0ed2b941 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4087,6 +4087,14 @@ theme Appearance Tampilan Delete Color Hapus warna Restore Generated Table Pulihkan tabel yang dibuat Unshift All Colors Batalkan pergeseran semua warna + Load Color Table… Muat tabel warna… + Load Color Table Muat tabel warna + Save Color Table… Simpan tabel warna… + Save Color Table Simpan tabel warna +@msg `{format}` has no color table: use gif or png8 `{format}` tidak memiliki tabel warna: gunakan gif atau png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors bukan tabel warna: file .act berukuran 768 atau 772 byte dan memakai 1 sampai 256 warna +@msg give exactly one of `path` and `dataBase64` berikan tepat satu dari `path` dan `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` adalah nomor slice dari `slice.list` Delete Symbol Hapus simbol Delete the selected symbol? Hapus simbol yang dipilih? Delete the selected symbols? Hapus simbol yang dipilih? diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 5f47e3f117..791d0ffc2b 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -860,6 +860,14 @@ font-technology Variable Variabili Delete Color Elimina colore Restore Generated Table Ripristina tabella generata Unshift All Colors Annulla spostamento di tutti i colori + Load Color Table… Carica tabella colori… + Load Color Table Carica tabella colori + Save Color Table… Salva tabella colori… + Save Color Table Salva tabella colori +@msg `{format}` has no color table: use gif or png8 `{format}` non ha una tabella colori: usa gif o png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors non è una tabella colori: un file .act è lungo 768 o 772 byte e usa da 1 a 256 colori +@msg give exactly one of `path` and `dataBase64` indica esattamente uno tra `path` e `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` è un numero di sezione da `slice.list` Delete Character Style Elimina stile carattere Delete Empty Artboards Elimina tavole da disegno vuote Delete Freeform Point Elimina punto libero diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 9a1b5f6354..5dda57f454 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -1630,6 +1630,14 @@ antiAlias Sharp シャープ Delete Color カラーを削除 Restore Generated Table 生成されたテーブルを復元 Unshift All Colors すべてのカラーのシフトを戻す + Load Color Table… カラーテーブルを読み込み… + Load Color Table カラーテーブルを読み込み + Save Color Table… カラーテーブルを保存… + Save Color Table カラーテーブルを保存 +@msg `{format}` has no color table: use gif or png8 `{format}` にはカラーテーブルがありません: gif または png8 を使ってください +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors カラーテーブルではありません: .act ファイルは 768 または 772 バイトで、1 から 256 色を使います +@msg give exactly one of `path` and `dataBase64` `path` と `dataBase64` のうち 1 つだけを指定してください +@msg `slice` is a slice number from `slice.list` `slice` は `slice.list` のスライス番号です Delete Character Style 文字スタイルを削除 Delete Empty Artboards 空のアートボードを削除 Delete Freeform Point フリーフォームポイントを削除 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8eeacee621..45233bc1e1 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -5497,6 +5497,14 @@ theme Appearance იერსახე Delete Color ფერის წაშლა Restore Generated Table გენერირებული ცხრილის აღდგენა Unshift All Colors ყველა ფერის წანაცვლების მოხსნა + Load Color Table… ფერების ცხრილის ჩატვირთვა… + Load Color Table ფერების ცხრილის ჩატვირთვა + Save Color Table… ფერების ცხრილის შენახვა… + Save Color Table ფერების ცხრილის შენახვა +@msg `{format}` has no color table: use gif or png8 `{format}`-ს არ აქვს ფერების ცხრილი: გამოიყენეთ gif ან png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors ეს არ არის ფერების ცხრილი: .act ფაილი 768 ან 772 ბაიტია და იყენებს 1-დან 256 ფერამდე +@msg give exactly one of `path` and `dataBase64` მიუთითეთ ზუსტად ერთი: `path` ან `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` არის ნაჭრის ნომერი `slice.list`-დან Delete Symbol სიმბოლოს წაშლა Delete the selected symbol? წაიშალოს მონიშნული სიმბოლო? Delete the selected symbols? წაიშალოს მონიშნული სიმბოლოები? diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 57e0b8be10..b293ac923a 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -1620,6 +1620,14 @@ antiAlias Sharp 날카롭게 Delete Color 색상 삭제 Restore Generated Table 생성된 표 복원 Unshift All Colors 모든 색상 이동 취소 + Load Color Table… 색상 표 불러오기… + Load Color Table 색상 표 불러오기 + Save Color Table… 색상 표 저장… + Save Color Table 색상 표 저장 +@msg `{format}` has no color table: use gif or png8 `{format}`에는 색상 표가 없습니다: gif 또는 png8을 사용하세요 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors 색상 표가 아닙니다: .act 파일은 768 또는 772바이트이며 1개에서 256개까지의 색상을 사용합니다 +@msg give exactly one of `path` and `dataBase64` `path`, `dataBase64` 중 정확히 하나를 지정하세요 +@msg `slice` is a slice number from `slice.list` `slice`는 `slice.list`의 분할 번호입니다 Delete Character Style 문자 스타일 삭제 Delete Empty Artboards 빈 아트보드 삭제 Delete Freeform Point 자유 형태 포인트 삭제 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 5ed5cdc3e0..56b2baa10e 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4085,6 +4085,14 @@ theme Appearance Vormgeving Delete Color Kleur verwijderen Restore Generated Table Gegenereerde tabel herstellen Unshift All Colors Verschuiving van alle kleuren ongedaan maken + Load Color Table… Kleurentabel laden… + Load Color Table Kleurentabel laden + Save Color Table… Kleurentabel opslaan… + Save Color Table Kleurentabel opslaan +@msg `{format}` has no color table: use gif or png8 `{format}` heeft geen kleurentabel: gebruik gif of png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors geen kleurentabel: een .act-bestand is 768 of 772 bytes lang en gebruikt 1 tot 256 kleuren +@msg give exactly one of `path` and `dataBase64` geef precies een van `path` en `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` is een slicenummer uit `slice.list` Delete Symbol Symbool verwijderen Delete the selected symbol? Het geselecteerde symbool verwijderen? Delete the selected symbols? De geselecteerde symbolen verwijderen? diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 74029133dc..867fc2245e 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3618,6 +3618,14 @@ theme Appearance Wygląd Delete Color Usuń kolor Restore Generated Table Przywróć wygenerowaną tablicę Unshift All Colors Cofnij przesunięcie wszystkich kolorów + Load Color Table… Wczytaj tablicę kolorów… + Load Color Table Wczytaj tablicę kolorów + Save Color Table… Zapisz tablicę kolorów… + Save Color Table Zapisz tablicę kolorów +@msg `{format}` has no color table: use gif or png8 `{format}` nie ma tablicy kolorów: użyj gif lub png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors to nie jest tablica kolorów: plik .act ma 768 lub 772 bajty i używa od 1 do 256 kolorów +@msg give exactly one of `path` and `dataBase64` podaj dokładnie jedno z: `path` i `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` to numer plasterka z `slice.list` Delete Symbol Usuń symbol Delete the selected symbol? Usunąć zaznaczony symbol? Delete the selected symbols? Usunąć zaznaczone symbole? diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index a1747af0b2..cea7326a84 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -786,6 +786,14 @@ antiAlias Sharp Nítido Delete Color Excluir Cor Restore Generated Table Restaurar Tabela Gerada Unshift All Colors Desfazer Mudança de Todas as Cores + Load Color Table… Carregar Tabela de Cores… + Load Color Table Carregar Tabela de Cores + Save Color Table… Salvar Tabela de Cores… + Save Color Table Salvar Tabela de Cores +@msg `{format}` has no color table: use gif or png8 `{format}` não tem tabela de cores: use gif ou png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors não é uma tabela de cores: um arquivo .act tem 768 ou 772 bytes e usa de 1 a 256 cores +@msg give exactly one of `path` and `dataBase64` informe exatamente um de `path` e `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` é um número de fatia de `slice.list` Delete Character Style Excluir Estilo de Caractere Delete Empty Artboards Excluir Mesas de Trabalho Vazias Delete Freeform Point Excluir Ponto Livre diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ca0c8d5145..7748cb5990 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -855,6 +855,14 @@ font-technology Variable Вариативные Delete Color Удалить цвет Restore Generated Table Восстановить созданную таблицу Unshift All Colors Отменить сдвиг всех цветов + Load Color Table… Загрузить цветовую таблицу… + Load Color Table Загрузить цветовую таблицу + Save Color Table… Сохранить цветовую таблицу… + Save Color Table Сохранить цветовую таблицу +@msg `{format}` has no color table: use gif or png8 у `{format}` нет цветовой таблицы: используйте gif или png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors это не цветовая таблица: файл .act имеет длину 768 или 772 байта и использует от 1 до 256 цветов +@msg give exactly one of `path` and `dataBase64` укажите ровно одно из: `path` и `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` задаёт номер фрагмента из `slice.list` Delete Character Style Удалить стиль символа Delete Empty Artboards Удалить пустые монтажные области Delete Freeform Point Удалить произвольную точку diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index c26474cf93..6c78516f51 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -840,6 +840,14 @@ font-technology Variable Variabla Delete Color Radera färg Restore Generated Table Återställ genererad tabell Unshift All Colors Ta bort förskjutning av alla färger + Load Color Table… Läs in färgtabell… + Load Color Table Läs in färgtabell + Save Color Table… Spara färgtabell… + Save Color Table Spara färgtabell +@msg `{format}` has no color table: use gif or png8 `{format}` har ingen färgtabell: använd gif eller png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors inte en färgtabell: en .act-fil är 768 eller 772 byte lång och använder 1 till 256 färger +@msg give exactly one of `path` and `dataBase64` ange exakt en av `path` och `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` är ett skivnummer från `slice.list` Delete Character Style Radera teckenstil Delete Empty Artboards Radera tomma ritytor Delete Freeform Point Radera fri punkt diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 82186ebcdd..0ab10863c5 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -836,6 +836,14 @@ font-technology Variable Değişken Delete Color Rengi Sil Restore Generated Table Oluşturulan Tabloyu Geri Yükle Unshift All Colors Tüm Renklerin Kaydırmasını Kaldır + Load Color Table… Renk Tablosunu Yükle… + Load Color Table Renk Tablosunu Yükle + Save Color Table… Renk Tablosunu Kaydet… + Save Color Table Renk Tablosunu Kaydet +@msg `{format}` has no color table: use gif or png8 `{format}` biçiminin renk tablosu yok: gif veya png8 kullanın +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors renk tablosu değil: bir .act dosyası 768 veya 772 bayt uzunluğundadır ve 1 ile 256 arasında renk kullanır +@msg give exactly one of `path` and `dataBase64` `path` ve `dataBase64` değerlerinden tam olarak birini verin +@msg `slice` is a slice number from `slice.list` `slice`, `slice.list` içindeki bir dilim numarasıdır Delete Character Style Karakter Stilini Sil Delete Empty Artboards Boş Çalışma Yüzeylerini Sil Delete Freeform Point Serbest Biçim Noktasını Sil diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index de3329ef10..5c60f06b06 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -854,6 +854,14 @@ font-technology Variable Варіативні Delete Color Видалити колір Restore Generated Table Відновити створену таблицю Unshift All Colors Скасувати зсув усіх кольорів + Load Color Table… Завантажити колірну таблицю… + Load Color Table Завантажити колірну таблицю + Save Color Table… Зберегти колірну таблицю… + Save Color Table Зберегти колірну таблицю +@msg `{format}` has no color table: use gif or png8 `{format}` не має колірної таблиці: використайте gif або png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors це не колірна таблиця: файл .act має довжину 768 або 772 байти й використовує від 1 до 256 кольорів +@msg give exactly one of `path` and `dataBase64` укажіть рівно одне з: `path`, `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` задає номер фрагмента зі `slice.list` Delete Character Style Видалити стиль символу Delete Empty Artboards Видалити порожні монтажні області Delete Freeform Point Видалити довільну точку diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 675143a8d6..42ef6d153c 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -1002,6 +1002,14 @@ font-technology Variable Biến thiên Delete Color Xóa màu Restore Generated Table Khôi phục bảng đã tạo Unshift All Colors Bỏ dịch chuyển tất cả màu + Load Color Table… Tải bảng màu… + Load Color Table Tải bảng màu + Save Color Table… Lưu bảng màu… + Save Color Table Lưu bảng màu +@msg `{format}` has no color table: use gif or png8 `{format}` không có bảng màu: hãy dùng gif hoặc png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors không phải bảng màu: tệp .act dài 768 hoặc 772 byte và dùng từ 1 đến 256 màu +@msg give exactly one of `path` and `dataBase64` hãy cho đúng một trong `path` và `dataBase64` +@msg `slice` is a slice number from `slice.list` `slice` là số lát cắt từ `slice.list` Delete Character Style Xóa kiểu ký tự Delete Data Set Xóa tập dữ liệu Delete Design Xóa thiết kế diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 57f6a4403b..beac4b000d 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -801,6 +801,14 @@ antiAlias Sharp 锐利 Delete Color 删除颜色 Restore Generated Table 恢复生成的颜色表 Unshift All Colors 取消偏移所有颜色 + Load Color Table… 加载颜色表… + Load Color Table 加载颜色表 + Save Color Table… 保存颜色表… + Save Color Table 保存颜色表 +@msg `{format}` has no color table: use gif or png8 `{format}` 没有颜色表:请使用 gif 或 png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors 不是颜色表:.act 文件长 768 或 772 字节,使用 1 到 256 种颜色 +@msg give exactly one of `path` and `dataBase64` `path` 和 `dataBase64` 中必须且只能给出一个 +@msg `slice` is a slice number from `slice.list` `slice` 是 `slice.list` 中的切片编号 Delete Character Style 删除字符样式 Delete Empty Artboards 删除空白画板 Delete Freeform Point 删除自由点 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 9834c17ea6..2b0232c1c6 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -822,6 +822,14 @@ font-technology Variable 可變 Delete Color 刪除顏色 Restore Generated Table 還原產生的色彩表 Unshift All Colors 取消位移所有顏色 + Load Color Table… 載入色彩表… + Load Color Table 載入色彩表 + Save Color Table… 儲存色彩表… + Save Color Table 儲存色彩表 +@msg `{format}` has no color table: use gif or png8 `{format}` 沒有色彩表:請使用 gif 或 png8 +@msg not a color table: an .act file is 768 or 772 bytes long and uses 1 to 256 colors 不是色彩表:.act 檔案長 768 或 772 位元組,使用 1 到 256 種顏色 +@msg give exactly one of `path` and `dataBase64` `path` 和 `dataBase64` 請只提供其中一個 +@msg `slice` is a slice number from `slice.list` `slice` 是 `slice.list` 中的切片編號 Delete Character Style 刪除字元樣式 Delete Empty Artboards 刪除空白工作區域 Delete Freeform Point 刪除任意形狀錨點 diff --git a/crates/ui-egui/src/io/save.rs b/crates/ui-egui/src/io/save.rs index aa4b565c07..927ff6231b 100644 --- a/crates/ui-egui/src/io/save.rs +++ b/crates/ui-egui/src/io/save.rs @@ -158,6 +158,7 @@ const FILE_TYPES: &[(&str, &[&str])] = &[ ("Action sets", &[crate::panels::actions::ACTIONS_EXT]), ("Export presets", fileio::SCREEN_EXPORT_PRESET_EXTS), ("Composite fonts", vectorcraft_engine::cmd::compositefonts::EXTS), + ("Color tables", &[vectorcraft_engine::cmd::webexport::COLOR_TABLE_EXT]), ("CSS", &["css"]), ("PostScript", &["ps"]), ("Preferences", &["json"]), diff --git a/docs/mcp.md b/docs/mcp.md index e7abf476a9..29b05a8090 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10527,7 +10527,8 @@ couldn't be decoded and is missing from the image; the files are written all the file size), `seconds` to download at `kbps` (default 56.6), the size, and for palette formats the colour table (`colors: [{color, source, transparent, locked, webShifted, shifted, webSafe}]`). The colour table's lists name colours by `source` (the colour the reduction made), so a colour keeps its edits when it is web-shifted or snapped. `slice: n` -previews one slice; `image: true` adds the file; `warnings` holds the export's warnings. +previews one slice, and a `slice` that is not a whole number from 1 up is an error; `image: true` adds the file; +`warnings` holds the export's warnings. Delete Color is `colorTable.deleted: ["#rrggbb"…]`, by `source`. The deleted colors leave the table and the file, and their pixels take the nearest color left, with the current reduction's color distance and dither; the preview and the @@ -10567,6 +10568,29 @@ leaves the table as it was. A shifted swatch shows the source color at its upper right, with the lock mark, and Lock stays on until the color is unshifted. Web Shift replaces a shift by hand, and Unshift All Colors in the table's menu clears `shifted` and `webShift`. Only Web Colors in the picker starts off. +Save Color Table… in the table's menu is `document.exportForWeb.saveColorTable {path?, slice?, …settings}`. It writes +the GIF or PNG-8 color table the preview shows as a color table file (`.act`) in the layout the file format +specification gives (https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/): 256 entries of three bytes (red, +green, blue) in file order, with zero bytes after the colors used, then the number of colors used and the index of the +transparent entry, two bytes each with the most significant byte first. The file is always 772 bytes, and the index is +65535 when the table has no transparent entry. A color shifted by hand is written as its new color. `.act` is added to +a `path` without an extension, and without `path` the file comes back as `dataBase64`. The reply is `{path, colors, +transparentIndex, bytes, warnings}` (`transparentIndex` is null when there is none). JPEG and PNG-24 are errors, and the +document and the settings do not change. Load Color Table… is `webExport.loadColorTable {path | dataBase64, +…settings}`. It reads a 768-byte file (256 colors, no transparent entry) or a 772-byte one (the number of colors used, +1 to 256, and the transparent entry's index; an index past the colors used names no entry) and returns +`{colors, transparentIndex, settings}`: the settings with the file's colors other than its transparent entry as +`colorTable.customPalette`, `colors` set to the number of colors the file uses (at least 2), the table's other edits +(`locked`, `transparent`, `deleted`, `shifted`, `webShift` and `sort`) cleared and `webSnap` set to 0, so every loaded +color is written as it is, in the file's order, and none is locked. A file whose only color is its +transparent entry loads that color. Another file size (base64 text included), a count of 0 or above 256, both or +neither of `path` and `dataBase64`, and JPEG or PNG-24 are errors; the command reads at most 773 bytes of a file and +remembers nothing. In +the dialog Load Color Table… puts the loaded settings into its fields (`__loadColorTable: true`), and Save Color Table… +writes the file picked in a save panel (`__saveColorTable: true`), or downloads it on the web, where Load Color Table… +is disabled. The help page describes both entries +(https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=404). + ```json {"name":"run_command","arguments":{"command":"document.exportForWeb.preview","params":{"format":"png8","colorTable":{"deleted":["#ff0000"],"customPalette":["#0000ff","#00ff00","#ff0000"]}}}} ``` diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 57ac87a396..f933a6fe0a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1005,6 +1005,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Save for Web: while Alt (Option on macOS) is held, the dialog's Cancel button reads Reset, which puts the remembered settings back on the document's active artboard and leaves the dialog open (`ui.dialogReset`). - Save for Web: the color table's trash button and Delete Color in its menu remove the selected GIF or PNG-8 colors, and their pixels take the nearest color left in the palette ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=404)). Click selects one color, Shift-click a range and Ctrl-click (Command-click on macOS) adds or removes one ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=398)). After the first deletion the table is a fixed Custom palette, so deleted colors stay out when the preview updates. These rules are VectorCraft's own: a deleted color is no longer locked, transparent or web-shifted; deleting every opaque color is refused; Restore Generated Table in the menu, or another reduction, goes back to the generated palette; presets and the remembered settings keep the edit (`colorTable.deleted`, `colorTable.customPalette`). Fixed palettes can also use all 256 entries when nothing is transparent. Scores and estimates are unchanged. - Save for Web: double-clicking a GIF or PNG-8 color-table swatch opens the Color Picker, and its OK changes that color to the one picked everywhere it appears in the image. The swatch then shows the original color in its upper-left half and the new one in its lower-right half, with the lock mark, and the color stays through a lower color count. Double-clicking a changed swatch opens the picker on the original color, and OK on it changes the color back; Unshift All Colors in the table's menu undoes every change, web shifts included ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=398)). These rules are VectorCraft's own: Cancel changes nothing; a changed color wins over Web Shift, Web Snap and Lock, and pressing Web Shift replaces it; a color mapped to transparent stays transparent; two colors may change to the same color; a changed color takes a kept palette slot before a locked one, and one slot always stays for the reduction; the change is kept by source color when the reduction changes and applies only while that source is in the table; presets and the remembered settings keep it; the picker opens with Only Web Colors off (`colorTable.shifted`). GIF lossy compression moves no pixel into or out of a changed color. Scores and estimates are unchanged. + - Save for Web: Save Color Table… in the color table's menu writes the GIF or PNG-8 table the preview shows to an `.act` file, and Load Color Table… reads one back as the table's fixed Custom palette, so the image is written with the loaded colors; reloaded colors come back as plain, unlocked entries ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=404)). The file follows the published color table layout (https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/): 256 RGB entries in file order, then the number of colors and the transparent entry. These rules are VectorCraft's own: Save always writes the 772-byte form, with zero bytes after the colors used and 65535 when there is no transparent entry; Load takes the 768-byte and 772-byte forms, leaves the transparent entry out of the palette, sets Colors to the file's count, clears the table's other edits and its sort, and sets Web Snap to 0; Load reads only `.act` files and is disabled on the web (`document.exportForWeb.saveColorTable`, `webExport.loadColorTable`). Scores and estimates are unchanged. - Export for Screens, Save for Web (slice images, and files named after the document's title) and the Libraries panel name files with the characters Windows does not allow written as `-` and with a `-` after a Windows device name such as `CON`, on every platform (`document.exportForScreens`, `document.exportForWeb`, `library.create`). - Variables (data merge): text, visibility and image variables bound to objects (an object may carry several), dataset rows applied in one undo step (`variable.*`, `dataset.*`) from a Variables panel and Window › Variables, with dialogs to define, bind and edit, Make Text/Visibility/Image Dynamic, Capture/Update Data Set, CSV import/export (`dataset.import` / `dataset.export`), and a row in italics when an edit leaves the art not matching it; an image dataset value is a file path and apply keeps the object's bounds; bindings let go of deleted art and locked art is left alone except by visibility values; every command, like the rest, is drivable over MCP and the CLI. - Export for Screens numbers distinct row files whose names collide, compared without case, as `-2`, `-3`… instead of leaving them out; identical rows still write one file. It puts row folders that differ only in case into one folder (`document.exportForScreens`).