To begin typing, begin typing.
My final project is a Braille typing interface. Since hardly anyone who can see can read Braille, and hardly anyone who can read Braille can see, It’s meant to be used as a venting system – like writing a letter you’ll never send. The program allows typing of all letters and some punctuation (i.e. question mark, space, enter keys). Once one has typed enough, the program will reset the canvas and repeatedly erase what the user has written. “Delete” will reset the canvas / program.
// Joshua Brown
// Jdbrown@andrew.cmu.edu
// Final Project: Braille Writing: "Irony"
// Section C
var dotSize = 8; // size of Braille dots
var dotX = 10; // x co-ordinate of each dot
var dotY = 10; // y co-ordinate of each dot
var dotDis = 10; // distance between dots;
var t1; // turtle object
var counter = 0; // counter for "transition" function
var back = 0; // background variable
var col = 0; // color variable
var spd = 0.5; // speed variable
function setup () {
createCanvas (480, 500);
background (255);
}
function draw () {
transition(); // function erases the canvas, erases typed input periodically
}
function transition() {
if (counter < 20) { // if the user has entered fewer
col = 0; // than 20 letters, dot color is black
}
if (counter > 20 & col < 240) { // if the user has entered more than
col += 0.5; // 20 letters, dot color lightens
}
if (counter > 20) { // if the user has entered more than
col += 1; // 20 letters, dot color lightens
}
if (col > 200) { // if the dot color is whitish,
background(back += 1); // de-draw the background, lighter
col = 255; // dot color is black.
}
if (back >= 255) { // if the background is white,
col = 1; // dot color is black
back -= 0.25; // background darkens
}
if (counter >= 150) {
background (255);
col = 0;
noLoop();
}
}
function keyPressed() {
var t1 = makeTurtle (dotX, dotY);
print (keyCode);
if (keyIsPressed) { // when a key is pressed, increase the counter;
counter += 1; // move the Turtle over to mimic space between letters.
print (counter);
dotX += 26;
}
if (keyCode == 8) { // when the delete key is pressed,
background (255); // clear the canvas and reset the turtle position.
dotX = 10; // clear the counter back to 0;
dotY = 10;
counter = 0;
draw();
}
if (dotX > (width - 5)) { // when the dotX goes beyond the canvas, reset it to keep it on
dotY += 45;
dotX = 10;
}
if (dotY > (height - 5)) { // if tying goes beyond the canvas, fix it.
dotY = 10;
dotX = 10;
background(255);
}
if (keyCode == 32) { // creating a space w/ spacebar;
makeSpace(t1);
}
if (keyCode == 65) {
makeA(t1);
}
if (keyCode == 66) {
makeB(t1);
}
if (keyCode == 67) {
makeC(t1);
}
if (keyCode == 68) {
makeD(t1);
}
if (keyCode == 69) {
makeE(t1);
}
if (keyCode == 70) {
makeF(t1);
}
if (keyCode == 71) {
makeG(t1);
}
if (keyCode == 72) {
makeH(t1);
}
if (keyCode == 73) {
makeI(t1);
}
if (keyCode == 74) {
makeJ(t1);
}
if (keyCode == 75) {
makeK(t1);
}
if (keyCode == 76) {
makeL(t1);
}
if (keyCode == 77) {
makeM(t1);
}
if (keyCode == 78) {
makeN(t1);
}
if (keyCode == 79) {
makeO(t1);
}
if (keyCode == 80) {
makeP(t1);
}
if (keyCode == 81) {
makeQ(t1);
}
if (keyCode == 82) {
makeR(t1);
}
if (keyCode == 83) {
makeS(t1);
}
if (keyCode == 84) {
makeT(t1);
}
if (keyCode == 85) {
makeU(t1);
}
if (keyCode == 86) {
makeV(t1);
}
if (keyCode == 87) {
makeW(t1);
}
if (keyCode == 88) {
makeX(t1);
}
if (keyCode == 89) {
makeY(t1);
}
if (keyCode == 90) {
makeZ(t1);
}
if (keyCode == 191) {
makeQuestion(t1);
}
if (keyCode == 13) {
dotY += 45;
dotX = 10;
}
}
function makeA (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeB (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp();
}
function makeC (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeD (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeE (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeF (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeG (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeH (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeI (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeJ (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeK (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeL (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeM (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeN (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeO (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeP (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeQ (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeR (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeS (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeT (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeU (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeV (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeW (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeX (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeY (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
function makeZ (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeSpace (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
function makeQuestion (t1) {
t1.setColor(col); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.forward(dotDis / 20);
}
// makeTurtle(x, y) -- make a turtle at x, y, facing right, pen down
// left(d) -- turn left by d degrees
// right(d) -- turn right by d degrees
// forward(p) -- move forward by p pixels
// back(p) -- move back by p pixels
// penDown() -- pen down
// penUp() -- pen up
// goto(x, y) -- go straight to this location
// setColor(color) -- set the drawing color
// setWeight(w) -- set line width to w
// face(d) -- turn to this absolute direction in degrees
// angleTo(x, y) -- what is the angle from my heading to location x, y?
// turnToward(x, y, d) -- turn by d degrees toward location x, y
// distanceTo(x, y) -- how far is it to location x, y?
function turtleLeft(d) {
this.angle -= d;
}
function turtleRight(d) {
this.angle += d;
}
function turtleForward(p) {
var rad = radians(this.angle);
var newx = this.x + cos(rad) * p;
var newy = this.y + sin(rad) * p;
this.goto(newx, newy);
}
function turtleBack(p) {
this.forward(-p);
}
function turtlePenDown() {
this.penIsDown = true;
}
function turtlePenUp() {
this.penIsDown = false;
}
function turtleGoTo(x, y) {
if (this.penIsDown) {
stroke(this.color);
strokeWeight(this.weight);
line(this.x, this.y, x, y);
}
this.x = x;
this.y = y;
}
function turtleDistTo(x, y) {
return sqrt(sq(this.x - x) + sq(this.y - y));
}
function turtleAngleTo(x, y) {
var absAngle = degrees(atan2(y - this.y, x - this.x));
var angle = ((absAngle - this.angle) + 360) % 360.0;
return angle;
}
function turtleTurnToward(x, y, d) {
var angle = this.angleTo(x, y);
if (angle < 180) {
this.angle += d;
} else {
this.angle -= d;
}
}
function turtleSetColor(c) {
this.color = c;
}
function turtleSetWeight(w) {
this.weight = w;
}
function turtleFace(angle) {
this.angle = angle;
}
function makeTurtle(tx, ty) {
var turtle = {x: tx, y: ty,
angle: 0.0,
penIsDown: true,
color: color(128),
weight: 1,
left: turtleLeft, right: turtleRight,
forward: turtleForward, back: turtleBack,
penDown: turtlePenDown, penUp: turtlePenUp,
goto: turtleGoTo, angleto: turtleAngleTo,
turnToward: turtleTurnToward,
distanceTo: turtleDistTo, angleTo: turtleAngleTo,
setColor: turtleSetColor, setWeight: turtleSetWeight,
face: turtleFace};
return turtle;
/*function TEMPLATE (t1) {
t1.setColor(0); // defining the top left
t1.setWeight(dotSize);
t1.penUp();
t1.forward(dotDis);
t1.right(90);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the mid left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining the bottom left;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining "turn into second column"
t1.left(90); // and bottom right
t1.forward(dotDis);
t1.penDown();
t1.left(90);
t1.forward(dotDis / 20);
t1.penUp(); // defining mid right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
t1.penUp(); // defining top right;
t1.forward(dotDis);
t1.penDown();
t1.forward(dotDis / 20);
}
Keycodes for letters:
a = 65, b = 66, c = 67, d = 68
e = 69, f = 70, g = 71, h = 72,
i = 73, j = 74, k = 75, l = 76,
m = 77, n = 78, o = 79, p = 80,
q = 81, r = 82, s = 83, t = 84,
u = 85, v = 86, w = 87, x = 88,
y = 89, z = 90;
*/
/*noStroke();
fill (0);
ellipse (dotX, dotY, dotSize, dotSize); // top left;
ellipse (dotX * 2, dotY, dotSize, dotSize); // top right;
ellipse (dotX, dotY * 2, dotSize, dotSize); // mid left;
ellipse (dotX * 2, dotY * 2, dotSize, dotSize); // mid right;
ellipse (dotX, dotY * 3, dotSize, dotSize); // bottom left;
ellipse (dotX * 2, dotY * 3, daotSize, dotSize); // bottom right;
//ellipse (10, 10, 10, 10); // defining the top left;
//ellipse (20, 10, 10, 10); // defining the top right;
//ellipse (10, 20, 10, 10); // defining the mid left;
//ellipse (20, 20, 10, 10); // defining the mid right;
//ellipse (10, 30, 10, 10); // defining the bottom left;
//ellipse (10, 30, 10, 10); // defining the bottom right;
*/
}