pub struct Viewer { /* private fields */ }
Expand description
Viewer struct is used to view points, edges, and curves in OpenSCAD.
Implementations§
source§impl Viewer
impl Viewer
sourcepub fn new(point_radius: f64, edge_radius: f64, segments: u64) -> Self
pub fn new(point_radius: f64, edge_radius: f64, segments: u64) -> Self
Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 42)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
fn main() {
let mut curve = dim2::CubicBezierChain2D::new(
Pt2::new(0.0, 0.0),
Pt2::new(40.0, -20.0),
Pt2::new(40.0, 80.0),
Pt2::new(0.0, 40.0),
24,
);
curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_cubic_bezier_chain2d(&curve);
scad_file!("output/view_cubic_bezier_chain.scad",
viewer.into_scad();
);
}
More examples
examples/bezier_star_sweep.rs (line 44)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
fn main() {
let output_viewer = false;
let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
if output_viewer {
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_bezier_star(&path);
let mut small_viewer = Viewer::new(0.05, 0.025, 6);
small_viewer.add_bezier_star(&profile);
scad_file!("output/bezier_star_sweep.scad",
small_viewer.into_scad() + viewer.into_scad();
);
} else {
let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
let profile = profile.gen_points();
let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
scad_file!("output/bezier_star_sweep.scad",
star_swept.into_scad();
);
}
}
pub fn add_pt2(&mut self, point: Pt2, color: ScadColor)
pub fn add_pt3(&mut self, point: Pt3, color: ScadColor)
pub fn add_pt2s(&mut self, points: &Pt2s, color: ScadColor)
pub fn add_pt3s(&mut self, points: &Pt3s, color: ScadColor)
pub fn add_lines2d(&mut self, edges: &Vec<(Pt2, Pt2)>, color: ScadColor)
pub fn add_lines3d(&mut self, edges: &Vec<(Pt3, Pt3)>, color: ScadColor)
pub fn add_quadratic_bezier2d(&mut self, curve: &QuadraticBezier2D)
pub fn add_quadratic_bezier3d(&mut self, curve: &QuadraticBezier3D)
pub fn add_cubic_bezier2d(&mut self, curve: &CubicBezier2D)
pub fn add_cubic_bezier3d(&mut self, curve: &CubicBezier3D)
sourcepub fn add_cubic_bezier_chain2d(&mut self, curve: &CubicBezierChain2D)
pub fn add_cubic_bezier_chain2d(&mut self, curve: &CubicBezierChain2D)
Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 43)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
fn main() {
let mut curve = dim2::CubicBezierChain2D::new(
Pt2::new(0.0, 0.0),
Pt2::new(40.0, -20.0),
Pt2::new(40.0, 80.0),
Pt2::new(0.0, 40.0),
24,
);
curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_cubic_bezier_chain2d(&curve);
scad_file!("output/view_cubic_bezier_chain.scad",
viewer.into_scad();
);
}
pub fn add_cubic_bezier_chain3d(&mut self, curve: &CubicBezierChain3D)
sourcepub fn add_bezier_star(&mut self, star: &BezierStar)
pub fn add_bezier_star(&mut self, star: &BezierStar)
Examples found in repository?
examples/bezier_star_sweep.rs (line 45)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
fn main() {
let output_viewer = false;
let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
if output_viewer {
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_bezier_star(&path);
let mut small_viewer = Viewer::new(0.05, 0.025, 6);
small_viewer.add_bezier_star(&profile);
scad_file!("output/bezier_star_sweep.scad",
small_viewer.into_scad() + viewer.into_scad();
);
} else {
let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
let profile = profile.gen_points();
let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
scad_file!("output/bezier_star_sweep.scad",
star_swept.into_scad();
);
}
}
sourcepub fn into_scad(self) -> Scad
pub fn into_scad(self) -> Scad
Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 45)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
fn main() {
let mut curve = dim2::CubicBezierChain2D::new(
Pt2::new(0.0, 0.0),
Pt2::new(40.0, -20.0),
Pt2::new(40.0, 80.0),
Pt2::new(0.0, 40.0),
24,
);
curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_cubic_bezier_chain2d(&curve);
scad_file!("output/view_cubic_bezier_chain.scad",
viewer.into_scad();
);
}
More examples
examples/bezier_star_sweep.rs (line 49)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
fn main() {
let output_viewer = false;
let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
if output_viewer {
let mut viewer = Viewer::new(0.5, 0.25, 6);
viewer.add_bezier_star(&path);
let mut small_viewer = Viewer::new(0.05, 0.025, 6);
small_viewer.add_bezier_star(&profile);
scad_file!("output/bezier_star_sweep.scad",
small_viewer.into_scad() + viewer.into_scad();
);
} else {
let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
let profile = profile.gen_points();
let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
scad_file!("output/bezier_star_sweep.scad",
star_swept.into_scad();
);
}
}