Removing some examples

This commit is contained in:
Casey Reas
2011-09-06 03:51:23 +00:00
parent 5e0e9eaedc
commit 68c460be7d
30 changed files with 76 additions and 1215 deletions
+3 -3
View File
@@ -8,8 +8,8 @@
int rectX, rectY; // Position of square button
int circleX, circleY; // Position of circle button
int rectSize = 50; // Diameter of rect
int circleSize = 53; // Diameter of circle
int rectSize = 90; // Diameter of rect
int circleSize = 93; // Diameter of circle
color rectColor, circleColor, baseColor;
color rectHighlight, circleHighlight;
color currentColor;
@@ -18,7 +18,7 @@ boolean circleOver = false;
void setup()
{
size(200, 200);
size(640, 360);
smooth();
rectColor = color(0);
rectHighlight = color(51);
+1 -1
View File
@@ -15,7 +15,7 @@ boolean locked = false;
void setup()
{
size(200, 200);
size(640, 360);
smooth();
color baseColor = color(102);
+14 -25
View File
@@ -7,9 +7,8 @@
Handle[] handles;
int num;
void setup()
{
size(200, 200);
void setup() {
size(640, 360);
num = height/15;
handles = new Handle[num];
int hsize = 10;
@@ -18,8 +17,7 @@ void setup()
}
}
void draw()
{
void draw() {
background(153);
for(int i=0; i<num; i++) {
@@ -31,15 +29,14 @@ void draw()
rect(0, 0, width/2, height);
}
void mouseReleased()
{
void mouseReleased() {
for(int i=0; i<num; i++) {
handles[i].release();
}
}
class Handle
{
class Handle {
int x, y;
int boxx, boxy;
int length;
@@ -50,8 +47,7 @@ class Handle
boolean otherslocked = false;
Handle[] others;
Handle(int ix, int iy, int il, int is, Handle[] o)
{
Handle(int ix, int iy, int il, int is, Handle[] o) {
x = ix;
y = iy;
length = il;
@@ -61,8 +57,7 @@ class Handle
others = o;
}
void update()
{
void update() {
boxx = x+length;
boxy = y - size/2;
@@ -85,8 +80,7 @@ class Handle
}
}
void over()
{
void over() {
if(overRect(boxx, boxy, size, size)) {
over = true;
} else {
@@ -94,8 +88,7 @@ class Handle
}
}
void press()
{
void press() {
if(over && mousePressed || locked) {
press = true;
locked = true;
@@ -104,13 +97,11 @@ class Handle
}
}
void release()
{
void release() {
locked = false;
}
void display()
{
void display() {
line(x, y, x+length, y);
fill(255);
stroke(0);
@@ -123,8 +114,7 @@ class Handle
}
}
boolean overRect(int x, int y, int width, int height)
{
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
@@ -133,7 +123,6 @@ boolean overRect(int x, int y, int width, int height)
}
}
int lock(int val, int minv, int maxv)
{
int lock(int val, int minv, int maxv) {
return min(max(val, minv), maxv);
}
@@ -1,108 +0,0 @@
/**
* Image button.
*
* Loading images and using them to create a button.
*/
ImageButtons button;
void setup()
{
size(200, 200);
background(102, 102, 102);
// Define and create image button
PImage b = loadImage("base.gif");
PImage r = loadImage("roll.gif");
PImage d = loadImage("down.gif");
int x = width/2 - b.width/2;
int y = height/2 - b.height/2;
int w = b.width;
int h = b.height;
button = new ImageButtons(x, y, w, h, b, r, d);
}
void draw()
{
button.update();
button.display();
}
class Button
{
int x, y;
int w, h;
color basecolor, highlightcolor;
color currentcolor;
boolean over = false;
boolean pressed = false;
void pressed() {
if(over && mousePressed) {
pressed = true;
} else {
pressed = false;
}
}
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
} else {
return false;
}
}
}
class ImageButtons extends Button
{
PImage base;
PImage roll;
PImage down;
PImage currentimage;
ImageButtons(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown)
{
x = ix;
y = iy;
w = iw;
h = ih;
base = ibase;
roll = iroll;
down = idown;
currentimage = base;
}
void update()
{
over();
pressed();
if(pressed) {
currentimage = down;
} else if (over){
currentimage = roll;
} else {
currentimage = base;
}
}
void over()
{
if( overRect(x, y, w, h) ) {
over = true;
} else {
over = false;
}
}
void display()
{
image(currentimage, x, y);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 774 B

+8 -13
View File
@@ -8,8 +8,8 @@
int rectX, rectY; // Position of square button
int circleX, circleY; // Position of circle button
int rectSize = 50; // Diameter of rect
int circleSize = 53; // Diameter of circle
int rectSize = 90; // Diameter of rect
int circleSize = 93; // Diameter of circle
color rectColor;
color circleColor;
@@ -18,9 +18,8 @@ color baseColor;
boolean rectOver = false;
boolean circleOver = false;
void setup()
{
size(200, 200);
void setup() {
size(640, 360);
smooth();
rectColor = color(0);
circleColor = color(255);
@@ -32,8 +31,7 @@ void setup()
ellipseMode(CENTER);
}
void draw()
{
void draw() {
update(mouseX, mouseY);
noStroke();
@@ -53,8 +51,7 @@ void draw()
ellipse(circleX, circleY, circleSize, circleSize);
}
void update(int x, int y)
{
void update(int x, int y) {
if( overCircle(circleX, circleY, circleSize) ) {
circleOver = true;
rectOver = false;
@@ -66,8 +63,7 @@ void update(int x, int y)
}
}
boolean overRect(int x, int y, int width, int height)
{
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
@@ -76,8 +72,7 @@ boolean overRect(int x, int y, int width, int height)
}
}
boolean overCircle(int x, int y, int diameter)
{
boolean overCircle(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) {
@@ -10,20 +10,18 @@ PImage top, bottom; // Two image to load
int topWidth, bottomWidth; // The width of the top and bottom images
void setup()
{
size(200, 200);
void setup() {
size(640, 360);
noStroke();
hs1 = new HScrollbar(0, 20, width, 10, 3*5+1);
hs2 = new HScrollbar(0, height-20, width, 10, 3*5+1);
hs1 = new HScrollbar(0, 20, width, 20, 3*5+1);
hs2 = new HScrollbar(0, height-20, width, 20, 3*5+1);
top = loadImage("seedTop.jpg");
topWidth = top.width;
bottom = loadImage("seedBottom.jpg");
bottomWidth = bottom.width;
}
void draw()
{
void draw() {
background(255);
// Get the position of the top scrollbar
@@ -45,8 +43,7 @@ void draw()
}
class HScrollbar
{
class HScrollbar {
int swidth, sheight; // width and height of bar
int xpos, ypos; // x and y position of bar
float spos, newspos; // x position of slider