1pxの斜線

90°*nを基準とすると・・・
45°+90°*n近傍が薄く見える。 30°+90°*nと60°+90°*n近傍が濃く見える。

linethickness.swf

  • ActionScript
  • LineThickness.as
  • Source
package {
	import fl.controls.NumericStepper;

	import flash.display.CapsStyle;
	import flash.display.LineScaleMode;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;

	public class LineThickness extends Sprite {

		private const RADIUS:int = 200;

		private var lineLayer:Sprite;
		private var interpolate:NumericStepper;
		private var base:MovieClip;

		public function LineThickness() {
			this.interpolate = new NumericStepper();
			this.interpolate.maximum = 360;
			this.interpolate.value = 180;
			this.interpolate.stepSize = 12;
			this.interpolate.x = 470;
			this.interpolate.y = 528;
			this.interpolate.addEventListener(Event.CHANGE, this.onInterpolateChange);
			this.addChild(this.interpolate);

			this.base = this.getChildByName('_base') as MovieClip;

			this.lineLayer = new Sprite();
			this.addChild(this.lineLayer);

			this.draw();
		}

		private function onInterpolateChange(e:Event):void {
			this.draw();
		}

		private function draw():void {
			var unit:Number = Math.PI * 2 / this.interpolate.value;
			var source:Point = new Point(this.base.width / 2, this.base.height / 2);
			var target:Point;

			this.lineLayer.graphics.clear();
			this.lineLayer.graphics.lineStyle(1, 0x333333, 1, false, LineScaleMode.NONE, CapsStyle.NONE);
			for (var i:int = 0; i < this.interpolate.value; i++) {
				target = Point.polar(this.RADIUS, unit * i);
				target = target.add(source);
				this.lineLayer.graphics.moveTo(source.x, source.y);
				this.lineLayer.graphics.lineTo(target.x, target.y);
			}
		}

	}
}
  1. package {
  2.     import fl.controls.NumericStepper;
  3.  
  4.     import flash.display.CapsStyle;
  5.     import flash.display.LineScaleMode;
  6.     import flash.display.MovieClip;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.geom.Point;
  10.  
  11.     public class LineThickness extends Sprite {
  12.  
  13.         private const RADIUS:int = 200;
  14.  
  15.         private var lineLayer:Sprite;
  16.         private var interpolate:NumericStepper;
  17.         private var base:MovieClip;
  18.  
  19.         public function LineThickness() {
  20.             this.interpolate = new NumericStepper();
  21.             this.interpolate.maximum = 360;
  22.             this.interpolate.value = 180;
  23.             this.interpolate.stepSize = 12;
  24.             this.interpolate.x = 470;
  25.             this.interpolate.y = 528;
  26.             this.interpolate.addEventListener(Event.CHANGE, this.onInterpolateChange);
  27.             this.addChild(this.interpolate);
  28.  
  29.             this.base = this.getChildByName('_base') as MovieClip;
  30.  
  31.             this.lineLayer = new Sprite();
  32.             this.addChild(this.lineLayer);
  33.  
  34.             this.draw();
  35.         }
  36.  
  37.         private function onInterpolateChange(e:Event):void {
  38.             this.draw();
  39.         }
  40.  
  41.         private function draw():void {
  42.             var unit:Number = Math.PI * 2 / this.interpolate.value;
  43.             var source:Point = new Point(this.base.width / 2, this.base.height / 2);
  44.             var target:Point;
  45.  
  46.             this.lineLayer.graphics.clear();
  47.             this.lineLayer.graphics.lineStyle(1, 0x333333, 1, false, LineScaleMode.NONE, CapsStyle.NONE);
  48.             for (var i:int = 0; i < this.interpolate.value; i++) {
  49.                 target = Point.polar(this.RADIUS, unit * i);
  50.                 target = target.add(source);
  51.                 this.lineLayer.graphics.moveTo(source.x, source.y);
  52.                 this.lineLayer.graphics.lineTo(target.x, target.y);
  53.             }
  54.         }
  55.  
  56.     }
  57. }

fl.motion.BezierSegmentで三次ベジェな感じに連続的な直線で疑似曲線を描画する時に目立つなぁ。


About this entry