mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Loading URLs.
|
||||
*
|
||||
* Click on the left button to open a different URL in the same window (Only
|
||||
* works online). Click on the right button to open a URL in a new browser window.
|
||||
*/
|
||||
|
||||
boolean overLeftButton = false;
|
||||
boolean overRightButton = false;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(204);
|
||||
|
||||
// Left buttom
|
||||
if (overLeftButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(20, 60, 75, 75);
|
||||
rect(50, 90, 15, 15);
|
||||
|
||||
// Right button
|
||||
if (overRightButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(105, 60, 75, 75);
|
||||
line(135, 105, 155, 85);
|
||||
line(140, 85, 155, 85);
|
||||
line(155, 85, 155, 100);
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
if (overLeftButton) {
|
||||
link("http://www.processing.org");
|
||||
} else if (overRightButton) {
|
||||
link("http://www.processing.org", "_new");
|
||||
}
|
||||
}
|
||||
|
||||
void mouseMoved() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
void mouseDragged() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
void checkButtons() {
|
||||
if (mouseX > 20 && mouseX < 95 && mouseY > 60 && mouseY < 135) {
|
||||
overLeftButton = true;
|
||||
} else if (mouseX > 105 && mouseX < 180 && mouseY > 60 && mouseY <135) {
|
||||
overRightButton = true;
|
||||
} else {
|
||||
overLeftButton = overRightButton = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
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 EmbeddedLinks extends PApplet {
|
||||
|
||||
/**
|
||||
* Loading URLs.
|
||||
*
|
||||
* Click on the left button to open a different URL in the same window (Only
|
||||
* works online). Click on the right button to open a URL in a new browser window.
|
||||
*/
|
||||
|
||||
boolean overLeftButton = false;
|
||||
boolean overRightButton = false;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(204);
|
||||
|
||||
// Left buttom
|
||||
if(overLeftButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(20, 60, 75, 75);
|
||||
rect(50, 90, 15, 15);
|
||||
|
||||
// Right button
|
||||
if(overRightButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(105, 60, 75, 75);
|
||||
line(135, 105, 155, 85);
|
||||
line(140, 85, 155, 85);
|
||||
line(155, 85, 155, 100);
|
||||
}
|
||||
|
||||
public void mousePressed()
|
||||
{
|
||||
if(overLeftButton) {
|
||||
link("http://www.processing.org");
|
||||
} else if (overRightButton) {
|
||||
link("http://www.processing.org", "_new");
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMoved() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
public void mouseDragged() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
public void checkButtons() {
|
||||
if(mouseX > 20 && mouseX < 95 &&
|
||||
mouseY > 60 && mouseY <135) {
|
||||
overLeftButton = true;
|
||||
} else if (mouseX > 105 && mouseX < 180 &&
|
||||
mouseY > 60 && mouseY <135) {
|
||||
overRightButton = true;
|
||||
} else {
|
||||
overLeftButton = overRightButton = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "EmbeddedLinks" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Loading URLs.
|
||||
*
|
||||
* Click on the left button to open a different URL in the same window (Only
|
||||
* works online). Click on the right button to open a URL in a new browser window.
|
||||
*/
|
||||
|
||||
boolean overLeftButton = false;
|
||||
boolean overRightButton = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(204);
|
||||
|
||||
// Left buttom
|
||||
if(overLeftButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(20, 60, 75, 75);
|
||||
rect(50, 90, 15, 15);
|
||||
|
||||
// Right button
|
||||
if(overRightButton == true) {
|
||||
fill(255);
|
||||
} else {
|
||||
noFill();
|
||||
}
|
||||
rect(105, 60, 75, 75);
|
||||
line(135, 105, 155, 85);
|
||||
line(140, 85, 155, 85);
|
||||
line(155, 85, 155, 100);
|
||||
}
|
||||
|
||||
void mousePressed()
|
||||
{
|
||||
if(overLeftButton) {
|
||||
link("http://www.processing.org");
|
||||
} else if (overRightButton) {
|
||||
link("http://www.processing.org", "_new");
|
||||
}
|
||||
}
|
||||
|
||||
void mouseMoved() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
void mouseDragged() {
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
void checkButtons() {
|
||||
if(mouseX > 20 && mouseX < 95 &&
|
||||
mouseY > 60 && mouseY <135) {
|
||||
overLeftButton = true;
|
||||
} else if (mouseX > 105 && mouseX < 180 &&
|
||||
mouseY > 60 && mouseY <135) {
|
||||
overRightButton = true;
|
||||
} else {
|
||||
overLeftButton = overRightButton = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Loading Images.
|
||||
*
|
||||
* Loading a recent image from the US National Weather Service.
|
||||
* Notice the date in the upper left corner of the image.
|
||||
* Processing applications can only load images from the network
|
||||
* while running in the Processing environment. This example will
|
||||
* not run in a web broswer and will only work when the computer
|
||||
* is connected to the Internet.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
PImage img1;
|
||||
img1 = loadImage("http://www.processing.org/img/processing_beta_cover.gif");
|
||||
image(img1, 0, 45);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
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 LoadingImages extends PApplet {
|
||||
public void setup() {/**
|
||||
* Loading Images.
|
||||
*
|
||||
* Loading a recent image from the US National Weather Service.
|
||||
* Notice the date in the upper left corner of the image.
|
||||
* Processing applications can only load images from the network
|
||||
* while running in the Processing environment. This example will
|
||||
* not run in a web broswer and will only work when the computer
|
||||
* is connected to the Internet.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
PImage img1;
|
||||
img1 = loadImage("http://www.processing.org/img/processing_beta_cover.gif");
|
||||
image(img1, 0, 45);
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "LoadingImages" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Loading Images.
|
||||
*
|
||||
* Loading a recent image from the US National Weather Service.
|
||||
* Notice the date in the upper left corner of the image.
|
||||
* Processing applications can only load images from the network
|
||||
* while running in the Processing environment. This example will
|
||||
* not run in a web broswer and will only work when the computer
|
||||
* is connected to the Internet.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
PImage img1;
|
||||
img1 = loadImage("http://www.processing.org/img/processing_beta_cover.gif");
|
||||
image(img1, 0, 45);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user