This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Sometimes we need the path to the Processing data directory. | |
| // creates a virtual file within the data directory | |
| File file = new File(dataPath("") + File.separator + "a_filename.txt"); | |
| //using dataPath("..."), the path can be altered, too (when using "", this is not the case). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * make sure, you have activated stereomix as your recording device in your system settings! | |
| */ | |
| import ddf.minim.*; | |
| import ddf.minim.signals.*; | |
| Minim minim; | |
| AudioInput in; | |
| SineWave sine; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.Graphics2D; | |
| import java.awt.image.BufferedImage; | |
| import java.io.BufferedReader; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.InputStreamReader; | |
| import java.io.OutputStreamWriter; | |
| import java.io.UnsupportedEncodingException; | |
| import java.net.HttpURLConnection; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.AWTException; | |
| import java.awt.Robot; | |
| KeystrokeSimulator keySim; | |
| void setup(){ | |
| keySim = new KeystrokeSimulator(); | |
| } | |
| void draw(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.net.*; | |
| import java.io.*; | |
| public static class IpFromUrl { | |
| // Returns the IP address of an URL | |
| // i.e. http://www.facebook.com -> 123.456.789.10 | |
| public static String getIp( String hostname ) throws IOException { | |
| try { | |
| InetAddress ipaddress = InetAddress.getByName(hostname); | |
| System.out.println("IP address: " + ipaddress.getHostAddress()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Author: Tim Pulver | |
| * Date: 2013 | |
| * Tested with Processing 2.0 | |
| * original code by jungalero (processing.org forum) | |
| */ | |
| import java.awt.AWTException; | |
| import java.awt.Robot; | |
| import java.awt.Rectangle; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.reflect.*; | |
| import java.io.File; | |
| class CallerWithParams{ | |
| /** | |
| @param o the object which contains the method to call, | |
| when passing 'this' from within the processing main sketch, | |
| all functions in your main sketch will be recognized | |
| (setup(), draw(),..., custom methods) | |
| @param m the name of the method to call without "()" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Threshold{ | |
| /** | |
| * Returns a new PImage with threshold thresh in Grayscale. | |
| * All coulours will be splitted according to their | |
| * brightness between black and white. | |
| */ | |
| PImage threshold(PImage pi, int thresh){ | |
| if(pi==null || thresh < 0 || thresh > 255){ // invalid argument | |
| println("threshold(): PImage == 0 or threshold value not in range [0..255]"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String parentFolder = "M:\\INSERT_PARENT_DIR_HERE"; | |
| void setup(){ | |
| File tmpDir; | |
| File fParentFolder = new File(parentFolder); | |
| println("Scanning " + fParentFolder.getAbsolutePath()); | |
| println("Folder exists: " + fParentFolder.exists()); | |
| File[] folderList = fParentFolder.listFiles(); | |
| println("Number of files/folders: " + folderList.length); | |
| println("-----------------------------------"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import processing.pdf.*; | |
| import com.lowagie.text.PageSize; | |
| import com.lowagie.text.Rectangle; | |
| /** | |
| * Hack to use dinA paper formats | |
| * Originally posted by http://toxi.co.uk, I made small changes to use it with Processing 2.0 alpha. | |
| */ | |