mirror of https://github.com/vitalif/openscad
Made logo.scad use a module, and let logo_and_text.scad use<> that module
parent
b578ff5c75
commit
4f49b35ba4
|
@ -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;
|
Logo(50);
|
||||||
hole = 25;
|
|
||||||
cylinderHeight = size * 1.25;
|
|
||||||
$fn = 32; // Increasing this makes the logo smoother
|
|
||||||
|
|
||||||
// One positive object (sphere) and three negative objects (cylinders)
|
// The $fn parameter will influence all objects inside this module
|
||||||
difference() {
|
// It can, optionally, be overridden when instantiating the module
|
||||||
sphere(d=size);
|
module Logo(size=50, $fn=100) {
|
||||||
|
// Temporary variables
|
||||||
|
hole = size/2;
|
||||||
|
cylinderHeight = size * 1.25;
|
||||||
|
|
||||||
cylinder(d=hole, h=cylinderHeight, center=true);
|
// One positive object (sphere) and three negative objects (cylinders)
|
||||||
// The '#' operator highlights the object
|
difference() {
|
||||||
#rotate([90, 0, 0]) cylinder(d=hole, h=cylinderHeight, center=true);
|
sphere(d=size);
|
||||||
rotate([0, 90, 0]) cylinder(d=hole, h=cylinderHeight, center=true);
|
|
||||||
|
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());
|
echo(version=version());
|
||||||
|
|
|
@ -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 <logo.scad> // Imports the Logo() module from logo.scad into this namespace
|
||||||
|
|
||||||
|
// Set the initial viewport parameters
|
||||||
$vpr = [90, 0, 0];
|
$vpr = [90, 0, 0];
|
||||||
$vpt = [250, 0, 80];
|
$vpt = [250, 0, 80];
|
||||||
$vpd = 500;
|
$vpd = 500;
|
||||||
|
|
||||||
r = 60;
|
logosize = 120;
|
||||||
hole = 30;
|
|
||||||
|
|
||||||
|
|
||||||
|
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 = "") {
|
module t(t, s = 18, style = "") {
|
||||||
rotate([90, 0, 0])
|
rotate([90, 0, 0])
|
||||||
linear_extrude(height = 1)
|
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() {
|
// Color helpers
|
||||||
cylinder(r = hole, h = 2.5 * r, center = true, $fn = 60);
|
module green() color([81/255, 142/255, 4/255]) children();
|
||||||
}
|
module black() color([0, 0, 0]) children();
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo(version=version());
|
||||||
// Written in 2014 by Torsten Paul <Torsten.Paul@gmx.de>
|
// Written in 2014 by Torsten Paul <Torsten.Paul@gmx.de>
|
||||||
//
|
//
|
||||||
// To the extent possible under law, the author(s) have dedicated all
|
// To the extent possible under law, the author(s) have dedicated all
|
||||||
|
|
Loading…
Reference in New Issue