mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 01:29:17 +01:00
focus code, and color(gray) / color(gray/alpha)
This commit is contained in:
@@ -38,7 +38,7 @@ import java.util.*;
|
||||
|
||||
public class PApplet extends Applet
|
||||
implements PConstants, Runnable,
|
||||
MouseListener, MouseMotionListener, KeyListener
|
||||
MouseListener, MouseMotionListener, KeyListener, FocusListener
|
||||
{
|
||||
static final double jdkVersion =
|
||||
toDouble(System.getProperty("java.version").substring(0,3));
|
||||
@@ -61,6 +61,17 @@ public class PApplet extends Applet
|
||||
public boolean keyPressed;
|
||||
public KeyEvent keyEvent;
|
||||
|
||||
/**
|
||||
* Gets set to true/false as the applet gains/loses focus.
|
||||
*/
|
||||
public boolean focused = false;
|
||||
|
||||
/**
|
||||
* Is the applet online or not? This can be used to test how the
|
||||
* applet should behave since online situations are different.
|
||||
*/
|
||||
public boolean online = false;
|
||||
|
||||
long millisOffset;
|
||||
|
||||
// getting the frame rate
|
||||
@@ -136,6 +147,7 @@ public class PApplet extends Applet
|
||||
addMouseListener(this);
|
||||
addMouseMotionListener(this);
|
||||
addKeyListener(this);
|
||||
addFocusListener(this);
|
||||
//timing = true;
|
||||
millisOffset = System.currentTimeMillis();
|
||||
|
||||
@@ -175,6 +187,13 @@ public class PApplet extends Applet
|
||||
this.width = g.width;
|
||||
this.height = g.height;
|
||||
g.applet = this;
|
||||
|
||||
try {
|
||||
getAppletContext();
|
||||
online = true;
|
||||
} catch (NullPointerException e) {
|
||||
online = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -551,6 +570,22 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// i am focused man, and i'm not afraid of death.
|
||||
// and i'm going all out. i circle the vultures in a van
|
||||
// and i run the block.
|
||||
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
focused = true;
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
focused = false;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// getting the time
|
||||
@@ -642,6 +677,7 @@ public class PApplet extends Applet
|
||||
* Is the applet online or not? This can be used to test how the
|
||||
* applet should behave since online situations are different.
|
||||
*/
|
||||
/*
|
||||
public boolean online() {
|
||||
try {
|
||||
getAppletContext();
|
||||
@@ -650,6 +686,7 @@ public class PApplet extends Applet
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -3178,6 +3215,26 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public final int color(int gray) {
|
||||
return g.color(gray);
|
||||
}
|
||||
|
||||
|
||||
public final int color(float gray) {
|
||||
return g.color(gray);
|
||||
}
|
||||
|
||||
|
||||
public final int color(int gray, int alpha) {
|
||||
return g.color(gray, alpha);
|
||||
}
|
||||
|
||||
|
||||
public final int color(float gray, float alpha) {
|
||||
return g.color(gray, alpha);
|
||||
}
|
||||
|
||||
|
||||
public final int color(int x, int y, int z) {
|
||||
return g.color(x, y, z);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user