<commit_before>//
//  poShape.cpp
//  BasicScene
//
//  Created by <NAME> on 3/19/14.
//
//
#include "cinder/TriMesh.h"
#include "cinder/Triangulate.h"
#include "cinder/gl/Texture.h"

#include "poShape.h"

namespace po {
    #pragma mark - Create -
    
    ShapeRef Shape::create()
    {
        return std::shared_ptr<Shape>(new Shape());
    }
    
    
    //Rect
    ShapeRef Shape::createRect(float width, float height)
    {
        std::shared_ptr<Shape> s = std::shared_ptr<Shape>(new Shape());
        
        ci::Shape2d shape;
        
        shape.moveTo(0,0);
        shape.lineTo(width,0);
        shape.lineTo(width,height);
        shape.lineTo(0,height);
        shape.close();
        
        s->setCiShape2d(shape);
        s->render();
        
        return s;
    }
    
    ShapeRef Shape::createRect(float size)
    {
        return createRect(size, size);
    }
    
    ShapeRef Shape::createRect(ci::gl::TextureRef texture)
    {
        
        std::shared_ptr<Shape> s = Shape::createRect(texture->getWidth(), texture->getHeight());
        s->mTexture = texture;
        s->render();
        
        return s;
    }
    
    //Ellipse
    ShapeRef Shape::createEllipse(float width, float height)
    {
        std::shared_ptr<Shape> s = std::shared_ptr<Shape>(new Shape());
        
        //Adapted from http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
        float kappa = .5522848;
        float x = 0;
        float y = 0;
        float ox = (width / 2) * kappa; // control point offset horizontal
        float oy = (height / 2) * kappa; // control point offset vertical
        float xe = x + width;           // x-end
        float ye = y + height;           // y-end
        float xm = x + width / 2;       // x-middle
        float ym = y + height / 2;       // y-middle
        
        ci::Shape2d shape;
        
        shape.moveTo(x, height/2);
        shape.curveTo(x, ym-oy, xm - ox, y, xm, y);
        shape.curveTo(xm + ox, y, xe, ym - oy, xe, ym);
        shape.curveTo(xe, ym + oy, xm + ox, ye, xm, ye);
        shape.curveTo(xm - ox, ye, x, ym + oy, x, ym);
        shape.close();
        
        s->setCiShape2d(shape);
        s->render();

        return s;
    }
    
    ShapeRef Shape::createEllipse(float size)
    {
        return createEllipse(size, size);
    }
    
    
    #pragma mark - Shape -
    Shape::Shape()
    :   mFillColor(255,255,255)
    ,   mFillEnabled(true)
    ,   mStrokeColor(255,255,255)
    ,   mStrokeEnabled(false)
    ,   mPrecision(100)
    ,   mTextureFit(TextureFit::NONE)
    ,   mTextureAlignment(Alignment::TOP_LEFT)
    {
    }
    
    Shape::~Shape() {}
    
    #pragma mark - ci::Shape2d -
    void Shape::setCiShape2d(ci::Shape2d shape)
    {
        mCiShape2d = shape;
        render();
    }
    
    #pragma mark - Drawing -
    void Shape::draw()
    {
        //Draw fill
        if(mFillEnabled) {
            ci::gl::color(mFillColor);
            
            ci::gl::enable( GL_TEXTURE_2D );
            mTexture->enableAndBind();
            ci::gl::draw(mVboMesh);
            if(mTexture) mTexture->disable();
            //ci::gl::drawSolid(ciShape2d);
        }
        
        //Draw stroke
        #pragma message "Need to implement better stroke stuff"
        if(mStrokeEnabled) {
            ci::gl::color(mStrokeColor);
            ci::gl::draw(mCiShape2d, ci::app::getWindowContentScale());<commit_msg>Checking for texture before binding, was disabled for testing<commit_after>//
//  poShape.cpp
//  BasicScene
//
//  Created by <NAME> on 3/19/14.
//
//
#include "cinder/TriMesh.h"
#include "cinder/Triangulate.h"
#include "cinder/gl/Texture.h"

#include "poShape.h"

namespace po {
    #pragma mark - Create -
    
    ShapeRef Shape::create()
    {
        return std::shared_ptr<Shape>(new Shape());
    }
    
    
    //Rect
    ShapeRef Shape::createRect(float width, float height)
    {
        std::shared_ptr<Shape> s = std::shared_ptr<Shape>(new Shape());
        
        ci::Shape2d shape;
        
        shape.moveTo(0,0);
        shape.lineTo(width,0);
        shape.lineTo(width,height);
        shape.lineTo(0,height);
        shape.close();
        
        s->setCiShape2d(shape);
        s->render();
        
        return s;
    }
    
    ShapeRef Shape::createRect(float size)
    {
        return createRect(size, size);
    }
    
    ShapeRef Shape::createRect(ci::gl::TextureRef texture)
    {
        
        std::shared_ptr<Shape> s = Shape::createRect(texture->getWidth(), texture->getHeight());
        s->mTexture = texture;
        s->render();
        
        return s;
    }
    
    //Ellipse
    ShapeRef Shape::createEllipse(float width, float height)
    {
        std::shared_ptr<Shape> s = std::shared_ptr<Shape>(new Shape());
        
        //Adapted from http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
        float kappa = .5522848;
        float x = 0;
        float y = 0;
        float ox = (width / 2) * kappa; // control point offset horizontal
        float oy = (height / 2) * kappa; // control point offset vertical
        float xe = x + width;           // x-end
        float ye = y + height;           // y-end
        float xm = x + width / 2;       // x-middle
        float ym = y + height / 2;       // y-middle
        
        ci::Shape2d shape;
        
        shape.moveTo(x, height/2);
        shape.curveTo(x, ym-oy, xm - ox, y, xm, y);
        shape.curveTo(xm + ox, y, xe, ym - oy, xe, ym);
        shape.curveTo(xe, ym + oy, xm + ox, ye, xm, ye);
        shape.curveTo(xm - ox, ye, x, ym + oy, x, ym);
        shape.close();
        
        s->setCiShape2d(shape);
        s->render();

        return s;
    }
    
    ShapeRef Shape::createEllipse(float size)
    {
        return createEllipse(size, size);
    }
    
    
    #pragma mark - Shape -
    Shape::Shape()
    :   mFillColor(255,255,255)
    ,   mFillEnabled(true)
    ,   mStrokeColor(255,255,255)
    ,   mStrokeEnabled(false)
    ,   mPrecision(100)
    ,   mTextureFit(TextureFit::NONE)
    ,   mTextureAlignment(Alignment::TOP_LEFT)
    {
    }
    
    Shape::~Shape() {}
    
    #pragma mark - ci::Shape2d -
    void Shape::setCiShape2d(ci::Shape2d shape)
    {
        mCiShape2d = shape;
        render();
    }
    
    #pragma mark - Drawing -
    void Shape::draw()
    {
        //Draw fill
        if(mFillEnabled) {
            ci::gl::color(mFillColor);
        
            if(mTexture) mTexture->enableAndBind();
            ci::gl::draw(mVboMesh);
            if(mTexture) mTexture->disable();
        }
        
        //Draw stroke
        #pragma message "Need to implement better stroke stuff"
        if(mStrokeEnabled) {
            ci::gl::color(mStrokeColor);
            ci::gl::draw(mCiShape2d, ci::app::getWindowContentScale());
{'fraction_non_alphanumeric': 0.13898550724637682, 'fraction_numerical': 0.017971014492753623, 'mean_word_length': 1.7692616372391654, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, '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': '5251454', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2287, 'n_words': 453}