1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
//! The standard library.
//!
//! Call [`new`] to obtain a [`Scope`] containing all standard library
//! definitions.
mod align;
mod deco;
mod document;
mod flow;
mod grid;
mod image;
mod pad;
mod page;
mod par;
mod shape;
mod sized;
mod spacing;
mod stack;
mod text;
mod transform;
mod utility;
/// Helpful imports for creating library functionality.
mod prelude {
pub use std::rc::Rc;
pub use crate::diag::{At, TypResult};
pub use crate::eval::{Args, EvalContext, Template, Value};
pub use crate::frame::*;
pub use crate::geom::*;
pub use crate::layout::*;
pub use crate::syntax::{Span, Spanned};
pub use crate::util::{EcoString, OptionExt};
}
pub use self::image::*;
pub use align::*;
pub use deco::*;
pub use document::*;
pub use flow::*;
pub use grid::*;
pub use pad::*;
pub use page::*;
pub use par::*;
pub use shape::*;
pub use sized::*;
pub use spacing::*;
pub use stack::*;
pub use text::*;
pub use transform::*;
pub use utility::*;
use crate::eval::{Scope, Value};
use crate::geom::*;
use crate::style::FontFamily;
/// Construct a scope containing all standard library definitions.
pub fn new() -> Scope {
let mut std = Scope::new();
// Text.
std.def_func("font", font);
std.def_func("par", par);
std.def_func("strike", strike);
std.def_func("underline", underline);
std.def_func("overline", overline);
std.def_func("link", link);
// Layout.
std.def_func("page", page);
std.def_func("pagebreak", pagebreak);
std.def_func("h", h);
std.def_func("v", v);
std.def_func("align", align);
std.def_func("box", box_);
std.def_func("block", block);
std.def_func("flow", flow);
std.def_func("pad", pad);
std.def_func("move", move_);
std.def_func("stack", stack);
std.def_func("grid", grid);
// Elements.
std.def_func("image", image);
std.def_func("rect", rect);
std.def_func("square", square);
std.def_func("ellipse", ellipse);
std.def_func("circle", circle);
// Utility.
std.def_func("assert", assert);
std.def_func("type", type_);
std.def_func("repr", repr);
std.def_func("join", join);
std.def_func("int", int);
std.def_func("float", float);
std.def_func("str", str);
std.def_func("abs", abs);
std.def_func("min", min);
std.def_func("max", max);
std.def_func("range", range);
std.def_func("rgb", rgb);
std.def_func("lower", lower);
std.def_func("upper", upper);
std.def_func("len", len);
std.def_func("sorted", sorted);
// Colors.
std.def_const("white", RgbaColor::WHITE);
std.def_const("black", RgbaColor::BLACK);
std.def_const("eastern", RgbaColor::new(0x23, 0x9D, 0xAD, 0xFF));
std.def_const("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF));
std.def_const("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF));
// Arbitrary constants.
std.def_const("ltr", Dir::LTR);
std.def_const("rtl", Dir::RTL);
std.def_const("ttb", Dir::TTB);
std.def_const("btt", Dir::BTT);
std.def_const("left", Align::Left);
std.def_const("top", Align::Top);
std.def_const("center", Align::Center);
std.def_const("right", Align::Right);
std.def_const("bottom", Align::Bottom);
std.def_const("serif", FontFamily::Serif);
std.def_const("sans-serif", FontFamily::SansSerif);
std.def_const("monospace", FontFamily::Monospace);
std
}
dynamic! {
Dir: "direction",
}
dynamic! {
Align: "alignment",
}
dynamic! {
FontFamily: "font family",
Value::Str(string) => Self::Named(string.to_lowercase()),
}
|