mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
removing applet folders from svn
This commit is contained in:
@@ -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 CharactersStrings extends PApplet {
|
||||
|
||||
/**
|
||||
* Characters Strings.
|
||||
*
|
||||
* Click on the image to give it focus and then type letters to
|
||||
* shift the location of the image.
|
||||
* Characters are typographic symbols such as A, d, and %.
|
||||
* The character datatype, abbreviated as char, stores letters and
|
||||
* symbols in the Unicode format, a coding system developed to support
|
||||
* a variety of world languages. Characters are distinguished from other
|
||||
* symbols by putting them between single quotes ('P').
|
||||
* A string is a sequence of characters. A string is noted by surrounding
|
||||
* a group of letters with double quotes ("Processing").
|
||||
* Chars and strings are most often used with the keyboard methods,
|
||||
* to display text to the screen, and to load images or files.
|
||||
*/
|
||||
|
||||
PImage frog;
|
||||
PFont fontA;
|
||||
int lettersize = 90;
|
||||
int xoffset;
|
||||
char letter;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
fontA = loadFont("Eureka90.vlw");
|
||||
textFont(fontA);
|
||||
textSize(lettersize);
|
||||
|
||||
// The String datatype must be capitalized because it is a complex datatype.
|
||||
// A String is actually a class with its own methods, some of which are
|
||||
// featured below.
|
||||
String name= "rathausFrog";
|
||||
String extension = ".jpg";
|
||||
int nameLength = name.length();
|
||||
println("The length of " + name + " is " + nameLength + ".");
|
||||
name = name.concat(extension);
|
||||
nameLength = name.length();
|
||||
println("The length of " + name + " is " + nameLength + ".");
|
||||
|
||||
// The parameter for the loadImage() method must be a string
|
||||
// This line could also be written "frog = loadImage("rathausFrog.jpg");
|
||||
frog = loadImage(name);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(51); // Set background to dark gray
|
||||
|
||||
image(frog, xoffset, 0);
|
||||
|
||||
// Draw an X
|
||||
line(0, 0, width, height);
|
||||
line(0, height, width, 0);
|
||||
|
||||
// Get the width of the letter
|
||||
int letterWidth = PApplet.parseInt(fontA.width(letter) * lettersize);
|
||||
|
||||
// Draw the letter to the center of the screen
|
||||
text(letter, width/2-letterWidth/2, height/2);
|
||||
}
|
||||
|
||||
public void keyPressed()
|
||||
{
|
||||
// The variable "key" always contains the value of the most recent key pressed.
|
||||
// If the key is an upper or lowercase letter between 'A' and 'z'
|
||||
// the image is shifted to the corresponding value of that key
|
||||
if(key >= 'A' && key <= 'z') {
|
||||
letter = PApplet.parseChar(key);
|
||||
// Scale the values to numbers between 0 and 100
|
||||
float scale = 100.0f/57.0f;
|
||||
int temp = PApplet.parseInt((key - 'A') * scale);
|
||||
// Set the offset for the image
|
||||
xoffset = temp;
|
||||
println(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "CharactersStrings" });
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* Characters Strings.
|
||||
*
|
||||
* Click on the image to give it focus and then type letters to
|
||||
* shift the location of the image.
|
||||
* Characters are typographic symbols such as A, d, and %.
|
||||
* The character datatype, abbreviated as char, stores letters and
|
||||
* symbols in the Unicode format, a coding system developed to support
|
||||
* a variety of world languages. Characters are distinguished from other
|
||||
* symbols by putting them between single quotes ('P').
|
||||
* A string is a sequence of characters. A string is noted by surrounding
|
||||
* a group of letters with double quotes ("Processing").
|
||||
* Chars and strings are most often used with the keyboard methods,
|
||||
* to display text to the screen, and to load images or files.
|
||||
*/
|
||||
|
||||
PImage frog;
|
||||
PFont fontA;
|
||||
int lettersize = 90;
|
||||
int xoffset;
|
||||
char letter;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
fontA = loadFont("Eureka90.vlw");
|
||||
textFont(fontA);
|
||||
textSize(lettersize);
|
||||
|
||||
// The String datatype must be capitalized because it is a complex datatype.
|
||||
// A String is actually a class with its own methods, some of which are
|
||||
// featured below.
|
||||
String name= "rathausFrog";
|
||||
String extension = ".jpg";
|
||||
int nameLength = name.length();
|
||||
println("The length of " + name + " is " + nameLength + ".");
|
||||
name = name.concat(extension);
|
||||
nameLength = name.length();
|
||||
println("The length of " + name + " is " + nameLength + ".");
|
||||
|
||||
// The parameter for the loadImage() method must be a string
|
||||
// This line could also be written "frog = loadImage("rathausFrog.jpg");
|
||||
frog = loadImage(name);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(51); // Set background to dark gray
|
||||
|
||||
image(frog, xoffset, 0);
|
||||
|
||||
// Draw an X
|
||||
line(0, 0, width, height);
|
||||
line(0, height, width, 0);
|
||||
|
||||
// Get the width of the letter
|
||||
int letterWidth = int(fontA.width(letter) * lettersize);
|
||||
|
||||
// Draw the letter to the center of the screen
|
||||
text(letter, width/2-letterWidth/2, height/2);
|
||||
}
|
||||
|
||||
void keyPressed()
|
||||
{
|
||||
// The variable "key" always contains the value of the most recent key pressed.
|
||||
// If the key is an upper or lowercase letter between 'A' and 'z'
|
||||
// the image is shifted to the corresponding value of that key
|
||||
if(key >= 'A' && key <= 'z') {
|
||||
letter = char(key);
|
||||
// Scale the values to numbers between 0 and 100
|
||||
float scale = 100.0/57.0;
|
||||
int temp = int((key - 'A') * scale);
|
||||
// Set the offset for the image
|
||||
xoffset = temp;
|
||||
println(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,49 +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 DatatypeConversion extends PApplet {
|
||||
public void setup() {/**
|
||||
* Datatype Conversion.
|
||||
*
|
||||
* It is sometimes beneficial to convert a value from one type of
|
||||
* data to another. Each of the conversion functions converts its parameter
|
||||
* to an equivalent representation within its datatype.
|
||||
* The conversion functions include int(), float(), char(), byte(), and others.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(51);
|
||||
noStroke();
|
||||
|
||||
char c; // Chars are used for storing typographic symbols
|
||||
float f; // Floats are decimal numbers
|
||||
int i; // Ints are values between 2,147,483,647 and -2147483648
|
||||
byte b; // Bytes are values between -128 and 128
|
||||
|
||||
c = 'A';
|
||||
f = PApplet.parseFloat(c); // Sets f = 65.0
|
||||
i = PApplet.parseInt(f * 1.4f); // Sets i to 91
|
||||
b = PApplet.parseByte(c / 2); // Sets b to 32
|
||||
|
||||
rect(f, 0, 40, 66);
|
||||
fill(204);
|
||||
rect(i, 67, 40, 66);
|
||||
fill(255);
|
||||
rect(b, 134, 40, 66);
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "DatatypeConversion" });
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Datatype Conversion.
|
||||
*
|
||||
* It is sometimes beneficial to convert a value from one type of
|
||||
* data to another. Each of the conversion functions converts its parameter
|
||||
* to an equivalent representation within its datatype.
|
||||
* The conversion functions include int(), float(), char(), byte(), and others.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(51);
|
||||
noStroke();
|
||||
|
||||
char c; // Chars are used for storing typographic symbols
|
||||
float f; // Floats are decimal numbers
|
||||
int i; // Ints are values between 2,147,483,647 and -2147483648
|
||||
byte b; // Bytes are values between -128 and 128
|
||||
|
||||
c = 'A';
|
||||
f = float(c); // Sets f = 65.0
|
||||
i = int(f * 1.4); // Sets i to 91
|
||||
b = byte(c / 2); // Sets b to 32
|
||||
|
||||
rect(f, 0, 40, 66);
|
||||
fill(204);
|
||||
rect(i, 67, 40, 66);
|
||||
fill(255);
|
||||
rect(b, 134, 40, 66);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,56 +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 IntegersFloats extends PApplet {
|
||||
|
||||
/**
|
||||
* Integers Floats.
|
||||
*
|
||||
* Integers and floats are two different kinds of numerical data.
|
||||
* An integer (more commonly called an int) is a number without
|
||||
* a decimal point. A float is a floating-point number, which means
|
||||
* it is a number that has a decimal place. Floats are used when
|
||||
* more precision is needed.
|
||||
*/
|
||||
|
||||
int a = 0; // Create a variable "a" of the datatype "int"
|
||||
float b = 0.0f; // Create a variable "b" of the datatype "float"
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
stroke(255);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
a = a + 1;
|
||||
b = b + 0.2f;
|
||||
line(a, 0, a, height/2);
|
||||
line(b, height/2, b, height);
|
||||
|
||||
if(a > width) {
|
||||
a = 0;
|
||||
}
|
||||
if(b > width) {
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "IntegersFloats" });
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Integers Floats.
|
||||
*
|
||||
* Integers and floats are two different kinds of numerical data.
|
||||
* An integer (more commonly called an int) is a number without
|
||||
* a decimal point. A float is a floating-point number, which means
|
||||
* it is a number that has a decimal place. Floats are used when
|
||||
* more precision is needed.
|
||||
*/
|
||||
|
||||
int a = 0; // Create a variable "a" of the datatype "int"
|
||||
float b = 0.0; // Create a variable "b" of the datatype "float"
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
stroke(255);
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(51);
|
||||
|
||||
a = a + 1;
|
||||
b = b + 0.2;
|
||||
line(a, 0, a, height/2);
|
||||
line(b, height/2, b, height);
|
||||
|
||||
if(a > width) {
|
||||
a = 0;
|
||||
}
|
||||
if(b > width) {
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,55 +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 TrueFalse extends PApplet {
|
||||
public void setup() {/**
|
||||
* True/False.
|
||||
*
|
||||
* Boolean data is one bit of information. True or false.
|
||||
* It is common to use Booleans with control statements to
|
||||
* determine the flow of a program. In this example, when the
|
||||
* boolean value "x" is true, vertical black lines are drawn and when
|
||||
* the boolean value "x" is false, horizontal gray lines are drawn.
|
||||
*/
|
||||
|
||||
boolean x = false;
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(0);
|
||||
|
||||
for (int i = 1; i < width; i += 2)
|
||||
{
|
||||
if (i < width/2) {
|
||||
x = true;
|
||||
} else {
|
||||
x = false;
|
||||
}
|
||||
|
||||
if (x) {
|
||||
stroke(255);
|
||||
line(i, 1, i, height-1);
|
||||
}
|
||||
|
||||
if (!x) {
|
||||
stroke(126);
|
||||
line(width/2 , i, width-2, i);
|
||||
}
|
||||
}
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "TrueFalse" });
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* True/False.
|
||||
*
|
||||
* Boolean data is one bit of information. True or false.
|
||||
* It is common to use Booleans with control statements to
|
||||
* determine the flow of a program. In this example, when the
|
||||
* boolean value "x" is true, vertical black lines are drawn and when
|
||||
* the boolean value "x" is false, horizontal gray lines are drawn.
|
||||
*/
|
||||
|
||||
boolean x = false;
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(0);
|
||||
|
||||
for (int i = 1; i < width; i += 2)
|
||||
{
|
||||
if (i < width/2) {
|
||||
x = true;
|
||||
} else {
|
||||
x = false;
|
||||
}
|
||||
|
||||
if (x) {
|
||||
stroke(255);
|
||||
line(i, 1, i, height-1);
|
||||
}
|
||||
|
||||
if (!x) {
|
||||
stroke(126);
|
||||
line(width/2 , i, width-2, i);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,81 +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 VariableScope extends PApplet {
|
||||
|
||||
/**
|
||||
* Variable Scope.
|
||||
*
|
||||
* Variables may either have a global or local "scope".
|
||||
* For example, variables declared within either the
|
||||
* setup() or loop() functions may be only used in these
|
||||
* functions. Global variables, variables declared outside
|
||||
* of setup() and loop(), may be used anywhere within the program.
|
||||
* If a local variable is declared with the same name as a
|
||||
* global variable, the program will use the local variable to make
|
||||
* its calculations within the current scope. Variables may be localized
|
||||
* within classes, functions, and iterative statements.
|
||||
*/
|
||||
|
||||
int a = 20; // Create a global variable "a"
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
background(51);
|
||||
stroke(255);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
// Draw a line using the global variable "a"
|
||||
line(a, 0, a, height);
|
||||
|
||||
// Create a new variable "a" local to the for() statement
|
||||
for(int a=50; a<80; a += 2) {
|
||||
line(a, 0, a, height);
|
||||
}
|
||||
|
||||
// Create a new variable "a" local to the loop() method
|
||||
int a = 100;
|
||||
// Draw a line using the new local variable "a"
|
||||
line(a, 0, a, height);
|
||||
|
||||
// Make a call to the custom function drawAnotherLine()
|
||||
drawAnotherLine();
|
||||
|
||||
// Make a call to the custom function setYetAnotherLine()
|
||||
drawYetAnotherLine();
|
||||
}
|
||||
|
||||
public void drawAnotherLine()
|
||||
{
|
||||
// Create a new variable "a" local to this method
|
||||
int a = 185;
|
||||
// Draw a line using the local variable "a"
|
||||
line(a, 0, a, height);
|
||||
}
|
||||
|
||||
public void drawYetAnotherLine()
|
||||
{
|
||||
// Because no new local variable "a" is set,
|
||||
// this lines draws using the original global
|
||||
// variable "a" which is set to the value 20.
|
||||
line(a+2, 0, a+2, height);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "VariableScope" });
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Variable Scope.
|
||||
*
|
||||
* Variables may either have a global or local "scope".
|
||||
* For example, variables declared within either the
|
||||
* setup() or loop() functions may be only used in these
|
||||
* functions. Global variables, variables declared outside
|
||||
* of setup() and loop(), may be used anywhere within the program.
|
||||
* If a local variable is declared with the same name as a
|
||||
* global variable, the program will use the local variable to make
|
||||
* its calculations within the current scope. Variables may be localized
|
||||
* within classes, functions, and iterative statements.
|
||||
*/
|
||||
|
||||
int a = 20; // Create a global variable "a"
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
background(51);
|
||||
stroke(255);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Draw a line using the global variable "a"
|
||||
line(a, 0, a, height);
|
||||
|
||||
// Create a new variable "a" local to the for() statement
|
||||
for(int a=50; a<80; a += 2) {
|
||||
line(a, 0, a, height);
|
||||
}
|
||||
|
||||
// Create a new variable "a" local to the loop() method
|
||||
int a = 100;
|
||||
// Draw a line using the new local variable "a"
|
||||
line(a, 0, a, height);
|
||||
|
||||
// Make a call to the custom function drawAnotherLine()
|
||||
drawAnotherLine();
|
||||
|
||||
// Make a call to the custom function setYetAnotherLine()
|
||||
drawYetAnotherLine();
|
||||
}
|
||||
|
||||
void drawAnotherLine()
|
||||
{
|
||||
// Create a new variable "a" local to this method
|
||||
int a = 185;
|
||||
// Draw a line using the local variable "a"
|
||||
line(a, 0, a, height);
|
||||
}
|
||||
|
||||
void drawYetAnotherLine()
|
||||
{
|
||||
// Because no new local variable "a" is set,
|
||||
// this lines draws using the original global
|
||||
// variable "a" which is set to the value 20.
|
||||
line(a+2, 0, a+2, height);
|
||||
}
|
||||
Binary file not shown.
|
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 Variables extends PApplet {
|
||||
public void setup() {/**
|
||||
* Variables.
|
||||
*
|
||||
* Variables are used for storing values. In this example, changing
|
||||
* the values of variables 'a' and 'b' significantly change the composition.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(153);
|
||||
|
||||
int a = 20;
|
||||
int b = 50;
|
||||
int c = a*8;
|
||||
int d = a*9;
|
||||
int e = b-a;
|
||||
int f = b*2;
|
||||
int g = f+e;
|
||||
|
||||
line(a, f, b, g);
|
||||
line(b, e, b, g);
|
||||
line(b, e, d, c);
|
||||
line(a, e, d-e, c);
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Variables" });
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Variables.
|
||||
*
|
||||
* Variables are used for storing values. In this example, changing
|
||||
* the values of variables 'a' and 'b' significantly change the composition.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(153);
|
||||
|
||||
int a = 20;
|
||||
int b = 50;
|
||||
int c = a*8;
|
||||
int d = a*9;
|
||||
int e = b-a;
|
||||
int f = b*2;
|
||||
int g = f+e;
|
||||
|
||||
line(a, f, b, g);
|
||||
line(b, e, b, g);
|
||||
line(b, e, d, c);
|
||||
line(a, e, d-e, c);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user