Shape - "Hello,Shape"

 

 


/*
 *  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-


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值