1pxの斜線
90°*nを基準とすると・・・
45°+90°*n近傍が薄く見える。
30°+90°*nと60°+90°*n近傍が濃く見える。
- 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);
}
}
}
}- 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);
- }
- }
- }
- }
fl.motion.BezierSegmentで三次ベジェな感じに連続的な直線で疑似曲線を描画する時に目立つなぁ。
About this entry
You’re currently reading “1pxの斜線,” an entry on jp.ferv.blog
- Published:
- Tue, Dec 30th, 2008 at 1:44 PM
- Author:
- dsk
- Category:
- Web
- Tags:
- ActionScript 3.0
No comments
Jump to comment form | comments rss | trackback uri