Removing a few Basics examples

This commit is contained in:
Casey Reas
2011-09-06 00:52:15 +00:00
parent 136b97bea5
commit d9f585f3a9
6 changed files with 7 additions and 236 deletions
@@ -1,8 +1,8 @@
/**
* Points and Lines.
*
* Constructing a simple dimensional form with lines and rectangles.
* Changing the value of the variable 'd' scales the image.
* Points and lines can be used to draw basic geometry.
* Change the value of the variable 'd' to scale the form.
* The four variables set the positions based on the value of 'd'.
*/
@@ -1,82 +0,0 @@
/**
* Simple Curves.
*
* Simple curves are drawn with simple equations.
* By using numbers with values between 0 and 1 in
* the equations, a series of elegant curves
* are created. The numbers are then scaled to fill the screen.
*/
void setup() {
size(640, 360);
colorMode(RGB, 100);
smooth();
background(0);
noFill();
noLoop(); // Run once and stop
}
void draw() {
stroke(40);
beginShape();
for(int i = 0; i < width; i++) {
vertex(i, singraph((float)i/width)*height);
}
endShape();
stroke(55);
beginShape();
for(int i = 0; i < width; i++) {
vertex(i, quad((float)i/width)*height);
}
endShape();
stroke(70);
beginShape();
for(int i = 0; i < width; i++) {
vertex(i, quadHump((float)i/width)*height);
}
endShape();
stroke(85);
beginShape();
for(int i = 0; i < width; i++) {
vertex(i, hump((float)i/width)*height);
}
endShape();
stroke(100);
beginShape();
for(int i = 0; i < width; i++) {
vertex(i, squared((float)i/width)*height);
}
endShape();
}
float singraph(float sa) {
sa = (sa - 0.5) * 1.0; //scale from -1 to 1
sa = sin(sa*PI)/2 + 0.5;
return sa;
}
float quad(float sa) {
return sa*sa*sa*sa;
}
float quadHump(float sa) {
sa = (sa - 0.5); //scale from -2 to 2
sa = sa*sa*sa*sa * 16;
return sa;
}
float hump(float sa) {
sa = (sa - 0.5) * 2; //scale from -2 to 2
sa = sa*sa;
if(sa > 1) { sa = 1; }
return 1-sa;
}
float squared(float sa) {
sa = sa*sa;
return sa;
}
@@ -1,51 +0,0 @@
/**
* Vertices.
*
* The beginShape() function begins recording vertices
* for a shape and endShape() stops recording.
* A vertex is a location in space specified by X, Y,
* and sometimes Z coordinates. After calling the beginShape() function,
* a series of vertex() functions must follow.
* To stop drawing the shape, call the endShape() functions.
*/
size(640, 360);
background(0);
noFill();
translate(140, 20);
scale(1.5);
strokeWeight(.5);
stroke(102);
beginShape();
curveVertex(168, 182);
curveVertex(168, 182);
curveVertex(136, 38);
curveVertex(42, 34);
curveVertex(64, 200);
curveVertex(64, 200);
endShape();
stroke(51);
beginShape(LINES);
vertex(60, 40);
vertex(160, 10);
vertex(170, 150);
vertex(60, 150);
endShape();
stroke(126);
beginShape();
vertex(60, 40);
bezierVertex(160, 10, 170, 150, 60, 150);
endShape();
stroke(255);
beginShape(POINTS);
vertex(60, 40);
vertex(160, 10);
vertex(170, 150);
vertex(60, 150);
endShape();
@@ -1,91 +0,0 @@
/**
* Request Image
* by Ira Greenberg.
* From Processing for Flash Developers, Friends of ED, 2009.
*
* Shows how to use the requestImage() function with preloader animation.
* The requestImage() function loads images on a separate thread so that
* the sketch does not freeze while they load. It's very useful when you are
* loading large images, as this example demonstrates.
*
* To work, this example requires 10 images named dublin0.jpg ... dublin9.jpg
* in the sketch data directory. To save space, these images are not included
* with the example.
*/
int imgCount = 10;
PImage[] imgs = new PImage[imgCount];
float imgW;
// Keeps track of loaded images (true or false)
boolean[] loadStates = new boolean[imgCount];
// For loading animation
float loaderX, loaderY, theta;
void setup() {
size(800, 60);
smooth();
imgW = width/imgCount;
// Load images asynchronously
for (int i = 0; i < imgCount; i++){
imgs[i] = requestImage("dublin"+i+".jpg");
}
}
void draw(){
background(0);
// Start loading animation
runLoaderAni();
for (int i = 0; i < imgs.length; i++){
// Check if individual images are fully loaded
if ((imgs[i].width != 0) && (imgs[i].width != -1)){
// As images are loaded set true in boolean array
loadStates[i] = true;
}
}
// When all images are loaded draw them to the screen
if (checkLoadStates()){
drawImages();
}
}
void drawImages(){
for (int i = 0; i < imgs.length; i++){
image(imgs[i], width/10*i, 0, imgW, height);
}
}
// Loading animation
void runLoaderAni(){
// Only run when images are loading
if (!checkLoadStates()){
ellipse(loaderX, loaderY, 10, 10);
loaderX += 2;
loaderY = height/2 + sin(theta) * (height/2.5);
theta += PI/22;
// Reposition ellipse if it goes off the screen
if (loaderX > width + 5){
loaderX = -5;
}
}
}
// Return true when all images are loaded - no false values left in array
boolean checkLoadStates(){
for (int i = 0; i < imgs.length; i++){
if (loadStates[i] == false){
return false;
}
}
return true;
}
@@ -6,21 +6,18 @@
* It continues to do this until the variable "level" is equal to 1.
*/
void setup()
{
void setup() {
size(640, 360);
noStroke();
smooth();
noLoop();
}
void draw()
{
void draw() {
drawCircle(width/2, 280, 6);
}
void drawCircle(int x, int radius, int level)
{
void drawCircle(int x, int radius, int level) {
float tt = 126 * level/4.0;
fill(tt);
ellipse(x, height/2, radius*2, radius*2);
@@ -6,16 +6,14 @@
* It continues to do this until the variable "level" is equal to 1.
*/
void setup()
{
void setup() {
size(640, 360);
noStroke();
smooth();
drawCircle(width*0.5, height*0.5, 160, 8);
}
void drawCircle(float x, float y, int radius, int level)
{
void drawCircle(float x, float y, int radius, int level) {
float tt = 126 * level/6.0;
fill(tt, 153);
ellipse(x, y, radius*2, radius*2);