StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
282 stars 89 forks source link

draw rect #109

Closed pjh00 closed 9 years ago

pjh00 commented 10 years ago

image

var _oShape:Shape = new Shape(); addChild(_oShape); _oShape.graphics.clear(); _oShape.graphics.lineStyle(5, 0xFFFFFF); _oShape.graphics.drawRect(0, 0, 300, 300);

jarrodmoldrich commented 10 years ago

Hi pjh00. Can you show the code for this?

My guess, is that this is a side effect of strokes not knowing if they are closed or not. A workaround for this problem would be to draw another line facing right. So:

a ---- b
|      |
d ---- c

a->b->c->d->a->b

It's not ideal. The Stroke implementation could be changed to detect closures in the future.

IonSwitz commented 10 years ago

The reason here is the thickness: the thickness is only applied to the width of a stroke, not the length of it. This is from Graphics drawRect:

moveTo( x, y ); lineTo( x + width, y ); lineTo( x + width, y + height ); lineTo( x, y + height ); lineTo( x, y );

The last line could be:

lineTo( x, y - _strokeThickness / 2 );

To make this work, but it might cause other issues.

pjh00 commented 10 years ago

lonSwitz Thank you. Solved.

IonSwitz commented 9 years ago

I have fixed this now, with the solution mentioned above. I can't believe that this change would cause any problems