use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
ColorScalar, IntoDrawn, IntoRgba, Primitive, SetColor, SetDimensions, SetOrientation,
SetPosition,
};
use crate::draw::{self, Draw};
use crate::geom::graph::node;
use crate::geom::{self, Point2, Point3, Vector2, Vector3};
use crate::math::{Angle, BaseFloat, Euler, Quaternion, Rad};
use std::marker::PhantomData;
#[derive(Debug)]
pub struct Drawing<'a, T, S = geom::scalar::Default>
where
T: IntoDrawn<S>,
S: 'a + BaseFloat,
{
draw: &'a Draw<S>,
index: node::Index,
finish_on_drop: bool,
_ty: PhantomData<T>,
}
pub fn new<'a, T, S>(draw: &'a Draw<S>, index: node::Index) -> Drawing<'a, T, S>
where
T: IntoDrawn<S>,
S: BaseFloat,
{
let _ty = PhantomData;
let finish_on_drop = true;
Drawing {
draw,
index,
finish_on_drop,
_ty,
}
}
impl<'a, T, S> Drop for Drawing<'a, T, S>
where
T: IntoDrawn<S>,
S: BaseFloat,
{
fn drop(&mut self) {
if self.finish_on_drop {
self.finish_inner().expect(
"the drawing contained a relative edge that would have \
caused a cycle within the geometry graph",
);
}
}
}
impl<'a, T, S> Drawing<'a, T, S>
where
T: IntoDrawn<S>,
S: BaseFloat,
{
fn finish_inner(&mut self) -> Result<(), geom::graph::WouldCycle<S>> {
if let Ok(mut state) = self.draw.state.try_borrow_mut() {
if let Some(prim) = state.drawing.remove(&self.index) {
let index = self.index;
draw::draw_primitive(&mut state, index, prim)?;
}
}
Ok(())
}
pub fn finish(mut self) -> Result<(), geom::graph::WouldCycle<S>> {
self.finish_inner()
}
pub fn id(self) -> node::Index {
let id = self.index;
self.finish().expect(draw::WOULD_CYCLE);
id
}
fn map_primitive<F, T2>(mut self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(draw::properties::Primitive<S>) -> draw::properties::Primitive<S>,
T2: IntoDrawn<S> + Into<Primitive<S>>,
{
if let Ok(mut state) = self.draw.state.try_borrow_mut() {
if let Some(mut primitive) = state.drawing.remove(&self.index) {
primitive = map(primitive);
state.drawing.insert(self.index, primitive);
}
}
self.finish_on_drop = false;
let Drawing { draw, index, .. } = self;
Drawing {
draw,
index,
finish_on_drop: true,
_ty: PhantomData,
}
}
fn map_primitive_with_vertices<F, T2>(mut self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(
draw::properties::Primitive<S>,
&mut draw::IntermediaryMesh<S>,
) -> draw::properties::Primitive<S>,
T2: IntoDrawn<S> + Into<Primitive<S>>,
{
if let Ok(mut state) = self.draw.state.try_borrow_mut() {
if let Some(mut primitive) = state.drawing.remove(&self.index) {
{
let mut intermediary_mesh = state.intermediary_mesh.borrow_mut();
primitive = map(primitive, &mut *intermediary_mesh);
}
state.drawing.insert(self.index, primitive);
}
}
self.finish_on_drop = false;
let Drawing { draw, index, .. } = self;
Drawing {
draw,
index,
finish_on_drop: true,
_ty: PhantomData,
}
}
pub fn map_ty<F, T2>(self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(T) -> T2,
T2: IntoDrawn<S> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
{
self.map_primitive(|prim| {
let maybe_ty: Option<T> = prim.into();
let ty = maybe_ty.expect("expected `T` but primitive contained different type");
let ty2 = map(ty);
ty2.into()
})
}
pub(crate) fn map_ty_with_vertices<F, T2>(self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(T, &mut draw::IntermediaryMesh<S>) -> T2,
T2: IntoDrawn<S> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
{
self.map_primitive_with_vertices(|prim, v_data| {
let maybe_ty: Option<T> = prim.into();
let ty = maybe_ty.expect("expected `T` but primitive contained different type");
let ty2 = map(ty, v_data);
ty2.into()
})
}
}
impl<'a, T, S> Drawing<'a, T, S>
where
T: IntoDrawn<S> + SetColor<ColorScalar> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
S: BaseFloat,
{
pub fn color<C>(self, color: C) -> Self
where
C: IntoRgba<ColorScalar>,
{
self.map_ty(|ty| SetColor::color(ty, color))
}
pub fn rgb(self, r: ColorScalar, g: ColorScalar, b: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::rgb(ty, r, g, b))
}
pub fn rgba(self, r: ColorScalar, g: ColorScalar, b: ColorScalar, a: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::rgba(ty, r, g, b, a))
}
pub fn hsl(self, h: ColorScalar, s: ColorScalar, l: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::hsl(ty, h, s, l))
}
pub fn hsla(self, h: ColorScalar, s: ColorScalar, l: ColorScalar, a: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::hsla(ty, h, s, l, a))
}
pub fn hsv(self, h: ColorScalar, s: ColorScalar, v: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::hsv(ty, h, s, v))
}
pub fn hsva(self, h: ColorScalar, s: ColorScalar, v: ColorScalar, a: ColorScalar) -> Self {
self.map_ty(|ty| SetColor::hsva(ty, h, s, v, a))
}
}
impl<'a, T, S> Drawing<'a, T, S>
where
T: IntoDrawn<S> + SetDimensions<S> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
S: BaseFloat,
{
pub fn x_dimension(self, x: dimension::Dimension<S>) -> Self {
self.map_ty(|ty| SetDimensions::x_dimension(ty, x))
}
pub fn y_dimension(self, y: dimension::Dimension<S>) -> Self {
self.map_ty(|ty| SetDimensions::y_dimension(ty, y))
}
pub fn z_dimension(self, z: dimension::Dimension<S>) -> Self {
self.map_ty(|ty| SetDimensions::z_dimension(ty, z))
}
pub fn width(self, w: S) -> Self {
self.map_ty(|ty| SetDimensions::width(ty, w))
}
pub fn height(self, h: S) -> Self {
self.map_ty(|ty| SetDimensions::height(ty, h))
}
pub fn depth(self, d: S) -> Self {
self.map_ty(|ty| SetDimensions::depth(ty, d))
}
pub fn w(self, w: S) -> Self {
self.map_ty(|ty| SetDimensions::w(ty, w))
}
pub fn h(self, h: S) -> Self {
self.map_ty(|ty| SetDimensions::h(ty, h))
}
pub fn d(self, d: S) -> Self {
self.map_ty(|ty| SetDimensions::d(ty, d))
}
pub fn wh(self, v: Vector2<S>) -> Self {
self.map_ty(|ty| SetDimensions::wh(ty, v))
}
pub fn whd(self, v: Vector3<S>) -> Self {
self.map_ty(|ty| SetDimensions::whd(ty, v))
}
pub fn w_h(self, x: S, y: S) -> Self {
self.map_ty(|ty| SetDimensions::w_h(ty, x, y))
}
pub fn w_h_d(self, x: S, y: S, z: S) -> Self {
self.map_ty(|ty| SetDimensions::w_h_d(ty, x, y, z))
}
pub fn x_dimension_relative(self, other: node::Index, x: dimension::Relative<S>) -> Self {
self.map_ty(|ty| SetDimensions::x_dimension_relative(ty, other, x))
}
pub fn y_dimension_relative(self, other: node::Index, y: dimension::Relative<S>) -> Self {
self.map_ty(|ty| SetDimensions::y_dimension_relative(ty, other, y))
}
pub fn z_dimension_relative(self, other: node::Index, z: dimension::Relative<S>) -> Self {
self.map_ty(|ty| SetDimensions::z_dimension_relative(ty, other, z))
}
pub fn w_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetDimensions::w_of(ty, other))
}
pub fn h_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetDimensions::h_of(ty, other))
}
pub fn d_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetDimensions::d_of(ty, other))
}
pub fn wh_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetDimensions::wh_of(ty, other))
}
pub fn whd_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetDimensions::whd_of(ty, other))
}
pub fn padded_w_of(self, other: node::Index, pad: S) -> Self {
self.map_ty(|ty| SetDimensions::padded_w_of(ty, other, pad))
}
pub fn padded_h_of(self, other: node::Index, pad: S) -> Self {
self.map_ty(|ty| SetDimensions::padded_h_of(ty, other, pad))
}
pub fn padded_d_of(self, other: node::Index, pad: S) -> Self {
self.map_ty(|ty| SetDimensions::padded_d_of(ty, other, pad))
}
pub fn padded_wh_of(self, other: node::Index, pad: S) -> Self
where
S: Clone,
{
self.map_ty(|ty| SetDimensions::padded_wh_of(ty, other, pad))
}
pub fn padded_whd_of(self, other: node::Index, pad: S) -> Self
where
S: Clone,
{
self.map_ty(|ty| SetDimensions::padded_whd_of(ty, other, pad))
}
pub fn scaled_w_of(self, other: node::Index, scale: S) -> Self {
self.map_ty(|ty| SetDimensions::scaled_w_of(ty, other, scale))
}
pub fn scaled_h_of(self, other: node::Index, scale: S) -> Self {
self.map_ty(|ty| SetDimensions::scaled_h_of(ty, other, scale))
}
pub fn scaled_d_of(self, other: node::Index, scale: S) -> Self {
self.map_ty(|ty| SetDimensions::scaled_d_of(ty, other, scale))
}
pub fn scaled_wh_of(self, other: node::Index, scale: S) -> Self
where
S: Clone,
{
self.map_ty(|ty| SetDimensions::scaled_wh_of(ty, other, scale))
}
pub fn scaled_whd_of(self, other: node::Index, scale: S) -> Self
where
S: Clone,
{
self.map_ty(|ty| SetDimensions::scaled_whd_of(ty, other, scale))
}
}
impl<'a, T, S> Drawing<'a, T, S>
where
T: IntoDrawn<S> + SetPosition<S> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
S: BaseFloat,
{
pub fn x_position(self, position: position::Position<S>) -> Self {
self.map_ty(|ty| SetPosition::x_position(ty, position))
}
pub fn y_position(self, position: position::Position<S>) -> Self {
self.map_ty(|ty| SetPosition::y_position(ty, position))
}
pub fn z_position(self, position: position::Position<S>) -> Self {
self.map_ty(|ty| SetPosition::z_position(ty, position))
}
pub fn x(self, x: S) -> Self {
self.map_ty(|ty| SetPosition::x(ty, x))
}
pub fn y(self, y: S) -> Self {
self.map_ty(|ty| SetPosition::y(ty, y))
}
pub fn z(self, z: S) -> Self {
self.map_ty(|ty| SetPosition::z(ty, z))
}
pub fn xy(self, p: Point2<S>) -> Self {
self.map_ty(|ty| SetPosition::xy(ty, p))
}
pub fn xyz(self, p: Point3<S>) -> Self {
self.map_ty(|ty| SetPosition::xyz(ty, p))
}
pub fn x_y(self, x: S, y: S) -> Self {
self.map_ty(|ty| SetPosition::x_y(ty, x, y))
}
pub fn x_y_z(self, x: S, y: S, z: S) -> Self {
self.map_ty(|ty| SetPosition::x_y_z(ty, x, y, z))
}
pub fn x_position_relative(self, x: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::x_position_relative(ty, x))
}
pub fn y_position_relative(self, y: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::y_position_relative(ty, y))
}
pub fn z_position_relative(self, z: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::z_position_relative(ty, z))
}
pub fn x_y_position_relative(self, x: position::Relative<S>, y: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::x_y_position_relative(ty, x, y))
}
pub fn x_y_z_position_relative(
self,
x: position::Relative<S>,
y: position::Relative<S>,
z: position::Relative<S>,
) -> Self {
self.map_ty(|ty| SetPosition::x_y_z_position_relative(ty, x, y, z))
}
pub fn x_position_relative_to(self, other: node::Index, x: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::x_position_relative_to(ty, other, x))
}
pub fn y_position_relative_to(self, other: node::Index, y: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::y_position_relative_to(ty, other, y))
}
pub fn z_position_relative_to(self, other: node::Index, z: position::Relative<S>) -> Self {
self.map_ty(|ty| SetPosition::z_position_relative_to(ty, other, z))
}
pub fn x_y_position_relative_to(
self,
other: node::Index,
x: position::Relative<S>,
y: position::Relative<S>,
) -> Self {
self.map_ty(|ty| SetPosition::x_y_position_relative_to(ty, other, x, y))
}
pub fn x_y_z_position_relative_to(
self,
other: node::Index,
x: position::Relative<S>,
y: position::Relative<S>,
z: position::Relative<S>,
) -> Self {
self.map_ty(|ty| SetPosition::x_y_z_position_relative_to(ty, other, x, y, z))
}
pub fn x_relative(self, x: S) -> Self {
self.map_ty(|ty| SetPosition::x_relative(ty, x))
}
pub fn y_relative(self, y: S) -> Self {
self.map_ty(|ty| SetPosition::y_relative(ty, y))
}
pub fn z_relative(self, z: S) -> Self {
self.map_ty(|ty| SetPosition::z_relative(ty, z))
}
pub fn xy_relative(self, p: Point2<S>) -> Self {
self.map_ty(|ty| SetPosition::xy_relative(ty, p))
}
pub fn xyz_relative(self, p: Point3<S>) -> Self {
self.map_ty(|ty| SetPosition::xyz_relative(ty, p))
}
pub fn x_y_relative(self, x: S, y: S) -> Self {
self.map_ty(|ty| SetPosition::x_y_relative(ty, x, y))
}
pub fn x_y_z_relative(self, x: S, y: S, z: S) -> Self {
self.map_ty(|ty| SetPosition::x_y_z_relative(ty, x, y, z))
}
pub fn x_relative_to(self, other: node::Index, x: S) -> Self {
self.map_ty(|ty| SetPosition::x_relative_to(ty, other, x))
}
pub fn y_relative_to(self, other: node::Index, y: S) -> Self {
self.map_ty(|ty| SetPosition::y_relative_to(ty, other, y))
}
pub fn z_relative_to(self, other: node::Index, z: S) -> Self {
self.map_ty(|ty| SetPosition::z_relative_to(ty, other, z))
}
pub fn xy_relative_to(self, other: node::Index, p: Point2<S>) -> Self {
self.map_ty(|ty| SetPosition::xy_relative_to(ty, other, p))
}
pub fn xyz_relative_to(self, other: node::Index, p: Point3<S>) -> Self {
self.map_ty(|ty| SetPosition::xyz_relative_to(ty, other, p))
}
pub fn x_y_relative_to(self, other: node::Index, x: S, y: S) -> Self {
self.map_ty(|ty| SetPosition::x_y_relative_to(ty, other, x, y))
}
pub fn x_y_z_relative_to(self, other: node::Index, x: S, y: S, z: S) -> Self {
self.map_ty(|ty| SetPosition::x_y_z_relative_to(ty, other, x, y, z))
}
pub fn x_direction(self, direction: position::Direction, x: S) -> Self {
self.map_ty(|ty| SetPosition::x_direction(ty, direction, x))
}
pub fn y_direction(self, direction: position::Direction, y: S) -> Self {
self.map_ty(|ty| SetPosition::y_direction(ty, direction, y))
}
pub fn z_direction(self, direction: position::Direction, z: S) -> Self {
self.map_ty(|ty| SetPosition::z_direction(ty, direction, z))
}
pub fn left(self, x: S) -> Self {
self.map_ty(|ty| SetPosition::left(ty, x))
}
pub fn right(self, x: S) -> Self {
self.map_ty(|ty| SetPosition::right(ty, x))
}
pub fn down(self, y: S) -> Self {
self.map_ty(|ty| SetPosition::down(ty, y))
}
pub fn up(self, y: S) -> Self {
self.map_ty(|ty| SetPosition::up(ty, y))
}
pub fn backwards(self, z: S) -> Self {
self.map_ty(|ty| SetPosition::backwards(ty, z))
}
pub fn forwards(self, z: S) -> Self {
self.map_ty(|ty| SetPosition::forwards(ty, z))
}
pub fn x_direction_from(
self,
other: node::Index,
direction: position::Direction,
x: S,
) -> Self {
self.map_ty(|ty| SetPosition::x_direction_from(ty, other, direction, x))
}
pub fn y_direction_from(
self,
other: node::Index,
direction: position::Direction,
y: S,
) -> Self {
self.map_ty(|ty| SetPosition::y_direction_from(ty, other, direction, y))
}
pub fn z_direction_from(
self,
other: node::Index,
direction: position::Direction,
z: S,
) -> Self {
self.map_ty(|ty| SetPosition::z_direction_from(ty, other, direction, z))
}
pub fn left_from(self, other: node::Index, x: S) -> Self {
self.map_ty(|ty| SetPosition::left_from(ty, other, x))
}
pub fn right_from(self, other: node::Index, x: S) -> Self {
self.map_ty(|ty| SetPosition::right_from(ty, other, x))
}
pub fn down_from(self, other: node::Index, y: S) -> Self {
self.map_ty(|ty| SetPosition::down_from(ty, other, y))
}
pub fn up_from(self, other: node::Index, y: S) -> Self {
self.map_ty(|ty| SetPosition::up_from(ty, other, y))
}
pub fn backwards_from(self, other: node::Index, z: S) -> Self {
self.map_ty(|ty| SetPosition::backwards_from(ty, other, z))
}
pub fn forwards_from(self, other: node::Index, z: S) -> Self {
self.map_ty(|ty| SetPosition::forwards_from(ty, other, z))
}
pub fn x_align(self, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::x_align(ty, align))
}
pub fn y_align(self, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::y_align(ty, align))
}
pub fn z_align(self, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::z_align(ty, align))
}
pub fn align_left(self) -> Self {
self.map_ty(|ty| SetPosition::align_left(ty))
}
pub fn align_left_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_left_with_margin(ty, margin))
}
pub fn align_middle_x(self) -> Self {
self.map_ty(|ty| SetPosition::align_middle_x(ty))
}
pub fn align_right(self) -> Self {
self.map_ty(|ty| SetPosition::align_right(ty))
}
pub fn align_right_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_right_with_margin(ty, margin))
}
pub fn align_bottom(self) -> Self {
self.map_ty(|ty| SetPosition::align_bottom(ty))
}
pub fn align_bottom_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_bottom_with_margin(ty, margin))
}
pub fn align_middle_y(self) -> Self {
self.map_ty(|ty| SetPosition::align_middle_y(ty))
}
pub fn align_top(self) -> Self {
self.map_ty(|ty| SetPosition::align_top(ty))
}
pub fn align_top_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_top_with_margin(ty, margin))
}
pub fn align_front(self) -> Self {
self.map_ty(|ty| SetPosition::align_front(ty))
}
pub fn align_front_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_front_with_margin(ty, margin))
}
pub fn align_middle_z(self) -> Self {
self.map_ty(|ty| SetPosition::align_middle_z(ty))
}
pub fn align_back(self) -> Self {
self.map_ty(|ty| SetPosition::align_back(ty))
}
pub fn align_back_with_margin(self, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_back_with_margin(ty, margin))
}
pub fn x_align_to(self, other: node::Index, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::x_align_to(ty, other, align))
}
pub fn y_align_to(self, other: node::Index, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::y_align_to(ty, other, align))
}
pub fn z_align_to(self, other: node::Index, align: position::Align<S>) -> Self {
self.map_ty(|ty| SetPosition::z_align_to(ty, other, align))
}
pub fn align_left_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_left_of(ty, other))
}
pub fn align_left_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_left_of_with_margin(ty, other, margin))
}
pub fn align_middle_x_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_middle_x_of(ty, other))
}
pub fn align_right_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_right_of(ty, other))
}
pub fn align_right_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_right_of_with_margin(ty, other, margin))
}
pub fn align_bottom_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_bottom_of(ty, other))
}
pub fn align_bottom_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_bottom_of_with_margin(ty, other, margin))
}
pub fn align_middle_y_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_middle_y_of(ty, other))
}
pub fn align_top_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_top_of(ty, other))
}
pub fn align_top_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_top_of_with_margin(ty, other, margin))
}
pub fn align_front_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_front_of(ty, other))
}
pub fn align_front_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_front_of_with_margin(ty, other, margin))
}
pub fn align_middle_z_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_middle_z_of(ty, other))
}
pub fn align_back_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::align_back_of(ty, other))
}
pub fn align_back_of_with_margin(self, other: node::Index, margin: S) -> Self {
self.map_ty(|ty| SetPosition::align_back_of_with_margin(ty, other, margin))
}
pub fn middle(self) -> Self {
self.map_ty(|ty| SetPosition::middle(ty))
}
pub fn bottom_left(self) -> Self {
self.map_ty(|ty| SetPosition::bottom_left(ty))
}
pub fn mid_left(self) -> Self {
self.map_ty(|ty| SetPosition::mid_left(ty))
}
pub fn top_left(self) -> Self {
self.map_ty(|ty| SetPosition::top_left(ty))
}
pub fn mid_top(self) -> Self {
self.map_ty(|ty| SetPosition::mid_top(ty))
}
pub fn top_right(self) -> Self {
self.map_ty(|ty| SetPosition::top_right(ty))
}
pub fn mid_right(self) -> Self {
self.map_ty(|ty| SetPosition::mid_right(ty))
}
pub fn bottom_right(self) -> Self {
self.map_ty(|ty| SetPosition::bottom_right(ty))
}
pub fn mid_bottom(self) -> Self {
self.map_ty(|ty| SetPosition::mid_bottom(ty))
}
pub fn middle_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::middle_of(ty, other))
}
pub fn bottom_left_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::bottom_left_of(ty, other))
}
pub fn mid_left_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::mid_left_of(ty, other))
}
pub fn top_left_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::top_left_of(ty, other))
}
pub fn mid_top_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::mid_top_of(ty, other))
}
pub fn top_right_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::top_right_of(ty, other))
}
pub fn mid_right_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::mid_right_of(ty, other))
}
pub fn bottom_right_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::bottom_right_of(ty, other))
}
pub fn mid_bottom_of(self, other: node::Index) -> Self {
self.map_ty(|ty| SetPosition::mid_bottom_of(ty, other))
}
}
impl<'a, T, S> Drawing<'a, T, S>
where
T: IntoDrawn<S> + SetOrientation<S> + Into<Primitive<S>>,
Primitive<S>: Into<Option<T>>,
S: BaseFloat,
{
pub fn look_at(self, target: orientation::LookAt<S>) -> Self {
self.map_ty(|ty| SetOrientation::look_at(ty, target))
}
pub fn look_at_node(self, node: node::Index) -> Self {
self.map_ty(|ty| SetOrientation::look_at_node(ty, node))
}
pub fn look_at_point(self, point: Point3<S>) -> Self {
self.map_ty(|ty| SetOrientation::look_at_point(ty, point))
}
pub fn x_orientation(self, orientation: orientation::Orientation<S>) -> Self {
self.map_ty(|ty| SetOrientation::x_orientation(ty, orientation))
}
pub fn y_orientation(self, orientation: orientation::Orientation<S>) -> Self {
self.map_ty(|ty| SetOrientation::y_orientation(ty, orientation))
}
pub fn z_orientation(self, orientation: orientation::Orientation<S>) -> Self {
self.map_ty(|ty| SetOrientation::z_orientation(ty, orientation))
}
pub fn x_radians(self, x: S) -> Self {
self.map_ty(|ty| SetOrientation::x_radians(ty, x))
}
pub fn y_radians(self, y: S) -> Self {
self.map_ty(|ty| SetOrientation::y_radians(ty, y))
}
pub fn z_radians(self, z: S) -> Self {
self.map_ty(|ty| SetOrientation::y_radians(ty, z))
}
pub fn x_degrees(self, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_degrees(ty, x))
}
pub fn y_degrees(self, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_degrees(ty, y))
}
pub fn z_degrees(self, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_degrees(ty, z))
}
pub fn x_turns(self, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_turns(ty, x))
}
pub fn y_turns(self, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_turns(ty, y))
}
pub fn z_turns(self, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_turns(ty, z))
}
pub fn radians(self, v: Vector3<S>) -> Self {
self.map_ty(|ty| SetOrientation::radians(ty, v))
}
pub fn degrees(self, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::degrees(ty, v))
}
pub fn turns(self, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::turns(ty, v))
}
pub fn euler<A>(self, e: Euler<A>) -> Self
where
S: BaseFloat,
A: Angle + Into<Rad<S>>,
{
self.map_ty(|ty| SetOrientation::euler(ty, e))
}
pub fn quaternion(self, q: Quaternion<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::quaternion(ty, q))
}
pub fn x_radians_relative(self, x: S) -> Self {
self.map_ty(|ty| SetOrientation::x_radians_relative(ty, x))
}
pub fn y_radians_relative(self, y: S) -> Self {
self.map_ty(|ty| SetOrientation::y_radians_relative(ty, y))
}
pub fn z_radians_relative(self, z: S) -> Self {
self.map_ty(|ty| SetOrientation::z_radians_relative(ty, z))
}
pub fn x_radians_relative_to(self, other: node::Index, x: S) -> Self {
self.map_ty(|ty| SetOrientation::x_radians_relative_to(ty, other, x))
}
pub fn y_radians_relative_to(self, other: node::Index, y: S) -> Self {
self.map_ty(|ty| SetOrientation::y_radians_relative_to(ty, other, y))
}
pub fn z_radians_relative_to(self, other: node::Index, z: S) -> Self {
self.map_ty(|ty| SetOrientation::z_radians_relative_to(ty, other, z))
}
pub fn x_degrees_relative(self, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_degrees_relative(ty, x))
}
pub fn y_degrees_relative(self, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_degrees_relative(ty, y))
}
pub fn z_degrees_relative(self, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_degrees_relative(ty, z))
}
pub fn x_degrees_relative_to(self, other: node::Index, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_degrees_relative_to(ty, other, x))
}
pub fn y_degrees_relative_to(self, other: node::Index, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_degrees_relative_to(ty, other, y))
}
pub fn z_degrees_relative_to(self, other: node::Index, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_degrees_relative_to(ty, other, z))
}
pub fn x_turns_relative(self, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_turns_relative(ty, x))
}
pub fn y_turns_relative(self, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_turns_relative(ty, y))
}
pub fn z_turns_relative(self, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_turns_relative(ty, z))
}
pub fn x_turns_relative_to(self, other: node::Index, x: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::x_turns_relative_to(ty, other, x))
}
pub fn y_turns_relative_to(self, other: node::Index, y: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::y_turns_relative_to(ty, other, y))
}
pub fn z_turns_relative_to(self, other: node::Index, z: S) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::z_turns_relative_to(ty, other, z))
}
pub fn radians_relative(self, v: Vector3<S>) -> Self {
self.map_ty(|ty| SetOrientation::radians_relative(ty, v))
}
pub fn radians_relative_to(self, other: node::Index, v: Vector3<S>) -> Self {
self.map_ty(|ty| SetOrientation::radians_relative_to(ty, other, v))
}
pub fn degrees_relative(self, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::degrees_relative(ty, v))
}
pub fn degrees_relative_to(self, other: node::Index, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::degrees_relative_to(ty, other, v))
}
pub fn turns_relative(self, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::turns_relative(ty, v))
}
pub fn turns_relative_to(self, other: node::Index, v: Vector3<S>) -> Self
where
S: BaseFloat,
{
self.map_ty(|ty| SetOrientation::turns_relative_to(ty, other, v))
}
pub fn euler_relative<A>(self, e: Euler<A>) -> Self
where
S: BaseFloat,
A: Angle + Into<Rad<S>>,
{
self.map_ty(|ty| SetOrientation::euler_relative(ty, e))
}
pub fn euler_relative_to<A>(self, other: node::Index, e: Euler<A>) -> Self
where
S: BaseFloat,
A: Angle + Into<Rad<S>>,
{
self.map_ty(|ty| SetOrientation::euler_relative_to(ty, other, e))
}
pub fn pitch(self, pitch: S) -> Self {
self.map_ty(|ty| SetOrientation::pitch(ty, pitch))
}
pub fn yaw(self, yaw: S) -> Self {
self.map_ty(|ty| SetOrientation::yaw(ty, yaw))
}
pub fn roll(self, roll: S) -> Self {
self.map_ty(|ty| SetOrientation::roll(ty, roll))
}
pub fn rotate(self, radians: S) -> Self {
self.map_ty(|ty| SetOrientation::rotate(ty, radians))
}
}