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,54 @@
|
||||
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 Pattern extends PApplet {
|
||||
|
||||
/**
|
||||
* Patterns.
|
||||
*
|
||||
* Move the cursor over the image to draw with a software tool
|
||||
* which responds to the speed of the mouse.
|
||||
*/
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(640, 360);
|
||||
background(102);
|
||||
smooth();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
// Call the variableEllipse() method and send it the
|
||||
// parameters for the current mouse position
|
||||
// and the previous mouse position
|
||||
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
|
||||
}
|
||||
|
||||
|
||||
// The simple method variableEllipse() was created specifically
|
||||
// for this program. It calculates the speed of the mouse
|
||||
// and draws a small ellipse if the mouse is moving slowly
|
||||
// and draws a large ellipse if the mouse is moving quickly
|
||||
|
||||
public void variableEllipse(int x, int y, int px, int py)
|
||||
{
|
||||
float speed = abs(x-px) + abs(y-py);
|
||||
stroke(speed);
|
||||
ellipse(x, y, speed, speed);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Pattern" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Patterns.
|
||||
*
|
||||
* Move the cursor over the image to draw with a software tool
|
||||
* which responds to the speed of the mouse.
|
||||
*/
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(640, 360);
|
||||
background(102);
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Call the variableEllipse() method and send it the
|
||||
// parameters for the current mouse position
|
||||
// and the previous mouse position
|
||||
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
|
||||
}
|
||||
|
||||
|
||||
// The simple method variableEllipse() was created specifically
|
||||
// for this program. It calculates the speed of the mouse
|
||||
// and draws a small ellipse if the mouse is moving slowly
|
||||
// and draws a large ellipse if the mouse is moving quickly
|
||||
|
||||
void variableEllipse(int x, int y, int px, int py)
|
||||
{
|
||||
float speed = abs(x-px) + abs(y-py);
|
||||
stroke(speed);
|
||||
ellipse(x, y, speed, speed);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user