Hackpads are smart collaborative documents. .

Guglielmo Torelli

1077 days ago
Unfiled. Edited by Zachary Dunham , Yuki Yoshida , Guglielmo Torelli 1077 days ago
  •     
 
Yuki Y
  • //Processing function to print serial ports
  • println(Serial.list());
  • //Listing the available serial ports with a for loop!!
  • for (int i = 0; i < Arduino.list().length; i++) {
  •     println(i + " --> " + Arduino.list()[i]);
  •   }
 
 
 
 
More about Synchronous and Asynchonous communication.
 
 
1084 days ago
Jason L Shaders are fun
Nathan R Check out typing.io!
 
Jason L The following code goes in your bin/data folder
 
Here is the code for the vertex shader "bin/data/shader.vert"
 
  • void main(void)
  • {
  •     gl_TexCoord[0] = gl_MultiTexCoord0;
  •     gl_Position    = ftransform();
  • }
 
here is the code for the fragment(pixel) shader "bin/data/shader.frag"
 
Jason L
  • void main( void )
  • {
  •     float width = 1024.0;
  •     float height = 768.0;
  •         float x = gl_FragCoord.x / width;
  •     float y = gl_FragCoord.y / height;
Jason L
  •     
Jason L
  •     float gray = (x * y);
  •     
  •     
  •     gl_FragColor = vec4(gray, gray, gray, 1.0);
for Defne:
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::setup(){
  •  
  •     shader.load("shader");
  •  
  •  
  •  
  • }
  •  
  •  
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::update(){
  •  
  •     ofSetWindowTitle("FPS: " + ofToString(ofGetFrameRate()));
  •  
  •  
  •  
  • }
  •  
  •  
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::draw(){
  •  
  •     shader.begin();
  •  
  •     ofRect(0, 0, ofGetWidth(), ofGetHeight());
  •  
  •     shader.end();   
  •  
  •  
  •  
  • }
  • Examples:
  •  
  • void main(void)
  • {
  •         float width = 1024.0;
  •         float height = 768.0;
  •         float x = gl_FragCoord.x / width;
  •         float y = gl_FragCoord.y / height;
  •  
  •         float gray;
  •  
  •         if (sin(x * 80) > cos(y * 50)) {
  •                 gray = tan(sin((x * y) * 40.0) * 34.0);
  •         } else {
  •                 gray = tan(y + x);
  •         }
  •  
  •         gl_FragColor = vec4(gray, gray, gray, 1.0);
  •         //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  • }
 
 
Defne O Defne's Shader:
code:
 
...
1108 days ago
Zach L Zach's workshops
 
Please sign up / limit of 8 per workshop (happy to repeat and we'll take notes).  please sign up below
 
  • 11/11  10 AM  --- Text Processing / scraping in python and command line (if not on osx, have python 2.7.7 installed) 
Defne O
  • Defne Onen
Zach L
  • 11/17  10 AM  --- Image processing / computer vision / pixels
Zan A
  • Zan Armstrong
Christo A
  • Christo Allegra
Defne O
  • Defne Onen
Zach L
  • 11/18  10 AM  --- 3d / opengl
Zan A
  • Zan Armstrong
Christo A
  • Christo Allegra
Defne O
  • Defne Onen
Zach L
  • 11/18  1PM --- io / connection / bridging technologies
Zan A
  • Zan Armstrong
Defne O
  • Defne Onen
 
 
1122 days ago
Unfiled. Edited by Lauren Gardner , Guglielmo Torelli , Zach Lieberman 1122 days ago
Lauren G Zach's Animation Class
 
Class on github
 
Examples
Mushroom on an oscilloscope - youtube
Jerobeam Fenderson - nuclear black noise
John Whitney's use of analogue computers (video) (wikipedia) (catalog 1961) - made the graphics manually (math/by hand) and photographed them on the computer then animated them (vertigo title sequence) (permutations)
 
sine and cosine
...think of the dot moving around the circle
  • sine follows the height of the dot
  • cosine follows the movement back and forth of the dot
 
example in OF
  • sin thinks in radiants so every 6.28 seconds it will repeat (2 pi)
  • void ofApp::draw(){
  •     ofBackground(0,0,0);
  •     
  •     float pct = (sin(ofGetElapsedTimef()) / 2.0) + 0.5;
  •     cout << pct << endl;
  •  
  •     float xPos = 250;
  •     ofCircle(xPos,250,30);
  • }
*gives us the small numbers (see in debug). you can convert to percent and remap to scale and offset to get big numbers (replace line 7)
  • float xPos = 300 + pct * 200;
This is the long way, a short way to do it is 
  • float xPos = ofMap( sin(ofGetElapsedTimef()), -1, 1, 300, 500);
Can make it go faster by adding this
  • float xPos = ofMap( sin(ofGetElapsedTimef()*15), -1, 1, 300, 500);
 
Combining sine waves
...using volume to turn the 'frequency' of the other sine
  • carrier - the underlying frequency
  • modulator - the frequency that is changing the carrier
  • code here...
 
Moving sine and cosinein a circle
X = xorig + r * cos(angle)
y = yorig + r * sin(angle)
  • ...code example...
  • in OF you'll see the sin represented as '-sin', its because 0,0 is the top left corner
  • hard to see what is happening but can record the path the cursor to see the movement
  • ...code example...
 
At this point he goes into week 4 & 5 of the git hub examples
  • next week - 'atan' lines, magnitude (how long the line is) & orientation (angle) 
  • push/pop Matrix
  • translate, rotate then redraw the box
 
Homework from 10/27
  • Create your own John Whitney art using sine & cosine
  • make a creature, can it breathe - can it have wings
 
Guglielmo T Useful resources
CODING MATH youtube channel. The guy is using very basic javascript so it's also good for learning basic js stuff.
You can find Trigonometry in video lessons 1 to 5 and easing in lessons 27 and 28.
 
 
 
1125 days ago
Unfiled. Edited by Guglielmo Torelli 1125 days ago
Mastering openFrameworks: Creative Coding Demystified Denis Perevalov Computers & Technology, Reference
 
1130 days ago
Unfiled. Edited by Guglielmo Torelli 1130 days ago
OSX Terminal Student Workshop - 22/10
 

Contact Support



Please check out our How-to Guide and FAQ first to see if your question is already answered! :)

If you have a feature request, please add it to this pad. Thanks!


Log in