When I want inside borders I do this:
var spr:Sprite = new Sprite();
addChild(spr);
var g:Graphics = spr.graphics;
g.beginFill(0xFF45A3);
g.drawRect(0, 0, 100, 100);
g.endFill();
drawInsideStroke(g, 0, 0, 100, 100, 1, 0x32010B);
function drawInsideStroke(graphics:Graphics, x:int, y:int, width:int,
height:int, thickness:int = 1, color:uint = 0x000000) {
graphics.endFill(); // for good measure, but maybe not?
graphics.beginFill(color);
graphics.drawRect(x, y, width, height);
graphics.drawRect( x + thickness, y + thickness, width - (thickness *
2), height - (thickness * 2) );
graphics.endFill();
}
trace(spr.width,spr.height); // -> 110 110
trace(spr.getBounds(this)) // -> (x=-5, y=-5, w=110, h=110)
On Mon, Apr 12, 2010 at 7:14 PM, Latcho <[email protected]> wrote:
> Hello,
> Something i still can't solve is that when drawing for example a rect in a
> Shape graphics object with a fat lineStyle, the line drawn is always half
> it's thicknes in the inner part of the rect and half outside; This always
> gives me headaches when aligning, measuring, skinning or bitmapping stuff
> since half the line is in the negative x / y coordinate space of the shape..
> I know that I can use the getBounds method to get me the accurate negative
> x and y offset of the (line) graphics, but what I really want is to have the
> line beign drawn totally within the rect. Is that possible by the default
> graphics api ? Then please expand on my example.
>
> Thanks.
> Latcho.
>
>
> var spr:Sprite = new Sprite();
> addChild(spr);
> var g:Graphics = spr.graphics;
> g.lineStyle(10,0xff0000);
> g.beginFill(0x0000ff);
> g.drawRect(0,0,100,100);
> g.endFill();
> trace(spr.width,spr.height); // -> 110 110
> trace(spr.getBounds(this)) // -> (x=-5, y=-5, w=110, h=110)
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders