Alerts4P – Processing Library
‘Alerts4P’ is a Processing library, created by Rolf van Gelder.
Processing is an open source programming language and environment for people who want to create images, animations, and interactions.
‘Alerts4P‘ is an utility for displaying popup alerts from a Processing sketch.
Download
Download the library:
- Alerts4P.zip v1.0 (07/11/2018), the latest version
Functionality
It can display popup alerts from a sketch.
Constructors
- Alerts4P
(processing.core.PApplet pApp)
Default constructor: alert will be centered on the screen, all default values will be used - Alerts4P
(processing.core.PApplet pApp,
int pXPos,
int pYPos)
Create an alert on a specific screen position - Alerts4P
(processing.core.PApplet pApp,
int pTextSize,
int pHorSpacing,
int pTxtColor,
int pBgColor,
int pRectRadius)
Create an alert with several lay-out settings
Methods
- disableAlerts
()
Disable all alerts - display
()
Display an alert (if scheduled) - enableAlerts
()
Enable all alerts - setAlert
(java.lang.String pMsg)
Create an alert that will be shown for the default number of millis - setAlert
(java.lang.String pMsg,
int pDurationMS)
Create an alert that will be shown for a specific number of millis - setBgColor
(int pBgColor)
Set the background color of the alert - setDuration
(int pDuration)
Set the default time the alert will be shown (in millis) - setHorSpacing
(int pHorSpacing)
Set the horizontal spacing inside of the popup (=horizontal padding) - setOpacity
(int pOpacity)
Set the opacity for the alerts - setRectRadius
(int pRectRadius)
Set the radius of the rounded corners - setStrokeColor
(int pStrokeColor)
Set the color of the frame - setStrokeWeight
(int pStrokeWeight)
Set the strokeweight for the frame - setTextColor
(int pTxtColor)
Set the text color for the alerts - setTextSize
(int pTextSize)
Set the text size for the alerts - version
()
Display the version info of the library
Example
// IMPORT THE ALERTS LIBRARY import com.cage.alerts4p.*; // ALERT OBJECT Alerts4P alert; // BEGIN- AND END COLORS FOR GRADIENT color c1 = color(230, 80, 0); color c2 = color(0, 80, 230); /*********************************************************************************** * SETUP ***********************************************************************************/ void setup() { size(400, 400); // CREATE AND INITIALIZE THE ALERTS INSTANCE alert = new Alerts4P(this); // DISPLAY VERSION OF THE LIBRARY alert.version(); // LAY-OUT alert.setTextColor(255); alert.setStrokeColor(255); alert.setStrokeWeight(3); alert.setTextSize(18); } // setup() /*********************************************************************************** * DRAW ***********************************************************************************/ void draw() { background(0); // DRAW GRADIENT drawGradient(0, 0, width, height, c2, c1); // DISPLAY ALERT (IF AVAILABLE) alert.display(); } // draw() /*********************************************************************************** * DRAW THE GRADIENT ***********************************************************************************/ void drawGradient(int x, int y, float w, float h, color c1, color c2) { for (int i = x; i <= x+w; i++) { float inter = map(i, x, x+w, 0, 1); color c = lerpColor(c1, c2, inter); stroke(c); line(i, y, i, y+h); } // for (int i = x; i <= x+w; i++) } // drawGradient( /********************************************************************************** * MOUSE HANDLER ***********************************************************************************/ void mousePressed() { alert.setBgColor(get(mouseX, mouseY)); alert.setAlert("You picked this color", 1500); } // mousePressed()
Documentation
Click HERE to see the javadocs.
History
v1.0 (07/11/2018)
– initial release