bp74 / StageXL

A fast and universal 2D rendering engine for HTML5 and Dart.
http://www.stagexl.org
Other
881 stars 82 forks source link

Shape doesnt have proper width/height #15

Closed deepblue-phoenix closed 11 years ago

deepblue-phoenix commented 11 years ago

it seems that when I draw inside of a Shape.graphic the resulting dimensions are not representative of the size of the drawing... both the width/height are 0 after the drawing operations. if you attach the Shape to the Sprite then, the Sprite itself also has resulting width/height == 0 as well...

as in as3, the dimensions should reflect the dimensions of the bounding box around the drawn shape.

deepblue-phoenix commented 11 years ago

great library by the way. just want to encourage you to continue! :)

deepblue-phoenix commented 11 years ago

even after I manually assign values to the width/height of the Shape instance, when reading those properties back they still return 0

deepblue-phoenix commented 11 years ago

so on line 112 and 113 in DisplayObject.dart I see this: num get width => getBoundsTransformed(_transformationMatrix).width; num get height => getBoundsTransformed(_transformationMatrix).height;

and in the same file in function getBoundsTransformed() on line 255 and 256 I see this: returnRectangle.width = 0; returnRectangle.height = 0; return returnRectangle;

so, it seems that width/height of returnRectangle are always set to 0, which is whats always returned by the getters...

I just glanced at the code though, so I might be missing something.

bp74 commented 11 years ago

Hello

Yes you are absolutely right. Currently the Shape does not calculate it's size and therefore you also can't use it as a mouse target - that's very unfortunate. Please give me a few days to take a look at that and i will try to implement the correct behavior.

Thank you for reporting this issue and also for the kind words about the library.

Bernhard

deepblue-phoenix commented 11 years ago

hello Bernard, no need to thank me for kind words, a library like this is much needed. Im actually considering of using it on a client project... Having this Shape issue implemented is highly important for any kind of procedural drawing. It would be amazing if you managed to implement this in the following days.

keep up the great work. thanks

bp74 commented 11 years ago

Just i quick update. I did some work an Shape and Graphics and the width/height properties should be correct now. The changes need more testing, therefore the source is only available here on GitHub but not on Pub. Furthermore i need to do some more work to make the hit test work exactly like it does in Flash. Currently the hit test takes the bounding rectangle of the Shape, but in fact the bounds of the shape of the graphics needs to be checked. This will follow within the next few days.

bp74 commented 11 years ago

I have finished the work on Graphics and Shapes. The Source is available on GitHub but not on Pub yet. I hope everything works as you expect. I will close this issue, but please don't hesitate to open a new one if anything does not work correct. Thanks for your feedback.

Bernhard

deepblue-phoenix commented 11 years ago

great work. incorporated your changes and am using your library in a client project now :) keep up the good work

bp74 commented 11 years ago

Thanks for the feedback, this is good to know! I would love to see what you have done when you are finished.