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.text.NumberFormat; | |
| String s = "256,128"; | |
| int val = int(s.replaceAll(",","")); | |
| println(val); | |
| int val2 = 0; | |
| NumberFormat nf = NumberFormat.getNumberInstance(java.util.Locale.US); |
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
| // Daniel Shiffman | |
| // Programming from A to Z, Fall 2014 | |
| // https://github.com/shiffman/Programming-from-A-to-Z-F14 | |
| // This examples builds a very simple DOM visualization of concordance | |
| // It reads the text one word a a time and animates the words growing according to their counts | |
| var concordance; | |
| var wutang; | |
| var canvas; |
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
| PGraphics canvas; | |
| void setup() { | |
| canvas = createGraphics(20, 20); | |
| } | |
| void draw() { | |
| background(255); | |
| canvas.beginDraw(); | |
| canvas.background(0); |
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[] listFileNames(String dir) { | |
| File file = new File(dir); | |
| if (file.isDirectory()) { | |
| String names[] = file.list(); | |
| StringList filelist = new StringList(); | |
| for (String s : names) { | |
| if (!s.contains("DS_Store")) { | |
| filelist.append(s); |
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
| void setup() { | |
| size (400, 300); // make a canvas that's 300 x 300 | |
| //SETTING UP MY UNDERLYING GRID STRUCTURE | |
| int numImages = 12; | |
| int colWidth = 10; //column width | |
| int rowHeight = 10; //row height | |
| int colNum = width/colWidth; | |
| int rowNum = height/rowHeight; |
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
| color col; | |
| void setup() { | |
| size(200, 100); | |
| col = color(50, 100, 25); | |
| } | |
| void draw() { | |
| background(0); | |
| noStroke(); |
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
| PGraphics canvas; | |
| void setup() { | |
| size(255,330); | |
| canvas = createGraphics(2550,3300); | |
| canvas.beginDraw(); | |
| canvas.background(0); | |
| for (int i = 0; i < 1000; i++) { |
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
| // This is for Java 7 | |
| // With Java 8 you can now say: | |
| import javax.xml.bind.DatatypeConverter; | |
| import java.nio.ByteBuffer; | |
| import java.nio.IntBuffer; | |
| // Load an image | |
| PImage img = loadImage("file.jpg"); |
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
| var fs = require('fs'); | |
| var request = require('request'); | |
| var url = 'https://farm8.staticflickr.com/7484/15685407577_d19030d469_m.jpg'; | |
| var saveFile = 'test.jpg'; | |
| request.head(url, getImage); | |
| function getImage(err, res, body) { | |
| var req = request(url); |
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
| var canvas; | |
| var button; | |
| function setup() { | |
| // Make a canvas | |
| canvas = createCanvas(100,100); | |
| // Make an HTML DOM element, a button! | |
| // The button will have the word "submit" in it | |
| button = createButton("submit"); |