#include "ofxTextureEditor.h" ofxTextureEditor::ofxTextureEditor() { clear(); } ofxTextureEditor::~ofxTextureEditor() { clear(); } void ofxTextureEditor::draw() { if (surface == NULL) return; drawJoints(); } void ofxTextureEditor::drawJoints() { for ( int i=0; idraw(); } } void ofxTextureEditor::setSurface(ofxBaseSurface* newSurface) { surface = newSurface; createJoints(); } void ofxTextureEditor::clear() { surface = NULL; clearJoints(); } void ofxTextureEditor::createJoints() { if ( surface == NULL ) return; clearJoints(); vector& texCoords = surface->getTexCoords(); ofVec2f textureSize = ofVec2f(surface->getTexture()->getWidth(), surface->getTexture()->getHeight()); for ( int i=0; iposition = texCoords[i] * textureSize; } } void ofxTextureEditor::clearJoints() { while ( joints.size() ) { delete joints.back(); joints.pop_back(); } } void ofxTextureEditor::moveTexCoords(ofVec2f by) { if ( surface == NULL ) return; vector& texCoords = surface->getTexCoords(); ofVec2f textureSize = ofVec2f( surface->getTexture()->getWidth(), surface->getTexture()->getHeight() ); for (int i=0; iposition += by; texCoords[i] = joints[i]->position / textureSize; } }