line

Function line 

Source
pub fn line<F: Float + Trig + FromPrimitive>(
    x1: F,
    y1: F,
    x2: F,
    y2: F,
    o: &mut Options,
) -> OpSet<F>
Expand description

Constructs a line primitive that can be rendered into relevant context

§Arguments

  • x1 - Line start point x coordinate
  • y1 - Line start point y coordinate
  • x2 - Line end point x coordinate
  • y2 - Line end point y coordinate
  • o - Line generation options

§Example

Note that result of this call is highly dependent on your selections of options and random number seed you use

use roughr::core::{Op, OpSetType, OpType, OptionsBuilder};
use roughr::renderer::line;

let mut o = OptionsBuilder::default().build().unwrap();
let result = line(0.0, 0.0, 1.0, 0.0, &mut o);
assert_eq!(result.op_set_type, OpSetType::Path);
assert_eq!(result.size, None);
assert_eq!(result.path, None);
assert_eq!(result.ops.len(), 4);
assert_eq!(
    result.ops[0],
    Op {
        op: OpType::Move,
        data: vec![-0.09998378610180225, -0.06502220928668975]
    }
);
assert_eq!(
    result.ops[1],
    Op {
        op: OpType::BCurveTo,
        data: vec![
            0.3744279434863932,
            -0.01609907269477844,
            0.6946386914619221,
            0.02767372608184813,
            1.037581992149353,
            0.012261581420898435
        ]
    }
);
assert_eq!(
    result.ops[2],
    Op {
        op: OpType::Move,
        data: vec![-0.03406156599521637, 0.0372807502746582]
    }
);
assert_eq!(
    result.ops[3],
    Op {
        op: OpType::BCurveTo,
        data: vec![
            0.21661711813283496,
            0.024078675508499146,
            0.4552517569317924,
            0.01821308374404907,
            1.0409734785556792,
            0.03352456092834473
        ],
    },
);