Shape - "Hello,Shape"

来源:互联网 发布:知乎长期光头 编辑:程序博客网 时间:2024/06/05 05:19

 

 


/* *  MOUSE *  position x      : length *  position y      : thickness and number of lines *  drag            : draw */ofColor col;bool bClear = false;//--------------------------------------------------------------void testApp::setup(){        ofSetWindowShape(720, 720);    ofNoFill();    ofBackground(255);        ofSetBackgroundAuto(false);        //    col = ofColor(0);}//--------------------------------------------------------------void testApp::update(){    }//--------------------------------------------------------------void testApp::draw(){        // stupid method, fixed clear problem in mac    if ( bClear ){        ofSetBackgroundAuto(true);        ofClear(255);        bClear = false;    }    else        ofSetBackgroundAuto(false);        ofEnableAlphaBlending();    if ( ofGetMousePressed()){        ofPushMatrix();        ofTranslate(ofGetWidth()*.5, ofGetHeight()*.5);                int circle_res = ofMap(mouseX+100, 0, ofGetHeight(), 2, 10);        float radius = mouseX - ofGetWidth()*.5 + 0.5;        float angle = TWO_PI/circle_res;                ofSetColor(col, 5);                ofEnableSmoothing();        ofBeginShape();        for (int i = 0; i<=circle_res; i++) {            float x = 0 + cos(angle*i) * radius;            float y = 0 + sin(angle*i) * radius;            ofVertex(x, y);        }        ofEndShape();        ofDisableSmoothing();                ofPopMatrix();    }}//--------------------------------------------------------------void testApp::keyPressed(int key){        if ( key == OF_KEY_BACKSPACE )  bClear = true;    if ( key == 's' )               ofSaveScreen("C.png");    if ( key == 'r' )                       col = ofColor(ofRandomuf()*255, ofRandomuf()*255, ofRandomuf()*255, 10);}

-GENERATIVE DESIGN-


原创粉丝点击