Find Bounds Of Contiguous Transparent Pixels
I have the need to find the largest rectangle of ONLY transparent pixels in a transparent PNG. The transparent region is non-rectangular, so getColorBoundsRect returns a rectangle that also contains non-transparent pixels. Is there a way I can check for a rectangle that contains only the color I set?
Adobe > Flash General Discussion
Posted on: 09/29/2008 11:28:38 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting Bounds For An Mc (using Pixels...y = 300 Etc)
What I wanted to know is how I would be able to make it so that a certain mc could go no higher than say 300 pixels vertically. I know there's a way to limit movement that way but I'm not sure how to put it. My scenario is basically this: I have a character which is moved with the arrow keys, he has vertical and horizontal movement but I don't want him to be able to go any higher than about 300 otherwise it looks like he's walking on the walls .
Thanks,
Fargate
Setting Bounds For An Mc (using Pixels...y = 300 Etc)
What I wanted to know is how I would be able to make it so that a certain mc could go no higher than say 300 pixels vertically. I know there's a way to limit movement that way but I'm not sure how to put it. My scenario is basically this: I have a character which is moved with the arrow keys, he has vertical and horizontal movement but I don't want him to be able to go any higher than about 300 otherwise it looks like he's walking on the walls .
Thanks,
Fargate
Can AS Find Pixels By Color?
In another scripting language I have used for other purposes (AutoIt Script) there was a function called pixelSearch where you could find pixel locations based on a color.
What I would like to do is develop a SWF that "reads" the colors of an image and applies a sparkle effect to the areas that are deemed bright enough (close enough to #ffffff). Ultimately, it would be really cool if I could make it figure out how large the bright area was to make a larger sparkle effect (increase size of sparkle MC) or that if it was too bright, it would assume it was background and not use the effect in that location.
This effect would be used to load various thumbnails from a database and render them in the browser, each with the same SWF but different image parameters, to make the images sparkle appropriately.
Any ideas on this one?
Thanks,
99ways
Use GIF With Transparent Pixels...
Hi,
I imported into my Library a gif with some transparent pixels.
basically this gif represents a frozen frame and i would like to see
thru like if user was watching thru frozen window.
however, when i convert it to symbol, the transparent pixels are turned
to non-transparent.
how can i do to use transparent pizel under CS3/AS3 ?
thanks a lot,
RAF
Make Pixels Transparent
i have a ractangle bitmap, and want to make it's four corner pixels transparent. so that it looks like the border has been cured and the corner is transparent.
how to do that using as2.0? thanks!
Mouse Ignore Transparent Pixels?
I have a bitmap on stage that I create by downloading a png (with transparency) cloning its bitmapData. This bitmap is then placed inside a Sprite so I can interact with it using Mouse Events. I am interested in having the user interact with it using the mouse, but I want the mouse to only detect events such as PRESS and ROLL_OVER on the pixels that are not transparent. Or, to say it another way, I want the mouse events to ignore the completely transparent pixels when detecting a hit on the object. Does anyone know if there is a built in method to do this? Or, if not, any ideas on implementing it?
Thanks for your thoughts!
BitMaps, Remove Transparent Pixels
Hi guys,
Iv created an app in work which needs a rubber. I basicly have a tool to draw line (paint/pencil). This draws over the entire stage area, including over buttons and interactive mc's. Once i draw the line i then want to be able to erase bit of it.
To this end iv made an eraser tool, which works well. I turn the line into a bitmap, then turn the eraser line into a bitmap and use BlendMode.ERASE to erase one from the other. My problem is, because when creating the bitmatdata i have to create a rectangular shape, the area created then means that i cant access any of the buttons underneath.
here is my code:
ActionScript Code:
//line array is an area of all the line objects which are currently live on stage.
for(var i=0; i<lineAr.length; i++){
//MainTimeLine.StageWidth & MainTimeLine.StageHeight refare to the stage size, but this size alters during the app thus the variable
var delBitMap:BitmapData = new BitmapData(MainTimeLine.StageWidth,MainTimeLine.StageHeight, true, 0);
delBitMap.draw(lineAr[i],null,null,BlendMode.LAYER);
delBitMap.draw( currentRubber, null, null, BlendMode.ERASE );
var bmp1:Bitmap = new Bitmap(delBitMap);
//removes the line currently in the holder
MovieClip(lineAr[i]).removeChild(MovieClip(lineAr[i]).getChildAt(0));
//adds the new line to the holder (line is added to holder as the holder contains interaction, startDrags etc)
MovieClip(lineAr[i]).addChild(bmp1);
}
The way i see it i need to remove the transparent pixels from delBitMap once the erase has been done. Is this possible, or is there any other way i could go about doing this?
thanks in advance for any assistance,
Roamer
Setting All Bitmapdata Pixels Transparent
Hi
i've got a bitmapdata "bmp"
already transparent, already created
i am loading a sequence of pngs with an alpha channel into it
after the new png is loaded i want to ERASE the contents of bitmap
and draw the new png so the images do not accumulate....
floodfill method is not working,
//SET TRANSPARENT (not working)
bmp.floodFill(0, 0, 0x00000000);
//REDRAW
bmp.draw(target_mc)
all help appreciated,
jhave
How Do I Find The Dimensions Of A Child Clip, In Global Pixels?
So with localToGlobal, you can get a nested coordinates' position on the global stage...I'm looking for the equivalent of that in terms of pixel width and height.
What I have is a child clip within a container clip. When I scale the parent clip, how do I find what the actual pixel size of the child clip is? My trace statements tell me that the child clip's _width and _height properties don't change, just as their _x and _y don't change.
How To Make .swf File Transparent So Webpage Shows Through? I Cant Find The Old Topic
i need ot know how to make .swf files transparent so my background image on my webpage shows through the .swf file instead of it being white. i know i read how to do this somewhere on this site but i cant find it now and the forum/tutorial searches didnt come up with anything. thanks for helping or pointing me to the old thread. i appreciate it
tyr
How To Make .swf File Transparent So Webpage Shows Through? I Cant Find The Old Topic
i need ot know how to make .swf files transparent so my background image on my webpage shows through the .swf file instead of it being white. i know i read how to do this somewhere on this site but i cant find it now and the forum/tutorial searches didnt come up with anything. thanks for helping or pointing me to the old thread. i appreciate it
tyr
FlashMX Pixels Vs Photoshop Pixels?
In creating an animated Flash banner using a JPG graphic created in Photoshop 7, I set the flash document size to match the size of the backround graphic. According to PS 7, the image size is 503x90 pixels. This should fit exactly into a Flash document sized 503x90... yet when I bring the image into Flash, the image is about 2pix x 2pix smaller than the flash doc... this throws a border which causes the other images in the web page to not line up correctly.
Is this a known problem? Why doesn't Flash 503pix X 90 pix match with Photoshop's 503x90?
Thanks for your help.
steve
Get Bounds
hey pplz, is get bounds used for games????
coz i want to know how to make it so that when my character moves over a hill he will go over the hill and walk up a little, if u know wot i mean.
also , this has no relation lol , how duz Xiao Xiao make it so that when u push that button, it slows the frame rate and it goes in slow motion ( XIAO XIAO 3 )
thanx pplz
Skribble
_______________________________
www.skribblinteractive.tk
Out Of Bounds?
Hello... If a user drags a piece off the screen my program goes crazy.
www.enjoychess.com. Grab a piece and take it all the way to the edge of the screen and you will see what I mean.
I have event handlers and boundaries set and they work, but when the user takes the piece all the way to edge it goes nuts.
Any idea? Thanks!!
I am using flash mx 2004 pro
ANDY
Bounds
Hello,
I have a big problem in my game. I can not make bounds! In a way I can but not in this case. The problem that it's the background that is moving, not the car. So I would really appreciate if someone could explain me how to do it.
Thanks.
Here is the script I put on the background (the car is called "bil") :
onClipEvent (load) {
speed = 8;
}
onClipEvent (enterFrame) {
if (key.isdown(key.LEFT)) {
_x += speed;
}
if (key.isdown(key.RIGHT)) {
_x -= speed;
}
if (key.isdown(key.DOWN)) {
_y -= speed;
}
if (key.isdown(key.UP)) {
_y += speed;
}
}
onClipEvent (enterFrame) {
if (_root.bil.hitTest(_root.Wall4) or _root.bil.hitTest(_root.wall5) or _root.bil.hitTest(_root.wall6) or _root.bil.hitTest(_root.wall7) or _root.bil.hitTest(_root.wall8) or _root.bil.hitTest(_root.wall9) or _root.bil.hitTest(_root.wall10) or _root.bil.hitTest(_root.wall11) or _root.bil.hitTest(_root.wall12)) {
speed = 0.1;
} else {
speed = 8;
}
}
And this one on the car :
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation = 90;
}
if (Key.isDown(Key.LEFT)) {
_rotation = 270;
}
if (Key.isDown(Key.UP)) {
_rotation = 0;
}
if (Key.isDown(Key.DOWN)) {
_rotation = 180;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
_rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
_rotation = 225;
}
}
Scrolling Bounds >?
hey ,
i have a mc called pic ,i am tring to have it appear at the _x pos when it scrolls out of the 300 width area to start over again ..
here is what i have for the arrow keys ..
*********i didnt add any of the code examples for the _x pos ..but the stage is 300x50
Code:
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 37) {
picture._x -= 2;
}
};
Key.addListener(myListener);
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 39) {
picture._x += 2;
}
};
Key.addListener(myListener);
cheers ..
Bounds For DraGging
Does anyone know how to create bounderies for a dragable object, so when the side of it gets to the bounderies it stops moving on either the X or Y axis depending on where ti hits?
thanks in advance
-Stwelin
[F8] Get Bounds - Whole Screen
I remember reading this code somewhere but now I canīt remeber or find it. If You want to have the "get Bounds" from the whole screen. So if You have a swf with many drag-objects. So the user doesnīt by accident drag something outside the screen and canīt find it again.
Bounds:Object
Hi
I need to check the bound of a rotating object. The code below has two versions: A) rotates the block itself and B) rotates a block within the movieClip. Only B works but for the purposes of my game I need A to work.
I've attached the test app.
Code:
var bounds:Object;
function rotationControl(evt:Event):void {
// A
this.testBlock.rotation += 5
//
bounds = this.testBlock.getBounds(this.testBlock);
this.guideLine1.x = this.testBlock.x + bounds.x;
this.guideLine2.x = this.testBlock.x + bounds.x + bounds.width;
// B
this.testBlockB.block_gr.rotation += 5
//
bounds = this.testBlockB.getBounds(this.testBlock.block_gr);
this.guideLine3.x = this.testBlockB.x + bounds.x;
this.guideLine4.x = this.testBlockB.x + bounds.x + bounds.width;
}
this.addEventListener(Event.ENTER_FRAME, rotationControl);
Thanks
[CS3] Scaling With Bounds
Hey all, I'm trying to create a function to zoom/in out on a map with bounds using a scrubber. Was wondering if anyone has ever run into a similar situation/solution. What I have so far doesn't seem to quite work:
PHP Code:
function onZoomAdjust(pct:Number):void {
var cx = stage.stageWidth/2 - map.x //determine center point of map on x
var cy = stage.stageHeight/2 - map.y
scale = maxScale * pct + minScale //new scale pct based on slider
var tx = (cx * scale)/2 //translation of x
var ty = (cy * scale)/2
map.x = tx;
map.y = ty;
map.scaleX = map.scaleY = scale
}
It gets me pretty close but there's no control to stop the user from zooming out of bounds. Is this the sort of thing I need to use a matrix for?
Thanks
Bounds In Flash?
i have a "circle_mc" movie clip and its registratoin is in the center but it moves and works fine but i dont want it to go off the stage half way i want it to stop before it goes off
anyone?
ActionScript Code:
circle_mc.onRollOver = function() {
this.dx = Math.round(Math.random()*Stage.width);
this.dy = Math.round(Math.random()*Stage.height);
this.onEnterFrame = moveIt;
};
function moveIt() {
this._x += (this.dx-this._x)/10;
this._y += (this.dy-this._y)/10;
if (Math.round(this._x) == this.dx) {
this._x = this.dx;
}
}
-aldo
StartDrag Bounds
So I'm doing what I would normally do in AS 2 and it's not working. On press of my clip I am getting
Code:
Argument count mismatch on flash.display::Sprite/startDrag(). Expected 0, got 6;
Live docs don't have an example on how to set bounds.
Does startDrag not take any parameters?
Any links or anything?
TIA
Expand Out Of Bounds
Given a flash file with dimensions, like 300x400 embedded on an xhtml page, is there a way to allow the content to spill out of the box and over other elements? Ive seen this done on ads, but I want to use it for a navigation. Does anyone know how they do it?
Expanding Beyond The Bounds...
I'm attempting to do some Rich Media design, and have run into a snag. I have a banner (768x90) that will expand once hovered over. Best example I've run into is something like THIS where it expands from the 90 high to about 270 total. There's a lot of other examples at PointRoll under the FatBoy category.
I need help on how to get the additional content to display outside of the original Flash file. It appears as though it's all one file, the 'bounds' of the stage simply expand to accomodate it, but I can't figure out exactly how to get this done.
Thanks in advance.
Mouse Bounds
I currently have a Nav that I am working on that will follow the mouse's _y position. I am wanting to have bounds set that keep the nav in between certain top _y and bottom _y, but am lost on how to do it.
I have tried applying the same techniques that I would to create bounds for a Dragging menu (define top and bottom bounds) but it didn't work with the mouse position.
Here is the code so far that makes the menu follow the mouse:
speed = 25;
menu_mc.onEnterFrame = function () {
target_y = _root._ymouse - this._y;
this._y = this._y + (target_y/speed);
}
Any help would be appreciated.
Thanks,
--
Michael
Change Scroller Bounds?
Hey guys I found this code that uses duplicate clips and xml to have a gallery, but I need to change the bounds of the scroller (the amount showing at one time) to make it wider. Here are the following movieclips and their script.
Thanks,
Eric Ehle
bb:
while (i < Laenge) {
a1.duplicateMovieClip("a" + i, i);
a = this["a" + i];
a._x = 6 + (123 * i);
a._y = 150;
i++;
dragger:
if (_root._xmouse < 465) {
startDrag ("_root.dragCTRL", true, 25, 0, 465, 282);
} else {
stopDrag();
}
dragCTRL:
var slidePercent = int (((_level0.dragCTRL._x - 25) * 100) / 440);
newX = int (((((_level0.bb.Laenge * 123) - (435 + (20 / (_level0.bb.Laenge / 2)))) / 100) * slidePercent) * -1);
_level0.bb._x = _level0.bb._x + ((newX - _level0.bb._x) / 10);
Laenge = codeArray.length;
Constraining Mouse OUTSIDE Bounds
Hi all,
Im creating a simple FLASH, shooting game, and trying to implement some
actionscript which constrains where the user can move the mouse.
As an example. Imagine a blank stage, with medium sized rectangle in the
middle. I want the user to be able to position/move their mouse anywhere
around the rectangle, but being unable to position the mouse within the
rectangle.
Basically, i want to contrain the bounds of the mouse OUTSIDE the rectangle.
(constraining the mouse within the rectangle is easy)
If someone could post the code, or point me to an online example i would be
most grateful
Cheers
Paul
Help Me Solve A Problem Bounds Of MC
Hi all,
Goh, im stuck.
I am trying to get the width and height of a movie clip, disregarding the rotation.
Here is my problem.
I have a MC called "canvas" which holds a few other MCs called "layer1", "layer2", etc.
These layer MCs can be streched, rotated, etc via buttons. If they are rotated or streched, i want to get their new widths.
The problem is, i do not get the right values once i rotate the MC. I figured it wa because flash was going off of the bounding box of the layerMC so i tried the getBounds method and this also only returns the correct value if the MC has not been rotated. How would i get the stage width, stage height of a MC regardless of its rotation. As in if its a rectangle 10x100 pixels, and i rotate it 90 degrees, it should be 100x10 respectivly. So far the only thing that causes problems is the rotation of the MC, scaling returns correct values.
Also, the CANVAS movie clip also gets scaled (zoomed in) though that has not been much of an issue thus far, it may be causing the wrong values.
Any ideas? PLZ HELP!
[F8] Bounds Of Movie, Stop Car
I want the car not to go off stage basically. I doubt im doing this right at all:
var stage.Width = sw
var stage.Height = sh
if ((this._x>sw) || (this._y>sh)){
_root.object.objectspeed *= -1
}
do I need some math in there somewhere?
Modifying The Bounds Of A Clip
I have a big movieclip but I just want to show a little peace of this movieclip. So I mask it with another movieclip with rectangles drawn in it and blendmode "alpha". The problem is that the rest of the clip (the masked part) is just then considered with _alpha=0; so actionscript always consider this clip as the whole big movieclip and it takes time to draw it on the screen.
So is it possible to really change (decrease) the bounds of a movieclip?
AS 3 Random Motion Within Bounds
Ok,
I have a script that produces random motion along the y axis, however, I want that motion to occur within the movie clip that is centered on the stage, or I should say within the bounds of that movie clip.
The movie clip has a height of 335 px
Here is the code:
Code:
var xTween:Tween;
var yTween:Tween;
startTween();
function startTween(e:TweenEvent = null):void {
yTween = new Tween(box, "y", Elastic.easeInOut, box.y, Math.random()*300, 2, true);
yTween.addEventListener(TweenEvent.MOTION_FINISH,startTween);
}
any help is appreciated
Thank you
-D
Constraining Motion/bounds
Hello.
I'm trying to solve a problem I have. Imagine you have a series of handles sat on a horizontal plane, they can be moved left to right...
___/\_____X_____/\_X_/\___X____/\___________
The X amounts are driven by the distance between the two points, simple. Now, when the objects move the distance shrinks, also simple...
___/\__X__/\_X__/\___X____/\________________
Now, what I want to be able to do is move the first triangle (well, any one but the first for this example) to the right, beyond the point where the second or third objects are. I want it to push those objects along as I move it, then when I drag it back it leaves them there. I then want to be able to drag the second object to the left, where it will 'hit' and push the first object out of the way.
In 3D I'd call this 'bi-directional constraints', I'm not familiar how to do it in AS3.
Any help would be great.
A.
Control Bounds Of Sliding Mc
I have this script attached to a mc (see below) that makes the mc slide across the x-axis. That part works great, but I only want the mc to go so far to the right and I don't want the mc to move when you are not over the mc (ie. anywhere else on the stage). Does anyone have any suggestions as to what I can add to this script to control that or do I need a different script? Any help would be appreciated.
onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/5;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
}
Help Me... Its The Bounds And Grass (:P) There Is The Problem
Hello my fellows!
I have a problem with bounds. I have seen HERE and when the blue stick brother there goes into grass he can not just walk over it. What AS should I write to do the same thing.
I need bounds that also work with a moving background.
Thanks
Finding The Bounds Of A Movieclip
Version: Flash CS3, AS3
Is there a way to find the bounds (width&height) of a single-frame movieclip in a way that disregards surrounding whitespace?
ie. if a movieclip contains only a 10x10 square at point 5,5 (within the movieclip), width&height is normally returned as 15x15. I want a way to have 10x10 returned.
Flash seems to know of such bounds - the graphic displayed in the library sidebar is set to this size. So are they accessible via AS3?
Thanks
Rick
Calculating Perimeter - Bounds
Hi,
Here is the task simplified:
You have a grid on which you place boxes that snap together,
all boxes have to touch each other, once you finish you click
i finished and it ouputs the bound measures.
How would one get those measures?
Thank you!
tamagorci
Setting Bounds With HitTest
Ok this problem is really starting to get annoying
ActionScript Code:
onClipEvent (enterFrame) { if (_root.line.circle.dot.hitTest(_root.mc)) { _root.gotoAndStop("end"); }}
That hittest performs when the two blue edgings around the two objects intersect. So it hittests just a little before it's supposed to. What I need to know and can't figure out is how to get it to Hit test when the actual objects interesect and not their borders.Thanks in advance .
Setting Bounds With HitTest
Ok this problem is really starting to get annoying
ActionScript Code:
onClipEvent (enterFrame) { if (_root.line.circle.dot.hitTest(_root.mc)) { _root.gotoAndStop("end"); }}
That hittest performs when the two blue edgings around the two objects intersect. So it hittests just a little before it's supposed to. What I need to know and can't figure out is how to get it to Hit test when the actual objects interesect and not their borders.Thanks in advance .
Set Bounds For Window Component
I have a window component in MX2004 Prof. So it's a SWC and un editable. How can I set limits on where this window can be dragged?
Currently, the window can be dragged off the area it's in and then (when released) it is impossible to drag it back down and close it.
How can I set the boundaries of where it can be dragged (the draggable part, anyway) ?
Making Text In Bounds...
How can i make shure that every time a textfield reaches maxlimit to the right it automaticly hits enter? Like when i reaches the right limit of this textbok the word is automaticly moved down to a line below... Any1 understood that?
More Efficient Bounds Checking
Hey... I'm making a side-scrolling game. There are a lot of different objects in the 'room', all of which need hitTest checks to make sure the main character can't walk through them... I don't want to make every object a movie clip, because that would be tedious, and very inefficient (I have started doing this, but it slows down the swf rendered file). I was wondering if there was any other, quicker, better way to make it so my character can't walk through walls and such like that.
Thanks for any help.
Moving Object Out Of The Movie Bounds
I'm not sure if this is possible or not. I am using Flash5, and what I want to do is have a relatively small movie clip(flash animation) say like 20x20 pixels but have a larger floating, draggable clip that will sit over the HTML in the page... images, tables, background, etc... can anybody give me a hint on how to do this, if it can be done???
Thanks.
paco
Hit Test To Define Objects, Bounds
I'm creating a game but I have the problem of the characters running off the top of the screen and returning on screen from the bottom. How can I define a perimeter?
Also, if I want the characters to NOT be able to run through other objects on the screen, how do I define that on the actionscripting?
I am using flash mx 2004.
Clipping Bounds On Sprite/MovieClip
Easy noob question for you: I'm using addChild() to add bitmaps to a 100x100 Sprite. I'm positioning these bitmaps with their x and y parameters. However, if the bitmap 'spills' over the edge of the 100x100 Sprite, I want it to be clipped. In other words, if I place a 50x50 image at the x,y coordinates of 90, 90, I only want the upper-left corner 10x10 pixels of the image to be shown. Does that make sense? How can I do this? Is there some 'clip' parameter?
Thanks in advance!
-Rich
Click, Drag, Stay In Bounds....Please.
Hey guys, I need help here. I've been searching this forum and found many versions of what I want but not exactly. I know this probably easy for you guys, but I've been spending days trying to figure this out, ...yes I know I'm a newbie.
Basically I have a click and drag MC on the stage, but I want to confine it to the stage, not having it go past it's edges.
...help!
Loaded .swf Into _mc Wont Stay Within Bounds
Basically I created a slide show (slideshow.swf).... which loads jpgs dynamically into movie clips that I also created dynamically. I also created buttons that I exported for action script and load dynamically on the stage as well...
all contained in SlideShow.swf.....
When I load slideshow.swf into a movieclip (movieClipHolder_mc) in my Main movie
part of the movie ( the jpgs) stay within the bounds of the Slideshow.swf stage...
however the buttons I created dynamically inside of the slideshow.swf movie....
put themselves onto the main stage of my main movie....
I've checked the code and it seems right, but obviously I'm missing something....
Proportionate Resize Based On Bounds
i have a container that is 100 x 100 and i have various symbols of different shapes and sizes (states for a U.S. map) that i am loading into that box and need to resize
some are bigger, some are smaller
can anyone help me figure out how to scale them proportionately larger or smaller depending on their size relative to the container.
here's what i have so far
Code:
attachMovie(_root.curState, "curState", 100, {_x:25, _y:15});
widthBound = 100;
heightBound = 100;
if (curState._width<widthBound && curState._height<heightBound) {
ratioWidth = Math.round(widthBound/curState._width);
ratioHeight = Math.round(heightBound/curState._height);
if (ratioWidth>ratioHeight) {
curState._width *= ratioWidth;
curState._height *= ratioHeight;
}
}
|