diff --git a/examples/Basics/logo.scad b/examples/Basics/logo.scad index 1f7aeb9f..9259098e 100644 --- a/examples/Basics/logo.scad +++ b/examples/Basics/logo.scad @@ -1,18 +1,23 @@ -// logo.scad - Basic example of difference() usage in OpenSCAD +// logo.scad - Basic example of module, top-level variable and $fn usage -size = 50; -hole = 25; -cylinderHeight = size * 1.25; -$fn = 32; // Increasing this makes the logo smoother +Logo(50); -// One positive object (sphere) and three negative objects (cylinders) -difference() { - sphere(d=size); +// The $fn parameter will influence all objects inside this module +// It can, optionally, be overridden when instantiating the module +module Logo(size=50, $fn=100) { + // Temporary variables + hole = size/2; + cylinderHeight = size * 1.25; - cylinder(d=hole, h=cylinderHeight, center=true); - // The '#' operator highlights the object - #rotate([90, 0, 0]) cylinder(d=hole, h=cylinderHeight, center=true); - rotate([0, 90, 0]) cylinder(d=hole, h=cylinderHeight, center=true); + // One positive object (sphere) and three negative objects (cylinders) + difference() { + sphere(d=size); + + cylinder(d=hole, h=cylinderHeight, center=true); + // The '#' operator highlights the object + #rotate([90, 0, 0]) cylinder(d=hole, h=cylinderHeight, center=true); + rotate([0, 90, 0]) cylinder(d=hole, h=cylinderHeight, center=true); + } } echo(version=version()); diff --git a/examples/Basics/logo_and_text.scad b/examples/Basics/logo_and_text.scad index bddaa336..35803e12 100644 --- a/examples/Basics/logo_and_text.scad +++ b/examples/Basics/logo_and_text.scad @@ -1,51 +1,35 @@ -// logo_and_text.scad - Example for text() usage in OpenSCAD +// logo_and_text.scad - Example for use<> and text() -echo(version=version()); +use // Imports the Logo() module from logo.scad into this namespace +// Set the initial viewport parameters $vpr = [90, 0, 0]; $vpt = [250, 0, 80]; $vpd = 500; -r = 60; -hole = 30; +logosize = 120; + +translate([110, 0, 80]) { + translate([0, 0, 30]) rotate([25, 25, -40]) Logo(logosize); + translate([100, 0, 40]) green() t("Open", 42, ":style=Bold"); + translate([247, 0, 40]) black() t("SCAD", 42, ":style=Bold"); + translate([100, 0, 0]) black() t("The Programmers"); + translate([160, 0, -30]) black() t("Solid 3D CAD Modeller"); +} + +// Helper to create 3D text with correct font and orientation module t(t, s = 18, style = "") { rotate([90, 0, 0]) linear_extrude(height = 1) - text(t, size = s, font = str("Liberation Serif", style), $fn = 16); + text(t, size = s, font = str("Liberation Sans", style), $fn = 16); } -module cut() { - cylinder(r = hole, h = 2.5 * r, center = true, $fn = 60); -} - -module logo() { - difference() { - sphere(r = r, $fn = 120); - cut(); - rotate([0, 90, 0]) cut(); - #rotate([90, 0, 0]) cut(); - } -} - -module green() { - color([81/255, 142/255, 4/255]) children(); -} - -module black() { - color([0, 0, 0]) children(); -} - -translate([110, 0, 80]) { - translate([0, 0, 30]) rotate([25, 25, -40]) logo(); - translate([100, 0, 40]) green() t("Open", 42, ":style=Bold"); - translate([242, 0, 40]) black() t("SCAD", 42, ":style=Bold"); - translate([100, 0, -10]) black() t("The Programmers"); - translate([160, 0, -40]) black() t("Solid 3D CAD Modeller"); -} - - +// Color helpers +module green() color([81/255, 142/255, 4/255]) children(); +module black() color([0, 0, 0]) children(); +echo(version=version()); // Written in 2014 by Torsten Paul // // To the extent possible under law, the author(s) have dedicated all