#include #include int main(int argc, char **argv) { printf(""); int fretsCount = strlen(argv[1]); //var origin = { x: 0, y: 0}; //var props = { width: 50, height: 60 }; // horizontals int i; for (i = 0; i <= 4; i++) { printf("", 0 - 1, (i * 60/4), 0+50+1, (i * 60/4) ); } // verts for ( i = 0; i < fretsCount; i++ ) { printf("", 0 + (i * 50 / (fretsCount - 1)), 0, 0 + (i * 50 / (fretsCount - 1)), 0 + 60 ); } // label printf("%s", 0 + 50/2, 0 - 5, argv[2] ); // If any dots are after 4, adjust the root to be the lowest non-zero fret // If the root is zero , thicken the top fret /*var baseFret = 0; var adjBaseFret = false; var lowestFret = 0; for (j=0; j < chord.frets.length; j++) { if (chord.frets.charAt(j) != 'x' && chord.frets.charAt(j) != 'X' && chord.frets.charAt(j) > 0) { if (chord.frets.charAt(j) < lowestFret || lowestFret == 0) { lowestFret = chord.frets.charAt(j); } if (chord.frets.charAt(j) > 4) { adjBaseFret = true; } } } if (adjBaseFret) { baseFret = lowestFret - 1; } // dots var dotsize = 3.5; var i = 0; for (j=0; j < chord.frets.length; j++) { ctx.alignText = "left"; ctx.fillText(chord.frets.charAt(j), origin.x + (i * props.width / (fretsCount - 1)), origin.y + props.height + 12); if (chord.frets.charAt(j) == 0) { } else if (chord.frets.charAt(j) == 'x' || chord.frets.charAt(j) == 'X') { } else { ctx.beginPath(); ctx.arc(origin.x + (i * props.width / (fretsCount -1)), origin.y - 7.5 + (15 * (chord.frets.charAt(j) - baseFret)), dotsize, 0, Math.PI*2,true); ctx.closePath(); ctx.fill(); } i++; } // base fret indicator if (baseFret > 0) { ctx.alignText = "left"; ctx.fillText(baseFret + 1, origin.x - 10, origin.y + 11); } else { ctx.alignText = "left"; ctx.fillText("3", origin.x - 10, origin.y + 41); }*/ printf(""); }