2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -0,0 +1,29 @@
|
|||
// Plot Fibonacci word/fractal
|
||||
// FiboWFractal.js - 6/27/16 aev
|
||||
function pFibowFractal(n,len,canvasId,color) {
|
||||
// DCLs
|
||||
var canvas = document.getElementById(canvasId);
|
||||
var ctx = canvas.getContext("2d");
|
||||
var w = canvas.width; var h = canvas.height;
|
||||
var fwv,fwe,fn,tx,x=10,y=10,dx=len,dy=0,nr;
|
||||
// Cleaning canvas, setting plotting color, etc
|
||||
ctx.fillStyle="white"; ctx.fillRect(0,0,w,h);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x,y);
|
||||
fwv=fibword(n); fn=fwv.length;
|
||||
// MAIN LOOP
|
||||
for(var i=0; i<fn; i++) {
|
||||
ctx.lineTo(x+dx,y+dy); fwe=fwv[i];
|
||||
if(fwe=="0") {tx=dx; nr=i%2;
|
||||
if(nr==0) {dx=-dy;dy=tx} else {dx=dy;dy=-tx}};
|
||||
x+=dx; y+=dy;
|
||||
}//fend i
|
||||
ctx.strokeStyle = color; ctx.stroke();
|
||||
}//func end
|
||||
// Create and return Fibonacci word
|
||||
function fibword(n) {
|
||||
var f1="1",f2="0",fw,fwn,n2,i;
|
||||
if (n<5) {n=5}; n2=n+2;
|
||||
for (i=0; i<n2; i++) {fw=f2+f1;f1=f2;f2=fw};
|
||||
return(fw)
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<!-- FiboWFractal2.html -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Fibonacci word/fractal</title>
|
||||
<script src="FiboWFractal.js"></script>
|
||||
</head>
|
||||
<body onload="pFibowFractal(31,2,'canvid','red')">
|
||||
<h3>Fibonacci word/fractal: n=31, len=2</h3>
|
||||
<canvas id="canvid" width="850" height="1150" style="border: 2px inset;"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- FiboWFractal1.html -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Fibonacci word/fractal</title>
|
||||
<script src="FiboWFractal.js"></script>
|
||||
</head>
|
||||
<body onload="pFibowFractal(31,1,'canvid','navy')">
|
||||
<h3>Fibonacci word/fractal: n=31, len=1</h3>
|
||||
<canvas id="canvid" width="1400" height="1030" style="border: 2px inset;"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue