extern crate strum;
use crate::svg_draw::svg_draw::{
WorkingStorageDrawPolyMorphNatal, WorkingStorageDrawPolyMorphTransit,
};
use libswe_sys::sweconst::{Bodies, Theme};
use svg::node::element::path::{Data, Number};
use svg::node::element::{Group, Path};
use svg::Document;
pub const ANGLE_SIZE: Number = 50.0;
impl WorkingStorageDrawPolyMorphNatal {
pub fn angles_draw_asc(&self) -> Document {
draw_asc(self.ws.theme)
}
pub fn angles_draw_fc(&self) -> Document {
draw_fc(self.ws.theme)
}
pub fn angles_draw_desc(&self) -> Document {
draw_desc(self.ws.theme)
}
pub fn angles_draw_mc(&self) -> Document {
draw_mc(self.ws.theme)
}
}
impl WorkingStorageDrawPolyMorphTransit {
pub fn angles_draw_asc(&self) -> Document {
draw_asc(self.ws.theme)
}
pub fn angles_draw_fc(&self) -> Document {
draw_fc(self.ws.theme)
}
pub fn angles_draw_desc(&self) -> Document {
draw_desc(self.ws.theme)
}
pub fn angles_draw_mc(&self) -> Document {
draw_mc(self.ws.theme)
}
}
fn draw_asc(theme: Theme) -> Document {
let size: (Number, Number) = (ANGLE_SIZE, ANGLE_SIZE);
let document: Document;
let color: String =
format!("#{:06X}", Bodies::EclNut.object_color(theme) as i32);
let data1 = Data::new()
.move_to((9.2, 28.6)) .line_by((-2.5, 7.6)) .horizontal_line_to(3.4) .line_by((8.2, -24.3)) .horizontal_line_by(3.8) .line_by((8.3, 24.3)) .horizontal_line_by(-3.3) .line_by((-2.6, -7.6)) .horizontal_line_to(9.2) .close() .move_to((17.1, 26.1)) .line_by((-2.4, -7.0)) .cubic_curve_by((-0.5, -1.6, -0.9, -3.0, -1.3, -4.4)) .horizontal_line_by(-0.1) .cubic_curve_by((-0.4, 1.4, -0.8, 2.9, -1.2, 4.4)) .line_by((-2.4, 7.0)) .horizontal_line_to(17.1) .close(); let data2 = Data::new()
.move_to((43.7, 35.4)) .cubic_curve_by((-1.2, 0.6, -3.5, 1.2, -6.4, 1.2)) .cubic_curve_by((-6.8, 0.0, -12.0, -4.3, -12.0, -12.3)) .cubic_curve_by((0.0, -7.6, 5.1, -12.7, 12.7, -12.7)) .cubic_curve_by((3.0, 0.0, 4.9, 0.6, 5.8, 1.1)) .line_to((43.0, 15.2)) .cubic_curve_by((-1.2, -0.6, -2.9, -1.0, -4.9, -1.0)) .cubic_curve_by((-5.7, 0.0, -9.5, 3.6, -9.5, 10.0)) .cubic_curve_by((0.0, 5.9, 3.4, 9.8, 9.3, 9.8)) .cubic_curve_by((1.9, 0.0, 3.9, -0.4, 5.1, -1.0)) .line_to((43.7, 35.4)) .close(); let path1 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data1);
let path2 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data2);
let group = Group::new().add(path1).add(path2);
document = Document::new()
.set("viewBox", (0, 0, size.0, size.1))
.add(group);
document
}
fn draw_fc(theme: Theme) -> Document {
let size: (Number, Number) = (ANGLE_SIZE, ANGLE_SIZE);
let document: Document;
let color: String =
format!("#{:06X}", Bodies::EclNut.object_color(theme) as i32);
let data1 = Data::new()
.move_to((7.2, 11.9)) .horizontal_line_by(13.1) .vertical_line_by(2.6) .horizontal_line_by(-9.9) .vertical_line_by(8.1) .horizontal_line_by(9.2) .vertical_line_by(2.6) .horizontal_line_by(-9.2) .vertical_line_by(11.0) .horizontal_line_to(7.2) .vertical_line_to(11.9) .close(); let data2 = Data::new()
.move_to((41.7, 35.4)) .cubic_curve_by((-1.2, 0.6, -3.5, 1.2, -6.4, 1.2)) .cubic_curve_by((-6.8, 0.0, -12.0, -4.3, -12.0, -12.3)) .cubic_curve_by((0.0, -7.6, 5.1, -12.7, 12.7, -12.7)) .cubic_curve_by((3.0, 0.0, 4.9, 0.6, 5.8, 1.1)) .line_to((41.0, 15.2)) .cubic_curve_by((-1.2, -0.6, -2.9, -1.0, -4.9, -1.0)) .cubic_curve_by((-5.7, 0.0, -9.5, 3.6, -9.5, 10.0)) .cubic_curve_by((0.0, 5.9, 3.4, 9.8, 9.3, 9.8)) .cubic_curve_by((1.9, 0.0, 3.9, -0.4, 5.1, -1.0)) .line_to((41.7, 35.4)) .close(); let path1 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data1);
let path2 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data2);
let group = Group::new().add(path1).add(path2);
document = Document::new()
.set("viewBox", (0, 0, size.0, size.1))
.add(group);
document
}
fn draw_desc(theme: Theme) -> Document {
let size: (Number, Number) = (ANGLE_SIZE, ANGLE_SIZE);
let document: Document;
let color: String =
format!("#{:06X}", Bodies::EclNut.object_color(theme) as i32);
let data1 = Data::new()
.move_to((4.0, 12.3)) .cubic_curve_by((1.9, -0.3, 4.2, -0.5, 6.7, -0.5)) .cubic_curve_by((4.5, 0.0, 7.7, 1.0, 9.8, 3.0)) .cubic_curve_by((2.2, 2.0, 3.4, 4.8, 3.4, 8.7)) .cubic_curve_by((0.0, 4.0, -1.2, 7.2, -3.5, 9.4)) .cubic_curve_by((-2.3, 2.3, -6.0, 3.5, -10.7, 3.5)) .cubic_curve_by((-2.2, 0.0, -4.1, -0.1, -5.7, -0.3)) .vertical_line_to(12.3) .close() .move_to((7.1, 33.7)) .cubic_curve_by((0.8, 0.1, 1.9, 0.2, 3.2, 0.2)) .cubic_curve_by((6.7, 0.0, 10.3, -3.7, 10.3, -10.3)) .cubic_curve_by((0.0, -5.7, -3.2, -9.4, -9.8, -9.4)) .cubic_curve_by((-1.6, 0.0, -2.8, 0.1, -3.7, 0.3)) .vertical_line_to(33.7) .close(); let data2 = Data::new()
.move_to((44.9, 35.4)) .cubic_curve_by((-1.2, 0.6, -3.5, 1.2, -6.4, 1.2)) .cubic_curve_by((-6.8, 0.0, -12.0, -4.3, -12.0, -12.3)) .cubic_curve_by((0.0, -7.6, 5.1, -12.7, 12.7, -12.7)) .cubic_curve_by((3.0, 0.0, 4.9, 0.6, 5.8, 1.1)) .line_by((-0.8, 2.6)) .cubic_curve_by((-1.2, -0.6, -2.9, -1.0, -4.9, -1.0)) .cubic_curve_by((-5.7, 0.0, -9.5, 3.6, -9.5, 10.0)) .cubic_curve_by((0.0, 5.9, 3.4, 9.8, 9.3, 9.8)) .cubic_curve_by((1.9, 0.0, 3.9, -0.4, 5.1, -1.0)) .line_to((44.9, 35.4)) .close(); let path1 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data1);
let path2 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data2);
let group = Group::new().add(path1).add(path2);
document = Document::new()
.set("viewBox", (0, 0, size.0, size.1))
.add(group);
document
}
fn draw_mc(theme: Theme) -> Document {
let size: (Number, Number) = (ANGLE_SIZE, ANGLE_SIZE);
let document: Document;
let color: String =
format!("#{:06X}", Bodies::EclNut.object_color(theme) as i32);
let data1 = Data::new()
.move_to((22.0, 25.5)) .cubic_curve_by((-0.2, -3.4, -0.4, -7.5, -0.4, -10.5)) .horizontal_line_by(-0.1) .cubic_curve_by((-0.8, 2.8, -1.8, 5.9, -3.1, 9.2)) .line_by((-4.3, 11.8)) .horizontal_line_by(-2.4) .line_to((7.8, 24.5)) .cubic_curve_by((-1.2, -3.4, -2.1, -6.6, -2.8, -9.4)) .horizontal_line_to(5.0) .cubic_curve_by((-0.1, 3.0, -0.3, 7.1, -0.5, 10.7)) .line_to((3.8, 36.2)) .horizontal_line_by(-3.0) .line_by((1.7, -24.3)) .horizontal_line_by(4.0) .line_by((4.1, 11.7)) .cubic_curve_by((1.0, 3.0, 1.8, 5.7, 2.4, 8.2)) .horizontal_line_by(0.1) .cubic_curve_by((0.6, -2.4, 1.5, -5.1, 2.6, -8.2)) .line_by((4.3, -11.7)) .horizontal_line_by(4.0) .line_by((1.5, 24.3)) .horizontal_line_by(-3.1) .line_to((22.0, 25.5)) .close(); let data2 = Data::new()
.move_to((47.4, 35.4)) .cubic_curve_to((46.3, 36.0, 44.0, 36.6, 41.0, 36.6)) .cubic_curve_by((-6.8, 0.0, -12.0, -4.3, -12.0, -12.3)) .cubic_curve_by((0.0, -7.6, 5.1, -12.7, 12.7, -12.7)) .cubic_curve_by((3.0, 0.0, 4.9, 0.6, 5.8, 1.1)) .line_by((-0.8, 2.6)) .cubic_curve_by((-1.2, -0.6, -2.9, -1.0, -4.9, -1.0)) .cubic_curve_by((-5.7, 0.0, -9.5, 3.6, -9.5, 10.0)) .cubic_curve_by((0.0, 5.9, 3.4, 9.8, 9.3, 9.8)) .cubic_curve_by((1.9, 0.0, 3.9, -0.4, 5.1, -1.0)) .line_to((47.4, 35.4)) .close(); let path1 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data1);
let path2 = Path::new()
.set("fill", color.clone())
.set("stroke", color.clone())
.set("stroke-width", 0)
.set("d", data2);
let group = Group::new().add(path1).add(path2);
document = Document::new()
.set("viewBox", (0, 0, size.0, size.1))
.add(group);
document
}