Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html class="no-js"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>CanvasJS Demo</title> | ||
</head> | ||
<body> | ||
<canvas id="demo" height="1000" width="1000"> | ||
</canvas> | ||
|
||
<script src="../Canvas.js"></script> | ||
<script> | ||
(function(){ | ||
"use strict" | ||
var ctx = new Canvas("demo"); | ||
function koch( x, y, length, level ) { | ||
ctx.save().moveTo(x,y) | ||
.beginPath() | ||
.line({ | ||
angle : -45, | ||
distance : length, | ||
}) | ||
.line({ | ||
angle : 45, | ||
distance : length, | ||
}) | ||
.line({ | ||
angle : 0, | ||
distance : length, | ||
}) | ||
.stroke() | ||
.restore(); | ||
|
||
if (level <1000) { | ||
koch( ctx.currentPos().x, ctx.currentPos().y, length/3, level+1); | ||
} | ||
|
||
} | ||
function init(){ | ||
/* | ||
if level < 1 then | ||
Move forward length pixels | ||
else | ||
Draw a k-1 level Koch curve with segments 1/3 the current length | ||
Turn left 60 degrees | ||
Draw a k-1 level Koch curve with segments 1/3 the current length | ||
Turn right 120 degrees | ||
Draw a k-1 level Koch curve with segments 1/3 the current length | ||
Turn left 60 degrees | ||
Draw a k-1 level Koch curve with segments 1/3 the current length | ||
*/ | ||
koch( 500, 500, 500, 1 ); | ||
} | ||
return { | ||
init : init | ||
}})().init( demo ); | ||
|
||
|
||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html class="no-js"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>CanvasJS Arc Demo</title> | ||
</head> | ||
<body> | ||
<canvas id="demo" height="500" width="960"> | ||
</canvas> | ||
|
||
<script src="../Canvas.js"></script> | ||
<script> | ||
(function(){ | ||
"use strict" | ||
function init(){ | ||
var ctx = new Canvas("demo"), | ||
int1 = 0, | ||
int2 = 1, | ||
int3, | ||
angle = 0; | ||
for (var i = 3; i <= 30; i++) { | ||
angle = angle+9; | ||
int3 = int1 + int2; | ||
int1 = int2; | ||
int2 = int3; | ||
ctx.beginPath() | ||
.line({ | ||
"distance" : int3/Math.PI, | ||
"angle" : int3, | ||
"x" : 400, | ||
"y" : 20 | ||
}) | ||
.arc( ctx.currentPos().x, ctx.currentPos().y, int3, ctx.math.radians( angle), ctx.math.radians(0 ), true ) | ||
.stroke() | ||
.closePath() | ||
} | ||
} | ||
|
||
return { | ||
init : init | ||
}})().init(); | ||
|
||
|
||
|
||
</script> | ||
</body> | ||
</html> |