<commit_before>#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup()
{
    ofSetFrameRate(100.0f);
    ofSetCurveResolution(100);
    
    _shapeSize = 160;
    
    _defaultRenderer = ofGetCurrentRenderer();
    _shivaVGRenderer = ofPtr<ofxShivaVGRenderer>(new ofxShivaVGRenderer);
    ofSetCurrentRenderer(_shivaVGRenderer);
    
    _shivaVGRenderer->setLineJoinStyle(VG_JOIN_ROUND);
    _shivaVGRenderer->setLineCapStyle(VG_CAP_ROUND);
    
    _createPolygon();
    _createStar();
    _createCurvedPath();
}

void testApp::_createPolygon()
{
    float s = _shapeSize;
    float r = _shapeSize/2;
   	int numPoints = 6;
    float angleStep = TWO_PI/numPoints;
    
    for (int i = 0; i < numPoints; i++)
    {
    	ofPoint p(cos(angleStep*i)*r, sin(angleStep*i)*r);
        _polygon.addVertex(p);
    }
    
    _polygon.close();
}

void testApp::_createStar()
{
    float s = _shapeSize;
    float r = _shapeSize/2;
    float r2 = r/2;
   	int numPoints = 5;
    numPoints *= 2;
    float angleStep = TWO_PI/numPoints;
    
    _star.setStrokeColor(ofColor(255, 0, 0));
    _star.setFillColor(ofColor(255, 255, 255));
    _star.setStrokeWidth(20.0f);
    
    for (int i = 0; i < numPoints; i++)
    {
        float rad = i % 2 == 0 ? r2 : r;
        
        ofPoint p(cos(angleStep*i)*rad, sin(angleStep*i)*rad);
        _star.lineTo(p);
    }
    
    _star.close();
}


void testApp::_createCurvedPath ()
{
    _curvedPath.setFilled(false);
    _curvedPath.setStrokeColor(ofColor(255, 255, 255));
    _curvedPath.setStrokeWidth(20.0f);
    
    for (int i = 0; i < 20; i++)
    {
        float s = _shapeSize*1.5;
        float t = (i*100)/PI;
        ofPoint p = ofPoint(cos(t)*(sin(t*(cos(t)/PI))*s), sin(t)*(cos(t*(sin(t)/PI))*s));
        
        if (i == 0) _curvedPath.moveTo(p);
        else _curvedPath.curveTo(p);
    }
}

//--------------------------------------------------------------
void testApp::update()
{
    
}



//--------------------------------------------------------------
void testApp::draw()
{
	ofBackground(20);
    glPushMatrix();
    
    float w = _shapeSize;
    float s = 40.0f;
    float x = s;
    float y = s;
    
    ofSetColor(255, 0, 0);
    ofRect(x, y, 0, w, w);
    
    x += w + s;
    ofSetColor(ofFloatColor(0.0f, 0.0f, 1.0f));
    ofCircle(x + w/2, y + w/2, w/2);
    
    x += w + s;
    ofSetColor(ofFloatColor(0.0f, 1.0f, 0.0f));
    ofSetLineWidth(30.0f);
    ofLine(x + s, y + s, x + w - s, y + w - s);
    
    x += w + s;
    ofSetColor(ofFloatColor(1.0f, 0.0f, 1.0f));
    ofEllipse(x + w, y + w/2, w*2, w);
    
    x = s;
    y = s + w + s;
    
    ofSetLineWidth(20.0f);
    ofSetColor(0, 255, 255);
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_polygon.draw();
    ofPopMatrix();
    
    x += w + s;
    
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_star.draw();
    ofPopMatrix();
    
    x += w + w + s;
    y += w;
    
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_curvedPath.draw();
    ofPopMatrix();
    
    glPopMatrix();
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button)
{
    cout << "change renderer" << endl;
    
    if (ofGetCurrentRenderer() == _defaultRenderer)
    {
        ofSetCurrentRenderer(_shivaVGRenderer);
    }
    else
    {
        ofSetCurrentRenderer(_defaultRenderer);
    }
}

//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
    if (key == 99) // c letter<commit_msg>updated example with instructions<commit_after>#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup()
{
    ofSetFrameRate(100.0f);
    ofSetCurveResolution(100);
    
    _shapeSize = 160;
    
    _defaultRenderer = ofGetCurrentRenderer();
    _shivaVGRenderer = ofPtr<ofxShivaVGRenderer>(new ofxShivaVGRenderer);
    ofSetCurrentRenderer(_shivaVGRenderer);
    
    _shivaVGRenderer->setLineJoinStyle(VG_JOIN_ROUND);
    _shivaVGRenderer->setLineCapStyle(VG_CAP_ROUND);
    
    _createPolygon();
    _createStar();
    _createCurvedPath();
}

