removing applet folders from svn
@@ -1,39 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Bezier extends PApplet {
|
||||
public void setup() {/**
|
||||
* Bezier.
|
||||
*
|
||||
* The first two parameters for the bezier() function specify the
|
||||
* first point in the curve and the last two parameters specify
|
||||
* the last point. The middle parameters set the control points
|
||||
* that define the shape of the curve.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(255);
|
||||
noFill();
|
||||
smooth();
|
||||
|
||||
for(int i = 0; i < 100; i += 20) {
|
||||
bezier(90-(i/2.0f), 20+i, 210, 10, 220, 150, 120-(i/8.0f), 150+(i/4.0f));
|
||||
}
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Bezier" });
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Bezier.
|
||||
*
|
||||
* The first two parameters for the bezier() function specify the
|
||||
* first point in the curve and the last two parameters specify
|
||||
* the last point. The middle parameters set the control points
|
||||
* that define the shape of the curve.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(255);
|
||||
noFill();
|
||||
smooth();
|
||||
|
||||
for(int i = 0; i < 100; i += 20) {
|
||||
bezier(90-(i/2.0), 20+i, 210, 10, 220, 150, 120-(i/8.0), 150+(i/4.0));
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,123 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class BezierEllipse extends PApplet {
|
||||
|
||||
/**
|
||||
* Bezier Ellipse
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Generates an ellipse using bezier() and
|
||||
* trig functions. Approximately every 1/2
|
||||
* second a new ellipse is plotted using
|
||||
* random values for control/anchor points.
|
||||
*/
|
||||
|
||||
// arrays to hold ellipse coordinate data
|
||||
float[] px, py, cx, cy, cx2, cy2;
|
||||
|
||||
// global variable-points in ellipse
|
||||
int pts = 4;
|
||||
|
||||
int controlPtCol = 0xff222222;
|
||||
int anchorPtCol = 0xffBBBBBB;
|
||||
|
||||
public void setup(){
|
||||
size(200, 200);
|
||||
smooth();
|
||||
setEllipse(pts, 65, 65);
|
||||
frameRate(1);
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
background(145);
|
||||
drawEllipse();
|
||||
setEllipse(PApplet.parseInt(random(3, 12)), random(-100, 150), random(-100, 150));
|
||||
}
|
||||
|
||||
// draw ellipse with anchor/control points
|
||||
public void drawEllipse(){
|
||||
strokeWeight(1.125f);
|
||||
stroke(255);
|
||||
noFill();
|
||||
// create ellipse
|
||||
for (int i=0; i<pts; i++){
|
||||
if (i==pts-1) {
|
||||
bezier(px[i], py[i], cx[i], cy[i], cx2[i], cy2[i], px[0], py[0]);
|
||||
}
|
||||
else{
|
||||
bezier(px[i], py[i], cx[i], cy[i], cx2[i], cy2[i], px[i+1], py[i+1]);
|
||||
}
|
||||
}
|
||||
strokeWeight(.75f);
|
||||
stroke(0);
|
||||
rectMode(CENTER);
|
||||
|
||||
// control handles and tangent lines
|
||||
for ( int i=0; i< pts; i++){
|
||||
if (i==pts-1){ // last loop iteration-close path
|
||||
line(px[0], py[0], cx2[i], cy2[i]);
|
||||
}
|
||||
if (i>0){
|
||||
line(px[i], py[i], cx2[i-1], cy2[i-1]);
|
||||
}
|
||||
line(px[i], py[i], cx[i], cy[i]);
|
||||
}
|
||||
|
||||
for ( int i=0; i< pts; i++){
|
||||
fill(controlPtCol);
|
||||
noStroke();
|
||||
//control handles
|
||||
ellipse(cx[i], cy[i], 4, 4);
|
||||
ellipse(cx2[i], cy2[i], 4, 4);
|
||||
|
||||
fill(anchorPtCol);
|
||||
stroke(0);
|
||||
//anchor points
|
||||
rect(px[i], py[i], 5, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// fill up arrays with ellipse coordinate data
|
||||
public void setEllipse(int points, float radius, float controlRadius){
|
||||
pts = points;
|
||||
px = new float[points];
|
||||
py = new float[points];
|
||||
cx = new float[points];
|
||||
cy = new float[points];
|
||||
cx2 = new float[points];
|
||||
cy2 = new float[points];
|
||||
float angle = 360.0f/points;
|
||||
float controlAngle1 = angle/3.0f;
|
||||
float controlAngle2 = controlAngle1*2.0f;
|
||||
for ( int i=0; i<points; i++){
|
||||
px[i] = width/2+cos(radians(angle))*radius;
|
||||
py[i] = height/2+sin(radians(angle))*radius;
|
||||
cx[i] = width/2+cos(radians(angle+controlAngle1))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cy[i] = height/2+sin(radians(angle+controlAngle1))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cx2[i] = width/2+cos(radians(angle+controlAngle2))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cy2[i] = height/2+sin(radians(angle+controlAngle2))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
|
||||
//increment angle so trig functions keep chugging along
|
||||
angle+=360.0f/points;
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "BezierEllipse" });
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* Bezier Ellipse
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Generates an ellipse using bezier() and
|
||||
* trig functions. Approximately every 1/2
|
||||
* second a new ellipse is plotted using
|
||||
* random values for control/anchor points.
|
||||
*/
|
||||
|
||||
// arrays to hold ellipse coordinate data
|
||||
float[] px, py, cx, cy, cx2, cy2;
|
||||
|
||||
// global variable-points in ellipse
|
||||
int pts = 4;
|
||||
|
||||
color controlPtCol = #222222;
|
||||
color anchorPtCol = #BBBBBB;
|
||||
|
||||
void setup(){
|
||||
size(200, 200);
|
||||
smooth();
|
||||
setEllipse(pts, 65, 65);
|
||||
frameRate(1);
|
||||
}
|
||||
|
||||
void draw(){
|
||||
background(145);
|
||||
drawEllipse();
|
||||
setEllipse(int(random(3, 12)), random(-100, 150), random(-100, 150));
|
||||
}
|
||||
|
||||
// draw ellipse with anchor/control points
|
||||
void drawEllipse(){
|
||||
strokeWeight(1.125);
|
||||
stroke(255);
|
||||
noFill();
|
||||
// create ellipse
|
||||
for (int i=0; i<pts; i++){
|
||||
if (i==pts-1) {
|
||||
bezier(px[i], py[i], cx[i], cy[i], cx2[i], cy2[i], px[0], py[0]);
|
||||
}
|
||||
else{
|
||||
bezier(px[i], py[i], cx[i], cy[i], cx2[i], cy2[i], px[i+1], py[i+1]);
|
||||
}
|
||||
}
|
||||
strokeWeight(.75);
|
||||
stroke(0);
|
||||
rectMode(CENTER);
|
||||
|
||||
// control handles and tangent lines
|
||||
for ( int i=0; i< pts; i++){
|
||||
if (i==pts-1){ // last loop iteration-close path
|
||||
line(px[0], py[0], cx2[i], cy2[i]);
|
||||
}
|
||||
if (i>0){
|
||||
line(px[i], py[i], cx2[i-1], cy2[i-1]);
|
||||
}
|
||||
line(px[i], py[i], cx[i], cy[i]);
|
||||
}
|
||||
|
||||
for ( int i=0; i< pts; i++){
|
||||
fill(controlPtCol);
|
||||
noStroke();
|
||||
//control handles
|
||||
ellipse(cx[i], cy[i], 4, 4);
|
||||
ellipse(cx2[i], cy2[i], 4, 4);
|
||||
|
||||
fill(anchorPtCol);
|
||||
stroke(0);
|
||||
//anchor points
|
||||
rect(px[i], py[i], 5, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// fill up arrays with ellipse coordinate data
|
||||
void setEllipse(int points, float radius, float controlRadius){
|
||||
pts = points;
|
||||
px = new float[points];
|
||||
py = new float[points];
|
||||
cx = new float[points];
|
||||
cy = new float[points];
|
||||
cx2 = new float[points];
|
||||
cy2 = new float[points];
|
||||
float angle = 360.0/points;
|
||||
float controlAngle1 = angle/3.0;
|
||||
float controlAngle2 = controlAngle1*2.0;
|
||||
for ( int i=0; i<points; i++){
|
||||
px[i] = width/2+cos(radians(angle))*radius;
|
||||
py[i] = height/2+sin(radians(angle))*radius;
|
||||
cx[i] = width/2+cos(radians(angle+controlAngle1))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cy[i] = height/2+sin(radians(angle+controlAngle1))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cx2[i] = width/2+cos(radians(angle+controlAngle2))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
cy2[i] = height/2+sin(radians(angle+controlAngle2))*
|
||||
controlRadius/cos(radians(controlAngle1));
|
||||
|
||||
//increment angle so trig functions keep chugging along
|
||||
angle+=360.0/points;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,44 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PieChart extends PApplet {
|
||||
public void setup() {/**
|
||||
* Pie Chart
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Uses the arc() function to generate a pie chart from the data
|
||||
* stored in an array.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(100);
|
||||
smooth();
|
||||
noStroke();
|
||||
|
||||
int diameter = 150;
|
||||
int[] angs = {30, 10, 45, 35, 60, 38, 75, 67};
|
||||
float lastAng = 0;
|
||||
|
||||
for (int i = 0; i < angs.length; i++){
|
||||
fill(angs[i] * 3.0f);
|
||||
arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
|
||||
lastAng += radians(angs[i]);
|
||||
}
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "PieChart" });
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Pie Chart
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Uses the arc() function to generate a pie chart from the data
|
||||
* stored in an array.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(100);
|
||||
smooth();
|
||||
noStroke();
|
||||
|
||||
int diameter = 150;
|
||||
int[] angs = {30, 10, 45, 35, 60, 38, 75, 67};
|
||||
float lastAng = 0;
|
||||
|
||||
for (int i = 0; i < angs.length; i++){
|
||||
fill(angs[i] * 3.0);
|
||||
arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
|
||||
lastAng += radians(angs[i]);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,53 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PointsLines extends PApplet {
|
||||
public void setup() {/**
|
||||
* Points and Lines.
|
||||
*
|
||||
* Constructing a simple dimensional form with lines and rectangles.
|
||||
* Changing the value of the variable 'd' scales the image.
|
||||
* The four variables set the positions based on the value of 'd'.
|
||||
*/
|
||||
|
||||
int d = 40;
|
||||
int p1 = d;
|
||||
int p2 = p1+d;
|
||||
int p3 = p2+d;
|
||||
int p4 = p3+d;
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
|
||||
// Draw gray box
|
||||
stroke(153);
|
||||
line(p3, p3, p2, p3);
|
||||
line(p2, p3, p2, p2);
|
||||
line(p2, p2, p3, p2);
|
||||
line(p3, p2, p3, p3);
|
||||
|
||||
// Draw white points
|
||||
stroke(255);
|
||||
point(p1, p1);
|
||||
point(p1, p3);
|
||||
point(p2, p4);
|
||||
point(p3, p1);
|
||||
point(p4, p2);
|
||||
point(p4, p4);
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "PointsLines" });
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Points and Lines.
|
||||
*
|
||||
* Constructing a simple dimensional form with lines and rectangles.
|
||||
* Changing the value of the variable 'd' scales the image.
|
||||
* The four variables set the positions based on the value of 'd'.
|
||||
*/
|
||||
|
||||
int d = 40;
|
||||
int p1 = d;
|
||||
int p2 = p1+d;
|
||||
int p3 = p2+d;
|
||||
int p4 = p3+d;
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
|
||||
// Draw gray box
|
||||
stroke(153);
|
||||
line(p3, p3, p2, p3);
|
||||
line(p2, p3, p2, p2);
|
||||
line(p2, p2, p3, p2);
|
||||
line(p3, p2, p3, p3);
|
||||
|
||||
// Draw white points
|
||||
stroke(255);
|
||||
point(p1, p1);
|
||||
point(p1, p3);
|
||||
point(p2, p4);
|
||||
point(p3, p1);
|
||||
point(p4, p2);
|
||||
point(p4, p4);
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,42 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class ShapePrimitives extends PApplet {
|
||||
public void setup() {/**
|
||||
* Shape Primitives.
|
||||
*
|
||||
* The basic shape primitive functions are triangle(),
|
||||
* rect(), quad(), and ellipse(). Squares are made
|
||||
* with rect() and circles are made with
|
||||
* ellipse(). Each of these functions requires a number
|
||||
* of parameters which determines their position and size.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
smooth();
|
||||
background(0);
|
||||
noStroke();
|
||||
fill(226);
|
||||
triangle(10, 10, 10, 200, 45, 200);
|
||||
rect(45, 45, 35, 35);
|
||||
quad(105, 10, 120, 10, 120, 200, 80, 200);
|
||||
ellipse(140, 80, 40, 40);
|
||||
triangle(160, 10, 195, 200, 160, 200);
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "ShapePrimitives" });
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Shape Primitives.
|
||||
*
|
||||
* The basic shape primitive functions are triangle(),
|
||||
* rect(), quad(), and ellipse(). Squares are made
|
||||
* with rect() and circles are made with
|
||||
* ellipse(). Each of these functions requires a number
|
||||
* of parameters which determines their position and size.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
smooth();
|
||||
background(0);
|
||||
noStroke();
|
||||
fill(226);
|
||||
triangle(10, 10, 10, 200, 45, 200);
|
||||
rect(45, 45, 35, 35);
|
||||
quad(105, 10, 120, 10, 120, 200, 80, 200);
|
||||
ellipse(140, 80, 40, 40);
|
||||
triangle(160, 10, 195, 200, 160, 200);
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,101 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class SimpleCurves extends PApplet {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
colorMode(RGB, 100);
|
||||
background(0);
|
||||
noFill();
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public 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();
|
||||
}
|
||||
|
||||
public float singraph(float sa) {
|
||||
sa = (sa - 0.5f) * 1.0f; //scale from -1 to 1
|
||||
sa = sin(sa*PI)/2 + 0.5f;
|
||||
return sa;
|
||||
}
|
||||
|
||||
public float quad(float sa) {
|
||||
return sa*sa*sa*sa;
|
||||
}
|
||||
|
||||
public float quadHump(float sa) {
|
||||
sa = (sa - 0.5f); //scale from -2 to 2
|
||||
sa = sa*sa*sa*sa * 16;
|
||||
return sa;
|
||||
}
|
||||
|
||||
public float hump(float sa) {
|
||||
sa = (sa - 0.5f) * 2; //scale from -2 to 2
|
||||
sa = sa*sa;
|
||||
if(sa > 1) { sa = 1; }
|
||||
return 1-sa;
|
||||
}
|
||||
|
||||
public float squared(float sa) {
|
||||
sa = sa*sa;
|
||||
return sa;
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "SimpleCurves" });
|
||||
}
|
||||
}
|
||||
@@ -1,81 +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(200, 200);
|
||||
colorMode(RGB, 100);
|
||||
background(0);
|
||||
noFill();
|
||||
noLoop();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,57 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class TriangleStrip extends PApplet {
|
||||
public void setup() {/**
|
||||
* TRIANGLE_STRIP Mode
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Generate a closed ring using vertex()
|
||||
* function and beginShape(TRIANGLE_STRIP)
|
||||
* mode. outerRad and innerRad variables
|
||||
* control ring's outer/inner radii respectively.
|
||||
* Trig functions generate ring.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(204);
|
||||
smooth();
|
||||
|
||||
int x = width/2;
|
||||
int y = height/2;
|
||||
int outerRad = 80;
|
||||
int innerRad = 50;
|
||||
float px = 0, py = 0, angle = 0;
|
||||
float pts = 36;
|
||||
float rot = 360.0f/pts;
|
||||
|
||||
beginShape(TRIANGLE_STRIP);
|
||||
for (int i = 0; i < pts; i++) {
|
||||
px = x + cos(radians(angle))*outerRad;
|
||||
py = y + sin(radians(angle))*outerRad;
|
||||
angle += rot;
|
||||
vertex(px, py);
|
||||
px = x + cos(radians(angle))*innerRad;
|
||||
py = y + sin(radians(angle))*innerRad;
|
||||
vertex(px, py);
|
||||
angle += rot;
|
||||
}
|
||||
endShape();
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "TriangleStrip" });
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* TRIANGLE_STRIP Mode
|
||||
* By Ira Greenberg
|
||||
*
|
||||
* Generate a closed ring using vertex()
|
||||
* function and beginShape(TRIANGLE_STRIP)
|
||||
* mode. outerRad and innerRad variables
|
||||
* control ring's outer/inner radii respectively.
|
||||
* Trig functions generate ring.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(204);
|
||||
smooth();
|
||||
|
||||
int x = width/2;
|
||||
int y = height/2;
|
||||
int outerRad = 80;
|
||||
int innerRad = 50;
|
||||
float px = 0, py = 0, angle = 0;
|
||||
float pts = 36;
|
||||
float rot = 360.0/pts;
|
||||
|
||||
beginShape(TRIANGLE_STRIP);
|
||||
for (int i = 0; i < pts; i++) {
|
||||
px = x + cos(radians(angle))*outerRad;
|
||||
py = y + sin(radians(angle))*outerRad;
|
||||
angle += rot;
|
||||
vertex(px, py);
|
||||
px = x + cos(radians(angle))*innerRad;
|
||||
py = y + sin(radians(angle))*innerRad;
|
||||
vertex(px, py);
|
||||
angle += rot;
|
||||
}
|
||||
endShape();
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,68 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Vertices extends PApplet {
|
||||
public void setup() {/**
|
||||
* 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(200, 200);
|
||||
background(0);
|
||||
noFill();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Vertices" });
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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(200, 200);
|
||||
background(0);
|
||||
noFill();
|
||||
|
||||
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();
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |