Skip to content

Instantly share code, notes, and snippets.

@benben
Created July 7, 2012 16:14
Show Gist options
  • Save benben/3067024 to your computer and use it in GitHub Desktop.
Save benben/3067024 to your computer and use it in GitHub Desktop.
of app for twitter avatar (press space to save images, stitch it together with a gif animator)
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
for (int i = 0; i <= 255; i++) {
ofColor c;
c.setHsb((i % 16) * 16, 255, i);
colors.push_back(c);
}
width = 5;
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
mod2 = -1;
for (int j = 0; j <= 99; j++) {
mod = 0;
for (int i = 0; i <= 255; i++) {
ofSetColor(colors[i]);
ofRect((i % 16)*width+((j % 10)*width*16),mod*width+(mod2*width*16), width, width);
if (((i+1) % 16) == 0) {
mod = mod + 1;
}
}
if (((j+1) % 10) == 0) {
mod2 = mod2 + 1;
}
}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
random_shuffle ( colors.begin(), colors.end() );
ofImage grab;
grab.grabScreen(0, 0, width*16, width*16);
grab.saveImage(ofToString(ofGetFrameNum()) + ".png");
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
vector<ofColor> colors;
int width;
float mod, mod2;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment