Skip to content

Commit

Permalink
added ofx2DCanvasTransformSync class. still needs some extra helper f…
Browse files Browse the repository at this point in the history
…unctions, and examples but it works
  • Loading branch information
roymacdonald committed May 19, 2024
1 parent 5d6ec77 commit 67691a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Renderers/ofx2DCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
#include "glm/mat4x4.hpp"


ofx2DCanvasTransformSync::ofx2DCanvasTransformSync(ofx2DCanvas* _owner , ofx2DCanvas* _other ):owner(_owner), other(_other)
{
if(owner && other && owner != other){
listeners.push(owner->onTransformBegin.newListener(this, &ofx2DCanvasTransformSync::onTransformUpdate) );
listeners.push(owner->onTransformUpdate.newListener(this, &ofx2DCanvasTransformSync::onTransformUpdate) );
}
}

void ofx2DCanvasTransformSync::onTransformUpdate(){
auto & oc = owner->getCamera();
auto & c = other->getCamera();
c.setPosition(oc.getPosition());
c.setScale(oc.getScale());

}


ofx2DCanvas::ofx2DCanvas(){

{
Expand Down
17 changes: 17 additions & 0 deletions src/Renderers/ofx2DCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
#pragma once
#include "ofMain.h"

class ofx2DCanvas;

class ofx2DCanvasTransformSync{
public:
ofx2DCanvasTransformSync(ofx2DCanvas* _owner, ofx2DCanvas* _other );

void onTransformUpdate();



ofEventListeners listeners;

ofx2DCanvas* owner = nullptr;
ofx2DCanvas* other = nullptr;

};


class ofx2DCanvas{
public:
Expand Down

0 comments on commit 67691a4

Please sign in to comment.