Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Animation not showing

$
0
0

@Ha99 wrote:

Hello, I am new to OpenFrameworks. I have converted a processing sketch to OpenFrameworks. There is no errors however, the animation is not showing. Please Help Thanks!

code- header file

pragma once

include "ofMain.h"

class ofApp : public ofBaseApp{

public:
	void setup();
	void update();
	void draw();
void linePlot(int xPos, int yPos);

	void keyPressed(int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void mouseEntered(int x, int y);
	void mouseExited(int x, int y);
	void windowResized(int w, int h);
	void dragEvent(ofDragInfo dragInfo);
	void gotMessage(ofMessage msg);

int x;
int y;
float move;
int tol;
float fac;
int lineOpa;
int stroke;



//int xPos; int yPos;
float angle;
float mouseDist;

include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

move= 0.05;
lineOpa= 150;
stroke= 10;
tol= 50;
fac= 0.0125;

ofEnableSmoothing();
ofHideCursor();

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

//void linePlot(int xPos, int yPos);

ofBackground(255);
for (int i = 50; i< (ofGetWidth()-25); i += 25){
    for (int j= 50; j< ofGetHeight()-25; j +=25){
        ofMap(i, 0, 500, 0, 255), ofMap(j, 0, 500, 0, 255);
        linePlot(i,j);
    }

}

   void linePlot(int xPos, int yPos);

}

void ofApp::linePlot(int xPos, int yPos){

ofSetLineWidth(stroke);

ofPushMatrix();

ofTranslate(ofGetWidth()/2, ofGetHeight()/2); //xPos, yPos

angle= atan2(ofGetMouseX() - xPos, ofGetMouseY() - yPos);

mouseDist = ofDist(ofGetMouseX(), ofGetMouseY(), xPos, yPos);

ofRotate(angle - PI, 0, 0, 1);
//ofRotate(angle - PI);

if (ofDist(ofGetMouseX(), ofGetMouseY(), xPos, yPos)){
    ofDrawLine(0, 0, mouseDist, 0);
}
else{
    ofDrawLine(0, 0, tol/ (mouseDist * fac), 0);
}

ofPopMatrix();

}

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles