Sunday, February 9, 2014

ASCII Project




The Inspiration

The Finished Product


















Process: First I googled "simple cartoon." I started off with a hippo but I wound up with a pig which is my favorite! I took a look at the graph and used a few pin points for the circles, everything else was just playing around with numbers. I saw the shadow effect in class and I thought it made the picture look better so I used it myself. When I got stuck I looked at my notes and the HTML5 tutorials. I finally got frustrated with the project because it was not going exactly the way I wanted it to but overall I'm very pleased with the outcome! So cute!!

<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ


    var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      context.rect(0, 0, canvas.width, canvas.height);

      // create radial gradient
      var grd = context.createRadialGradient(238, 50, 10, 238, 50, 300);
      // light blue
      grd.addColorStop(0, 'yellow');
      // dark blue
      grd.addColorStop(1, 'white');
      grd.addColorStop(.5, 'orange');

      context.fillStyle = grd;
      context.fill();
   



 context.beginPath();
      context.arc(350, 450, 60, 0, Math.PI, true);
      context.closePath();
      context.lineWidth = 3;
      context.fillStyle = 'pink';
      context.fill();
      context.strokeStyle = 'black';
      context.stroke();

 context.beginPath();
      context.arc(480, 450, 60, 0, Math.PI, true);
      context.closePath();
      context.lineWidth = 3;
      context.fillStyle = 'pink';
      context.fill();
      context.strokeStyle = 'black';
      context.stroke();
   

   
context.beginPath();
      context.arc(325, 160, 70, 0, 2 * Math.PI, false);
      context.fillStyle = 'pink';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();
   
 context.beginPath();
      context.arc(500, 160, 70, 0, 2 * Math.PI, false);
      context.fillStyle = 'pink';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();  

context.beginPath();
      context.arc(415, 275, 150, 0, 2 * Math.PI, false);
      context.fillStyle = 'pink';
      context.shadowColor = 'gray';
      context.shadowBlur = 30;
      context.shadowOffsetX = 8;
      context.shadowOffsetY = 8;
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();
   
context.beginPath();
      context.arc(450, 200, 30, 0, 2 * Math.PI, false);
      context.fillStyle = 'white';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();

context.beginPath();
      context.arc(375, 200, 30, 0, 2 * Math.PI, false);
      context.fillStyle = 'white';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();

context.beginPath();
      context.arc(440, 205, 10, 0, 2 * Math.PI, false);
      context.fillStyle = 'black';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();

context.beginPath();
      context.arc(385, 205, 10, 0, 2 * Math.PI, false);
      context.fillStyle = 'black';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();

var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      var centerX = 6;
      var centerY = -40;
      var radius = 20;

      // save state
      context.save();

      // translate context
      context.translate(canvas.width / 2, canvas.height / 2);

      // scale context horizontally
      context.scale(2, 1);

      // draw circle which will be stretched into an oval
      context.beginPath();
      context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);

      // restore to original state
      context.restore();

      // apply styling
      context.fillStyle = 'gray';
      context.fill();
      context.lineWidth = 3;
      context.strokeStyle = 'black';
      context.stroke();

    var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      var x = canvas.width / 1.95;
      var y = canvas.height / 2.001;
      var radius = 50;
      var startAngle = 1.1 * Math.PI;
      var endAngle = 1.9 * Math.PI;
      var counterClockwise = true;

      context.beginPath();
      context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
      context.lineWidth = 4;
      context.strokeStyle = 'black';
      context.lineCap = 'round';
      context.stroke();
   
  context.beginPath();
      context.moveTo(18, 450);
      context.quadraticCurveTo(150, 0, 270, 450);
      context.lineWidth = 4;
      context.strokeStyle = 'green';
   
      context.stroke();

  context.closePath();
      context.lineWidth = 5;
      context.fillStyle = 'green';
      context.fill();
      context.strokeStyle = 'green';
      context.stroke();


////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};

</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

No comments:

Post a Comment