From: Daniel T. <de...@ti...> - 2003-09-29 14:35:04
|
Hi Brian! I am currently working on a "stacker" that reacts on layer resizing. Its a function that works with the x,y,h,w of the layers added. If you have layer 1 and layer2 and they are exacltly 5 pixels space between them, if you resize layer 1 so the space is say 15 pixels between them, layers 2 will be moved so its still 5 pixels between them. But with movement this one is not the option, this is just for sizing, however you should have a look at the groupmanager example who deals with positions, i dont know if thats the thing you are looking for but it might help you out. Regards Daniel -----Original Message----- From: dyn...@li... [mailto:dyn...@li...] On Behalf Of Brian Hayes Sent: den 28 september 2003 16:54 To: dyn...@li... Subject: [Dynapi-Help] Setting the scale for one object based on another. Hello everyone, I have been at this for about (well all night) and I seem to be missing something... What am I trying? Well, When one layer grows, I need another layer to shring accourdingly.. Plus, if I move one layer I need to other layer to move accourdingly.. Everything I have tried seems to be close, but not there... Not to mention looking at the code in scrollbar.js, but being a little week in math?? Well, lets say its not my cup of tee.. Please help... example: ViewWin is my larger Window and ScaleViewerContainer is my smaller window.. The two objects that need to interact are ViewLyr[lyrid] where lyrid is the layer in focus (larger) and ScaleViewer the smaller one. -Both of the obove are contained in there parent layers ViewWin -> ViewLyr[lyrid] and ScaleViewerContainer -> ScaleViewer.. this.rh = this.ViewWin.getHeight()/this.ScaleViewer.getHeight(); //ratio this.rw = this.ViewWin.getWidth()/this.ScaleViewer.getWidth(); this.sw =(this.ViewLyr[lyrid].getWidth() - (this.ScaleViewer.getWidth()/this.rw))/this.rw; this.sh =(this.ViewLyr[lyrid].getHeight() - (this.ScaleViewer.getHeight()/this.rh))/this.rh; this.nh = this.ScaleViewerContainer.getHeight() - (this.sh-this.ScaleViewer.getHeight()); this.nw = this.ScaleViewerContainer.getWidth() - (this.sw-this.ScaleViewer.getWidth()); //this.rh = this.ViewWin.h/this.ScaleViewerContainer.h; //ratio //this.rw = this.ViewWin.w/this.ScaleViewerContainer.w; this.rx = (this.ViewLyr[lyrid].getX()*-1)/this.rw; this.ry = (this.ViewLyr[lyrid].getY()*-1)/this.rh; this.ScaleViewer.setSize(this.nw,this.nh); this.ScaleViewer.setLocation((this.rx/this.rw),(this.ry/this.rh)); Thanks, Brian Hayes |