void testApp::_createPolygon()
{
    float s = _shapeSize;
    float r = _shapeSize/2;
   	int numPoints = 6;
    float angleStep = TWO_PI/numPoints;
    
    for (int i = 0; i < numPoints; i++)
    {
    	ofPoint p(cos(angleStep*i)*r, sin(angleStep*i)*r);
        _polygon.addVertex(p);
    }
    
    _polygon.close();
}

void testApp::_createStar()
{
    float s = _shapeSize;
    float r = _shapeSize/2;
    float r2 = r/2;
   	int numPoints = 5;
    numPoints *= 2;
    float angleStep = TWO_PI/numPoints;
    
    _star.setStrokeColor(ofColor(255, 0, 0));
    _star.setFillColor(ofColor(255, 255, 255));
    _star.setStrokeWidth(20.0f);
    
    for (int i = 0; i < numPoints; i++)
    {
        float rad = i % 2 == 0 ? r2 : r;
        
        ofPoint p(cos(angleStep*i)*rad, sin(angleStep*i)*rad);
        _star.lineTo(p);
    }
    
    _star.close();
}


void testApp::_createCurvedPath ()
{
    _curvedPath.setFilled(false);
    _curvedPath.setStrokeColor(ofColor(255, 255, 255));
    _curvedPath.setStrokeWidth(20.0f);
    
    for (int i = 0; i < 20; i++)
    {
        float s = _shapeSize*1.5;
        float t = (i*100)/PI;
        ofPoint p = ofPoint(cos(t)*(sin(t*(cos(t)/PI))*s), sin(t)*(cos(t*(sin(t)/PI))*s));
        
        if (i == 0) _curvedPath.moveTo(p);
        else _curvedPath.curveTo(p);
    }
}

//--------------------------------------------------------------
void testApp::update()
{
    
}



//--------------------------------------------------------------
void testApp::draw()
{
	ofBackground(20);
    
    float w = _shapeSize;
    float s = 40.0f;
    float x = s;
    float y = s;
    
    ofSetColor(255, 0, 0);
    ofRect(x, y, 0, w, w);
    
    x += w + s;
    ofSetColor(ofFloatColor(0.0f, 0.0f, 1.0f));
    ofCircle(x + w/2, y + w/2, w/2);
    
    x += w + s;
    ofSetColor(ofFloatColor(0.0f, 1.0f, 0.0f));
    ofSetLineWidth(30.0f);
    ofLine(x + s, y + s, x + w - s, y + w - s);
    
    x += w + s;
    ofSetColor(ofFloatColor(1.0f, 0.0f, 1.0f));
    ofEllipse(x + w, y + w/2, w*2, w);
    
    x = s;
    y = s + w + s;
    
    ofSetLineWidth(20.0f);
    ofSetColor(0, 255, 255);
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_polygon.draw();
    ofPopMatrix();
    
    x += w + s;
    
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_star.draw();
    ofPopMatrix();
    
    x += w + w + s;
    y += w;
    
    ofPushMatrix();
    ofTranslate(x + (w/2), y + (w/2));
    	_curvedPath.draw();
    ofPopMatrix();
    
    ofSetColor(255, 255, 255);
    
    stringstream m;
    m << "FPS: " << (int)ofGetFrameRate();
    m << " | current renderer: ";
    m << (ofGetCurrentRenderer() == _defaultRenderer ? "DEFAULT" : "OFX_SHIVA_VG");
    m << " | click to toogle renderer";
    m << " | hit 'c' to toggle line-cap style";
    
    ofDrawBitmapString(m.str(), s, ofGetHeight() - s);
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button)
{
    cout << "change renderer" << endl;
    
    if (ofGetCurrentRenderer() == _defaultRenderer)
    {
        ofSetCurrentRenderer(_shivaVGRenderer);
    }
    else
    {
        ofSetCurrentRenderer(_defaultRenderer);
    }
}

//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
    if (key == 99) // c letter
{'fraction_non_alphanumeric': 0.23076923076923078, 'fraction_numerical': 0.031588686227861484, 'mean_word_length': 1.8036309744349759, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2096020', 'n_tokens_mistral': 2959, 'n_tokens_neox': 2804, 'n_words': 536}