double yPos = Height;
Timer = Draw;
void Draw()
{
//draw() loops forever. Until stopped
Background(204);
yPos = yPos-1;
if(yPos < 0)
{
yPos = Height;
}
Line(0, yPos, Width, yPos);
}
Draw()
double x = 0;
Timer = Draw;
MousePressed = OnMousePressed;
bool loop = true;
void OnMousePressed()
{
if(loop == true)
NoLoop();
else
Loop();
loop =! loop;
}
void Draw()
{
Background(204);
x = x + 1;
if (x > Width)
{
x = 0;
}
Line(x, 0, x, Height);
}
Loop()
double x = 0;
Timer= Draw;
void Draw()
{
NoLoop();
Background(200);
Line(10, 10, 90, 90);
}
double x = 0;
Timer= Draw;
void Draw()
{
if(MouseIsPressed == true)
{
NoLoop();
}
Background(204);
x = x + 1;
if (x > Width)
{
x = 0;
}
Line(x, 0, x, Height);
}
NoLoop()
int counter = 0;
Timer = Draw;
void Draw()
{
Background(200);
Text(counter);
if(KeyIsPressed == true)
{
NoLoop();
}
counter += 1;
}
Timer = "Method"
double x = 0;
Timer= Draw;
FrameRate(30);
void Draw()
{
Background(204);
x = x + 1;
if (x > Width)
{
x = 0;
}
Line(x, 0, x, Height);
}
FrameRate(fps)
FrameRate()
Timer= Draw;
void Draw()
{
Background(200);
Text(FrameCount());
}
FrameCount()
Timer = Output;
void Output()
{
Background(204);
long millisecond = Millis();
Text("Milliseconds \n running: \n"+ millisecond, 5, 40);
}
Millis()
Width = 100;
Height = 100;
Timer = Draw;
void Draw()
{
Background(200);
Text("Width: "+ Width + "\n" +"Height: "+ Height);
}
Width = 100;
Height = 100;
Timer = Draw;
void Draw()
{
Background(200);
Text("Width: "+ Width + "\n" +"Height: "+ Height);
}
Timer= Draw;
void Draw()
{
Background(204);
var widthMid = Width / 2;
var heightMid = Height / 2;
Line(widthMid, 0, widthMid, Height);
Line(0, heightMid, Width, heightMid);
if (MouseX < widthMid && MouseY < heightMid)
{
Cursor("Arrow");
}
else if (MouseX > widthMid && MouseY < heightMid)
{
Cursor("No");
}
else if (MouseX > widthMid && MouseY > heightMid)
{
Cursor("SizeAll");
}
else
{
Cursor("UpArrow");
}
}
Cursor("Cursortype")
double r = Random(50, 100);
Line(30 + r, 40, 85, r);
Random(min, max);
Background(200);
double a = 20;
double b = 80;
double c = Lerp(a, b, 0.2);
double d = Lerp(a, b, 0.5);
double e = Lerp(a, b, 0.8);
double y = 50;
StrokeWeight(5);
Circle(a, y, 5);
Circle(b, y, 5);
Stroke(100);
Circle(c, y, 5);
Circle(d, y, 5);
Circle(e, y, 5);
Lerp(start, stop, amt);
Background(200);
double x1 = 20;
double x2 = 80;
double y = 50;
StrokeWeight(5);
Circle(x1, y, 5);
Circle(x2, y, 5);
double d = Dist(x1, y, x2, y);
Text("Distance:" + d);
Dist(x1, y1, x2, y2);
Background(200);
Triangle(20,20, 110,20, 20,100);
double x = Dist(20, 20, 110, 20);
double y = Dist(20, 20, 20, 100);
double h = Hypot(x, y);
Text("Hypotenuse Length: " + h);
Hypot(first, second);
Timer = Draw;
void Draw()
{
Background(200);
double leftWall = 25;
double rightWall = 75;
// x1 is just the MouseX, while
// x2 is the MouseX, but constrained
// between the leftWall and rightWall!
double x1 = MouseX;
double x2 = Constrain(MouseX, leftWall, rightWall);
// Draw the walls.
Stroke(150);
Line(leftWall, 0, leftWall, Height);
Line(rightWall, 0, rightWall, Height);
// Draw x1 and x2 as circles.
NoStroke();
Fill(150);
Ellipse(x1, 33, 9, 9); // Not Constrained
Fill(0);
Ellipse(x2, 66, 9, 9); // Constrained
}
Constrain(n, low, high);
Background(200);
double value = 23;
double m = Map(value, 20, 80, 0, 100, true);
Text(m); // output: 5
Map(value, start1, stop1, start2, stop2, [withinBounds]);
Background(200);
double value = 30;
double n = Norm(value, 0, 100);
Text(n); // output: 0.3
Norm(value, start, stop);
double deg = 45.0;
double rad = Radians(deg);
Text(deg + " degrees is " + rad + " radians");
Radians(degrees);
double xoff = 0.0;
Timer = Draw;
void Draw()
{
Background(200);
xoff = xoff + 0.01;
double n = Noise(xoff) * Width/2;
Line(n, 0, n, Height);
Text(Noise(xoff));
}
Noise(x, [y], [z]);
Text(PI);
Text(TWO_PI);
Text(HALF_PI);
Text(QUARTER_PI);
Timer = Draw;
void Draw()
{
Background(200);
Line(MouseX, 0, MouseX, Height);
}
MouseX
Timer = Draw;
void Draw()
{
Background(200);
Line(0, MouseY, Width, MouseY);
}
MouseY
Timer = Draw;
void Draw()
{
Background(237, 34, 93);
Fill(0);
if (MouseIsPressed == true)
Ellipse(50, 50, 50, 50);
else
Rect(50, 50, 50, 50);
Text("MouseIsPressed: " + MouseIsPressed);
}
MouseIsPressed
MousePressed = OnMousePressed;
double value = 0;
Background(200);
void OnMousePressed()
{
Fill(value);
Rect(25, 25, 50, 50);
if (value == 0)
{
value = 255;
}
else
{
value = 0;
}
}
MousePressed
Timer = Draw;
void Draw()
{
Background(237, 34, 93);
Fill(0);
if (MouseButton == MouseButtons.Left)
Ellipse(50, 50, 50, 50);
if (MouseButton == MouseButtons.Right)
Rect(50, 50, 50, 50);
if (MouseButton == MouseButtons.Middle)
Triangle(23, 75, 50, 20, 78, 75);
PrintLn(MouseButton);
}
MouseButton
Timer = Draw;
void Draw()
{
Fill(0);
if (KeyIsPressed == true)
{
Fill(255);
}
else
{
Fill(0);
}
Square(25, 25, 25);
}
KeyIsPressed
KeyPressed = Draw;
int value = 0;
void Draw()
{
Fill(value);
if (value == 0)
{
value = 255;
}
else
{
value = 0;
}
Square(25, 25, 25);
}
KeyPressed
KeyPressed = OnKeyPressed;
void OnKeyPressed()
{
Background(204);
Text(Key, 25, 25);
}
Key
KeyPressed = OnKeyPressed;
void OnKeyPressed()
{
Background(204);
Text(KeyCode, 25, 25);
}
KeyCode
Ellipse(45, 45, 50, 80);
Ellipse(x, y, w, [h])
Circle(45, 45, 50);
Circle(x, y, d)
Rect(45, 45, 50, 65);
Rect(x, y, w, h)
Square(45, 40.35, 50);
Square(x, y, w)
Line(40, 60, 80, 100);
Line(x1, y1, x2, y2)
Triangle(20, 10, 80, 80, 100, 10);
Triangle(x1, y1, x2, y2, x3, y3)
string path = @"http://mana-buch.de/149/cover.png";
Image(path);
path = @"C:\images\Logo.png";
Image(path, 5, 10);
Image(path, [x], [y])
Point(20, 40);
Point(x, y)
Arc(100, 100, 200, 250, 50, 80, 45, true);
Arc(x1, y1, x2, y2, w, h, angle rotation, clockwise);
Bezier(25, 20, 100, 180, 280, 12, 305, 350, true);
Bezier(xStart, yStart, x1, y1, x2, y2, x3, y3, isClosed)
Text("Test", 25, 30, 20, 30);
Text(text, x, y, [w], [h])
Background(50)
Background(value)
Background(x1, x2, x3)
Background(x1, x2, x3, alpha)
Background(colorString)
Fill(51);
Rect(50,50,60,60);
Fill(value)
Fill(x1, x2, x3)
Fill(x1, x2, x3, alpha)
Fill(gray value, alpha)
Fill(colorString)
NoFill();
Rect(50, 50, 60, 60);
NoFill()
StrokeWeight(4);
Stroke(51);
Rect(100, 100, 60, 60);
Stroke(value)
Stroke(x1, x2, x3)
Stroke(x1, x2, x3, alpha)
Stroke(gray value, alpha)
Stroke(colorString)
NoStroke();
Rect(50, 50, 60, 60);
NoStroke()
TextSize(13);
Text("Font Size 13", 10, 30);
TextSize(15);
Text("Font Size 15", 10, 60);
TextSize(17);
Text("Font Size 17", 10, 90);
TextSize(size)
TextSize(12);
TextFont("Georgia");
Text("Georgia", 12, 30);
TextFont("Helvetica");
Text("Helvetica", 12, 60);
TextFont(textFont)
TextColor("Red");
Text("Text Color", 10, 30);
TextColor(value)
TextColor(x1, x2, x3)
TextColor(x1, x2, x3, alpha)
TextColor(colorString)
Timer = Draw;
void Draw()
{
Background(128);
Translate(2,2);
Rotate(Radians(0.45));
Rect(Width/2, Height/2, 50, 50);
}
Rotate(angle)
Rect(40, 40, 55, 55);
Translate(30, 20);
Rect(50, 50, 55, 55);
Translate(14, 14);
Rect(60, 60, 55, 55);
Timer = Draw;
var rectangle = Rect(0, 0, 55, 55);
void Draw()
{
rectangle.Translate(1, 1);
}
Translate(x, y)
StrokeWeight(1);
Line(20, 20, 80, 20);
StrokeWeight(4);
Line(20, 40, 80, 40);
StrokeWeight(10);
Line(20, 70, 80, 70);
StrokeWeight(weight)
StrokeWeight(12.0);
StrokeCap(StrokeCaps.Flat);
Line(20, 10, 80, 10);
StrokeCap(StrokeCaps.Square);
Line(20, 30, 80, 30);
StrokeCap(StrokeCaps.Round);
Line(20, 50, 80, 50);
StrokeCap(StrokeCaps.Triangle);
Line(20, 70, 80, 70);
StrokeCap(StrokeCaps.cap)
EllipseMode(EllipseModes.Corner);
Fill(255);
Ellipse(50, 50, 30, 30);
EllipseMode(EllipseModes.mode)
RectMode(RectModes.Corner);
Fill(255);
Rect(25,25,50,50);
RectMode(RectModes.mode)
PrintLn("Hello World")
PrintLn()