Bottom of the image painted
/* *** FUNCTION NAMING FORMAT*** 1) fill - complete function that fills the area with color loopThru - when it is filling a square it iterates and fills each pixel reset - compliments the loopThru function to help fill each pixel paintColor - compliements the fill function to paint with correct color 2) There will be either T,M,B at the end of each basic function name This is to indicate wheater the function corresponds to the Top, Middle, or Bottom 3) There Will be either R,L,C after the previous top, middle, or bottom to indicate weather it is Right, Left, or Center 4) If there are multiple functions in the same area of the picture, For example) two functions that paint the bottom left. They are distinguisehed by a spelled out number after the function */ // length 14, idk height, right bottom - BR function function start(){ fillBottom(); } function fillBottom(){ // BOTTOM LEFT CORNER OF THE IMAGE (8*8) back square // Fills up all each line with color until it reaches top of image for (var i = 0; i < 8; i++){ loopThruBL(); } while(notFacingEast()){ turnRight(); } for (var i = 0; i < 9; i++){ move(); } while(notFacingSouth()){ turnRight(); } for (var i = 0; i < 8; i++){ move(); } while(notFacingEast()){ turnRight(); } for (var i = 0; i < 5; i++){ loopThruBLtwo(); } while(notFacingEast()){ turnRight(); } for (var i = 0; i < 12; i++){ move(); } while(notFacingSouth()){ turnRight(); } for (var i = 0; i < 5; i++){ move(); } while(notFacingEast()){ turnRight(); } move(); paintColorBLtwo(); move(); paintColorBLtwo(); while(notFacingNorth()){ turnLeft(); } move(); while(notFacingWest()){ turnLeft(); } move(); paintColorBLtwo(); while(notFacingSouth()){ turnLeft(); } move(); while(notFacingEast()){ turnLeft(); } for (var i = 0; i < 12; i++){ move(); } for (var i = 0; i < 6; i++){ loopThruBR(); } while(notFacingSouth()){ turnRight(); } for (var i = 0; i < 6; i++){ move(); } while(notFacingWest()){ turnLeft(); } for (var i = 0; i < 3; i++){ move(); paintColorBR(); } turnAround(); for (var i = 0; i < 2; i++){ move(); } while(notFacingNorth()){ turnLeft(); } move(); paintColorBR(); move(); paintColorBR(); } // Does not allow nested for loop so it is in a functon function loopThruBL(){ // moves through each pixel in line and colors it for(var i = 0; i < 8; i++ ){ paintColorBL(); move(); paintColorBL(); } resetBL(); } /* Once Karel reaches the end of the row, resets Karel to start on a new row */ function resetBL(){ while (notFacingWest()){ turnRight(); } for(var i = 0; i < 8; i++ ){ move(); } while (notFacingNorth()){ turnLeft(); } if (frontIsClear()){ move(); paintColorBL(); } while (notFacingEast()){ turnRight(); } } // we can make this like a bigger function and put 27 line functions inside // maybe use if else to check function paintColorBL(){ if (colorIs(Color.red)){ paint(Color.blue); }else{ paint(Color.createFromRGB(13, 25, 8, 255)); } } function paintColorBLtwo(){ if (colorIs(Color.red)){ paint(Color.blue); }else{ paint(Color.createFromRGB(55,45,58,255)); } } function loopThruBLtwo(){ // moves through each pixel in line and colors it for(var i = 0; i < 12; i++ ){ paintColorBLtwo(); move(); paintColorBLtwo(); } resetBLtwo(); } function resetBLtwo(){ while (notFacingWest()){ turnRight(); } for(var i = 0; i < 12; i++ ){ move(); } while (notFacingNorth()){ turnLeft(); } if (frontIsClear()){ move(); paintColorBLtwo(); } while (notFacingEast()){ turnRight(); } } function paintColorBR(){ if (colorIs(Color.red)){ paint(Color.blue); }else{ paint(Color.createFromRGB(49,66,42,255)); } } function loopThruBR(){ // moves through each pixel in line and colors it for(var i = 0; i < 13; i++ ){ paintColorBR(); move(); paintColorBR(); } resetBR(); } function resetBR(){ while (notFacingWest()){ turnRight(); } for(var i = 0; i < 13; i++ ){ move(); } while (notFacingNorth()){ turnLeft(); } if (frontIsClear()){ move(); paintColorBR(); } while (notFacingEast()){ turnRight(); } }
Leave a Comment