Are the borderlines in the Flash Graphics API inside or outside the form?

When I draw rectangles, etc. in ActionScript, using the Flash Player drawing API (that is, the Graphics class), is the border line of this form drawn outside or inside the form? I. e., Which of the following diagrams correctly depicts the rectangle drawn by the border of the content area in the user component?

Flash drawing question

I looked through the documentation for the Graphics class and did not find any hints.

+2
source share
1 answer

I wrote a short test using a special component with a fixed size, drawing some lines as a link, then drawing a 30-pixel-wide rectangle on a white background. Here's what it looks like, see below code:

Flash graphics test

So, referring to the image in question, the second diagram (โ€œcenteredโ€) correctly depicts the way Flash Player is played.

Also notice how the inner lines (45 pixels) are inside the rectangle, and the outer lines (15 pixels) align with the outer edges of the rectangle.

This is the test application code:

 <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:test="*"> <test:TestCanvas horizontalCenter="0" verticalCenter="0" id="canvas" /> </mx:Application> 

And this is the component of TestCanvas :

 public class TestCanvas extends UIComponent { public function TestCanvas() { super(); } override protected function measure():void { super.measure(); this.measuredWidth = this.minWidth = 300; this.measuredHeight = this.minHeight = 300; } override protected function updateDisplayList(w:Number, h:Number):void { super.updateDisplayList(w, h); this.graphics.clear(); this.graphics.lineStyle(undefined); this.graphics.beginFill(0xffffff); this.graphics.drawRect(0, 0, w, h); this.graphics.endFill(); this.graphics.lineStyle(0, 0xff0000, 0.5); this.graphics.moveTo(0, 15); this.graphics.lineTo(300, 15); this.graphics.moveTo(0, 45); this.graphics.lineTo(300, 45); this.graphics.moveTo(15, 0); this.graphics.lineTo(15, 300); this.graphics.moveTo(45, 0); this.graphics.lineTo(45, 300); this.graphics.lineStyle(0, 0xff0000, 0.75); this.graphics.moveTo(0, 30); this.graphics.lineTo(300, 30); this.graphics.moveTo(30, 0); this.graphics.lineTo(30, 300); this.graphics.lineStyle(30, 0x0000ff, 0.25, false, "normal", null, JointStyle.MITER); this.graphics.drawRect(30, 30, 240, 240); } 
+2
source

Source: https://habr.com/ru/post/1310232/


All Articles