lines, barebones drawing window
addition of lines means ipc slightly changed, though can be ignored. also, minor malvim fix
This commit is contained in:
@@ -221,6 +221,7 @@ impl Serializable for DrawInstructions {
|
||||
DrawInstructions::Gradient(p, d, c1, c2, u) => format!("Gradient/{}\x1E{}\x1E{}\x1E{}\x1E{}", array_to_string(p), array_to_string(d), array_to_string(c1), array_to_string(c2), u),
|
||||
DrawInstructions::Bmp(p, s, b) => format!("Bmp/{}\x1E{}\x1E{}", array_to_string(p), s, b),
|
||||
DrawInstructions::Circle(p, u, c) => format!("Circle/{}\x1E{}\x1E{}", array_to_string(p), u, array_to_string(c)),
|
||||
DrawInstructions::Line(s, e, w, c) => format!("Line/{}\x1E{}\x1E{}\x1E{}", array_to_string(s), array_to_string(e), w, array_to_string(c)),
|
||||
}
|
||||
}
|
||||
fn deserialize(serialized: &str) -> Result<Self, ()> {
|
||||
@@ -402,6 +403,35 @@ impl Serializable for DrawInstructions {
|
||||
let c = get_color(arg.unwrap())?;
|
||||
Ok(DrawInstructions::Circle(p, u.unwrap(), c))
|
||||
},
|
||||
"Line" => {
|
||||
let rest = get_rest_of_split(&mut parts, Some("/"));
|
||||
//(s, e, w, c)
|
||||
let mut args = rest.split("\x1E");
|
||||
let arg = args.next();
|
||||
if arg.is_none() {
|
||||
return Err(());
|
||||
}
|
||||
let s = get_two_array(arg.unwrap())?;
|
||||
let arg = args.next();
|
||||
if arg.is_none() {
|
||||
return Err(());
|
||||
}
|
||||
let e = get_two_array(arg.unwrap())?;
|
||||
let arg = args.next();
|
||||
if arg.is_none() {
|
||||
return Err(());
|
||||
}
|
||||
let w = arg.unwrap().parse();
|
||||
if w.is_err() {
|
||||
return Err(());
|
||||
}
|
||||
let arg = args.next();
|
||||
if arg.is_none() {
|
||||
return Err(());
|
||||
}
|
||||
let c = get_color(arg.unwrap())?;
|
||||
Ok(DrawInstructions::Line(s, e, w.unwrap(), c))
|
||||
},
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,18 @@ pub enum KeyChar {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DrawInstructions {
|
||||
/// Top left point, dimensions, colour
|
||||
Rect(Point, Dimensions, RGBColor),
|
||||
Text(Point, Vec<String>, String, RGBColor, RGBColor, Option<usize>, Option<u8>), //font and text
|
||||
/// Top left point, fonts, text, colour, background colour, horizontal spacing, monospace width
|
||||
Text(Point, Vec<String>, String, RGBColor, RGBColor, Option<usize>, Option<u8>),
|
||||
/// Top left point, dimensions, start colour, end colour, steps
|
||||
Gradient(Point, Dimensions, RGBColor, RGBColor, usize),
|
||||
/// Top left point, path to file, reverse
|
||||
Bmp(Point, String, bool),
|
||||
/// Centre point, radius, colour
|
||||
Circle(Point, usize, RGBColor),
|
||||
/// Start point, end point, line width, line colour
|
||||
Line(Point, Point, usize, RGBColor),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user