summaryrefslogtreecommitdiff
path: root/src/library/mod.rs
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-03-16 12:36:50 +0100
committerMartin Haug <mhaug@live.de>2022-03-16 12:36:50 +0100
commit4d617bcd67f9e42218da190dc9a0bf2f10d4b78d (patch)
treefea275e9321004c15ed7d1def9f3749641f648ed /src/library/mod.rs
parent288a926feae1e73dff5a6b103aa920d6f7eb0f35 (diff)
`LineNode`
Diffstat (limited to 'src/library/mod.rs')
-rw-r--r--src/library/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs
index 8f00e5fe..88f003c2 100644
--- a/src/library/mod.rs
+++ b/src/library/mod.rs
@@ -53,6 +53,7 @@ pub fn new() -> Scope {
// Graphics.
std.def_node::<graphics::ImageNode>("image");
+ std.def_node::<graphics::LineNode>("line");
std.def_node::<graphics::RectNode>("rect");
std.def_node::<graphics::SquareNode>("square");
std.def_node::<graphics::EllipseNode>("ellipse");
@@ -170,3 +171,14 @@ castable! {
Expected: "content",
Value::Content(content) => content.pack(),
}
+
+castable! {
+ Spec<Linear>,
+ Expected: "two-dimensional length array",
+ Value::Array(array) => {
+ let e = "point array must contain exactly two entries";
+ let a = array.get(0).map_err(|_| e)?.clone().cast::<Linear>()?;
+ let b = array.get(1).map_err(|_| e)?.clone().cast::<Linear>()?;
+ Spec::new(a, b)
+ },
+}