Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify method to 0.8.4 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions example/bin/data/quadwarp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<quadwarp>
<src>
<point x="0" y="0"/>
<point x="500" y="0"/>
<point x="500" y="300"/>
<point x="0" y="300"/>
</src>
<dst>
<point x="251" y="134"/>
<point x="692" y="119"/>
<point x="746" y="546"/>
<point x="309" y="584"/>
</dst>
</quadwarp>
2 changes: 2 additions & 0 deletions example/ofxQuadWarpExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_51)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_52)",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
PREBINDING = NO;
PRODUCT_NAME = ofxQuadWarpExampleDebug;
WRAPPER_EXTENSION = app;
Expand Down Expand Up @@ -988,6 +989,7 @@
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_50)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_51)",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
PREBINDING = NO;
PRODUCT_NAME = ofxQuadWarpExample;
WRAPPER_EXTENSION = app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@
<string>ofxQuadWarpExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>14B8AC792BB3E433FAB0B60E4B728B5F7967140B</key>
<string>github.com:julapy/ofxQuadWarp.git</string>
<key>7A1153F4-82DE-49F1-BC06-5BFDA0261534</key>
<string>https://github.com/julapy/ofxQuadWarp.git</string>
<key>C4622832-A4AC-476E-8C39-53A491E37455</key>
<string>https://github.com/julapy/openFrameworks.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>addons/ofxQuadWarp/example/ofxQuadWarpExample.xcodeproj/project.xcworkspace</string>
<string>example/ofxQuadWarpExample.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>7A1153F4-82DE-49F1-BC06-5BFDA0261534</key>
<key>14B8AC792BB3E433FAB0B60E4B728B5F7967140B</key>
<string>../../..</string>
<key>7A1153F4-82DE-49F1-BC06-5BFDA0261534</key>
<string>../../../..</string>
<key>C4622832-A4AC-476E-8C39-53A491E37455</key>
<string>../../../../..</string>
<string>../../../../openFrameworks</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/julapy/ofxQuadWarp.git</string>
<string>github.com:julapy/ofxQuadWarp.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>C4622832-A4AC-476E-8C39-53A491E37455</string>
<string>14B8AC792BB3E433FAB0B60E4B728B5F7967140B</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
Expand All @@ -38,6 +42,14 @@
<key>IDESourceControlWCCIdentifierKey</key>
<string>7A1153F4-82DE-49F1-BC06-5BFDA0261534</string>
<key>IDESourceControlWCCName</key>
<string></string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>14B8AC792BB3E433FAB0B60E4B728B5F7967140B</string>
<key>IDESourceControlWCCName</key>
<string>ofxQuadWarp</string>
</dict>
<dict>
Expand Down
58 changes: 30 additions & 28 deletions example/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ void ofApp::setup() {
//--------------------------------------------------------------
void ofApp::update()
{
if(ofGetFrameNum() % 5 != 0) {
// only update every 5 frames.
return;
}
// if(ofGetFrameNum() % 5 != 0) {
// // only update every 5 frames.
// return;
// }
//
// for(int i=0; i<10; i++) {
// // randomise points over the image area.
// points[i].x = ofRandom(img.width);
// points[i].y = ofRandom(img.height);
// }

for(int i=0; i<10; i++) {
// randomise points over the image area.
points[i].x = ofRandom(img.width);
points[i].y = ofRandom(img.height);
}
fbo.begin();
img.draw(0, 0);
fbo.end();
}

//--------------------------------------------------------------
Expand All @@ -46,9 +50,7 @@ void ofApp::draw() {

//======================== draw image into fbo.

fbo.begin();
img.draw(0, 0);
fbo.end();


//======================== get our quad warp matrix.

Expand All @@ -63,17 +65,17 @@ void ofApp::draw() {

//======================== use the matrix to transform points.

ofSetLineWidth(2);
ofSetColor(ofColor::cyan);

for(int i=0; i<9; i++) {
int j = i + 1;

ofVec3f p1 = mat.preMult(ofVec3f(points[i].x, points[i].y, 0));
ofVec3f p2 = mat.preMult(ofVec3f(points[j].x, points[j].y, 0));

ofDrawLine(p1.x, p1.y, p2.x, p2.y);
}
// ofSetLineWidth(2);
// ofSetColor(ofColor::cyan);
//
// for(int i=0; i<9; i++) {
// int j = i + 1;
//
// ofVec3f p1 = mat.preMult(ofVec3f(points[i].x, points[i].y, 0));
// ofVec3f p2 = mat.preMult(ofVec3f(points[j].x, points[j].y, 0));
//
// ofLine(p1.x, p1.y, p2.x, p2.y);
// }

//======================== draw quad warp ui.

Expand All @@ -91,11 +93,11 @@ void ofApp::draw() {

//======================== info.

ofSetColor(ofColor::white);
ofDrawBitmapString("to warp the image, drag the corners of the image.", 20, 30);
ofDrawBitmapString("press 's' to toggle quad warp UI. this will also disable quad warp interaction.", 20, 50);
ofDrawBitmapString("press & hold 1, 2, 3, 4 to snap that point to the mouse", 20, 70);
ofDrawBitmapString("when a corner is selected (red), use keyboard arrow keys to nudge the corner position.", 20, 90);
// ofSetColor(ofColor::white);
// ofDrawBitmapString("to warp the image, drag the corners of the image.", 20, 30);
// ofDrawBitmapString("press 's' to toggle quad warp UI. this will also disable quad warp interaction.", 20, 50);
// ofDrawBitmapString("press & hold 1, 2, 3, 4 to snap that point to the mouse", 20, 70);
// ofDrawBitmapString("when a corner is selected (red), use keyboard arrow keys to nudge the corner position.", 20, 90);
}

void ofApp::exit() {
Expand Down
4 changes: 2 additions & 2 deletions src/ofxQuadWarp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void ofxQuadWarp::drawQuadOutline() {

for(int i=0; i<4; i++) {
int j = (i+1) % 4;
ofDrawLine(dstPoints[i].x + position.x,
ofLine(dstPoints[i].x + position.x,
dstPoints[i].y + position.y,
dstPoints[j].x + position.x,
dstPoints[j].y + position.y);
Expand Down Expand Up @@ -547,7 +547,7 @@ void ofxQuadWarp::drawSelectedCorner() {
}

void ofxQuadWarp::drawCornerAt(const ofPoint & point) {
ofDrawRectangle(point.x + position.x - anchorSizeHalf,
ofRect(point.x + position.x - anchorSizeHalf,
point.y + position.y - anchorSizeHalf,
anchorSize, anchorSize);
}