This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// title : OpenJSCAD Example | |
// author : Natalie Freed | |
function getParameterDefinitions() { | |
var parameters = [{ name: 'numCurves', type: 'int', initial: 2, caption: "num curves:" }]; | |
parameters = parameters.concat(makeSliders(1)); | |
return parameters; | |
} | |
function main(params) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// title : OpenJSCAD Bezier, 2D/3D Export Example | |
// author : Natalie Freed | |
// sources : 2D/3D export technique from Lamp Shade Example | |
function getParameterDefinitions() { | |
return [{ name: 'height', type: 'float', initial: 6, caption: "height:" }, | |
{ | |
name: 'type', | |
type: 'choice', | |
values: ["2D", "3D"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// title : OpenJSCAD Example | |
// author : Natalie Freed | |
function getParameterDefinitions() { | |
return [{ name: 'heightOfBox1', type: 'float', initial: 6, caption: "Height of box 1:" }]; | |
} | |
function main(params) { | |
var box1 = cube({size: [1,2,params.heightOfBox1]}); | |
var box2 = cube({size: [4,3,2]}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// title : OpenJSCAD Pumpkin | |
// author : Natalie Freed | |
function getParameterDefinitions() { | |
return [ | |
{ name: 'numSegments', type: 'int', initial: 10, caption: "Number of segments:" }, | |
{ name: 'proportions', type: 'choice', caption: 'Proportions:', values: ["tall", "wide", "medium"], captions: ["tall", "wide", "medium"], initial: "medium" } | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Radial Shape Wrapper Function | |
Natalie Freed September 2016 | |
*/ | |
function setup() { | |
createCanvas(600, 600); | |
//draw a shape | |
arrow(width/2+20, height/2, 20, color(0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rainbow; //global variable | |
function setup() { | |
createCanvas(600, 600); | |
//make the list (array) of rainbow colors | |
rainbow = [color('#c0392b'), color('#e67e22'), color('#f1c40f'), color('#2ecc71'), color('#3498db'), color('#8e44ad')]; | |
//shift to the center and down a bit | |
translate(width / 2, height / 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
createCanvas(600, 600); | |
var listOfColors = [color('#aabf12'), color('#33ab12'), color('#165512'), color('#fe3fa2'), color('#a345cd')]; | |
var stripeWidth = 20; | |
strokeWeight(stripeWidth); | |
for(var i=0;i<=width/stripeWidth;i++) { | |
stroke(listOfColors[int(random(0, listOfColors.length))]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example of choosing a random function | |
Notice this program re-randomizes the row of shapes every time it's run! | |
*/ | |
function setup() { | |
createCanvas(800, 400); | |
background(50); | |
//draw some shapes to test. These aren't randomized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
createCanvas(600, 600); | |
noFill(); | |
strokeWeight(3); | |
//example: draw something, unscaled | |
yourFunctionThatDrawsAThing(100, 200); | |
//example: make a half scale version | |
var scaledByHalf = autoScale(yourFunctionThatDrawsAThing, 0.5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Scale your shapes up without them moving all over the place! | |
var scalingFactor = 1; | |
var x = 100; | |
var y = 200; | |
var w = 40; | |
var h = 30; | |
function setup() | |
{ |