2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

途切れた線の描画

Last updated at Posted at 2017-11-15

Interrupted Line (1) | CreateJS

var graph = new createjs.Shape();
stage.addChild(graph);
graph.graphics.setStrokeStyle(3, "round", "round");
graph.graphics.beginStroke("#FF3366");
var drawn = false;
for (n = -320; n <= 320; n++) {
	px = n;
	py = 120*Math.sin(n*RADIAN);
	if (!drawn) {
		graph.graphics.moveTo(px, -py);
		drawn = true;
	} else {
		graph.graphics.lineTo(px, -py);
	}
}
graph.graphics.endStroke();

Interrupted Line (2) | CreateJS

var graph = new createjs.Shape();
stage.addChild(graph);
graph.graphics.setStrokeStyle(3, "round", "round");
graph.graphics.beginStroke("#FF3366");
var interrupted = true;
for (n = -320; n <= 320; n++) {
	px = n;
	py = 120*Math.sin(n*RADIAN);
	//描画領域を制限
	if (-py > -LIMIT_HEIGHT && -py < LIMIT_HEIGHT) {
		if (interrupted) {
			graph.graphics.moveTo(px, -py);
		} else {
			graph.graphics.lineTo(px, -py);
		}
		//連続している
		interrupted = false;
	} else {
		//途切れた
		interrupted = true;
	}
}
graph.graphics.endStroke();
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?