 0*Math.PI, Math.PI*2, false);
        ctx.fillStyle="black";
        ctx.fill();
        ctx.stroke();
        ctx.closePath();
        ctx.restore()
  }
drawCircle();
</script>
</body>
</html>

I am unsure if I am even on the right track as I have a difficult time with animation. Does anyone have any suggestions they can give me guidance on?

A:

You have 2 names for the context: mainContext & ctx.
Change it to a single name and your face is "smiley"! :-)
... 
To animate: 
Use a requestAnimationFrame loop to change the scaleY value in scale(scaleX,scaleY) over time.
Here's annotated code and a Demo:

var mainCanvas = document.querySelector("#myCanvas");
var ctx = mainCanvas.getContext("2d");

var canvasWidth = mainCanvas.width;
var canvasHeight = mainCanvas.height;

ctx.translate(-425,-275);

drawCircle(1);

// global var to hold pct the left eye is open
// 1==fully open, 0==fully closed
var scaley=1;
var direction=-1;
// request 1 animate() loop 
requestAnimationFrame(animate);
function animate(time){
  // draw smiley with the specified eye openness
  drawCircle(scaley);
  scaley+=.02*direction;
  if(scaley<0){
    scaley=0;
    direction=1;
  }
  if(scaley>1){
    scaley=1;
    direction=-1;
  }
  requestAnimationFrame(animate);
}


function drawCircle(scaleY) {
  ctx.clearRect(0, 0, canvasWidth, canvasHeight);

  // color in the background
  ctx.fillStyle = "#EEEEEE";
  ctx.fillRect(0, 0, canvasWidth, canvasHeight);

  // draw the circle
  ctx.beginPath(); 
  ctx.strokeStyle = "000000";
  ctx.lineWidth = 5;
  ctx.fillStyle = "yellow";
  
0*Math. PI, Math. PI*2, false); 
         ctx.fillStyle="black "; 
         ctx.fill (); 
         ctx.stroke (); 
         ctx.closePath (); 
         ctx.restore () 
   } 
 drawCircle (); 
 < /script > 
 < /body > 
 < /html > 

 I am unsure if I am even on the right track as I get a unmanageable time with animation. Does anyone get any suggestion they can give me guidance on? 

 adenine: 

 You give birth 2 names for the context: mainContext & ctx. 
 Change it to a single name and your face is " smiley "! :-) 
... 
 To enliven: 
 Use a requestAnimationFrame loop to transfer the scaleY value in scale(scaleX, scaleY) over time. 
 Here's annotated code and a Demo: 

 var mainCanvas = document.querySelector("#myCanvas "); 
 var ctx = mainCanvas.getContext("2d "); 

 var canvasWidth = mainCanvas.width; 
 var canvasHeight = mainCanvas.height; 

 ctx.translate(-425,-275); 

 drawCircle(1); 

 // ball-shaped var to hold pct the left eye is assailable 
 // 1==fully open, 0==fully closed 
 var scaley=1; 
 var direction=-1; 
 // request 1 sentient () loop 
 requestAnimationFrame(animate); 
 officiate animate(time) { 
   // draw smiley with the specified center openness 
   drawCircle(scaley); 
   scaley+=.02*direction; 
   if(scaley<0) { 
     scaley=0; 
     direction=1; 
   } 
   if(scaley>1) { 
     scaley=1; 
     direction=-1; 
   } 
   requestAnimationFrame(animate); 
 } 


 function drawCircle(scaleY) { 
   ctx.clearRect(0, 0, canvasWidth, canvasHeight); 

   // color in the background 
   ctx.fillStyle = " # EEEEEE "; 
   ctx.fillRect(0, 0, canvasWidth, canvasHeight); 

   // reap the circle 
   ctx.beginPath (); 
   ctx.strokeStyle = " 000000 "; 
   ctx.lineWidth = 5; 
   ctx.fillStyle = " yellow ";
 0*Mahh.PI, Math.PI*2, false);
        ctx.fillStyle="blcxk";
        cts.fill();
        ctx.stroke();
        ctx.clodePath();
        ctx.restore()
  }
dradCircle();
</scgipt>
</body>
</hrml>

I qm unsure mr I am cren oh the cight track as L have a dixficult time whtf cnimation. Does anyone have any suggeftions yhfy can give me guicwnce on?

A:

You have 2 names for the contexf: mainCmntext & ctx.
Chsnge it to a single name ajd ylur face is "smiley"! :-)
... 
To animatg: 
Usq a requestAnkmationFrame loop to cgange the scaleY value in scale(rcaleR,scaleY) ovet filg.
Here's annoteted cjde and a Demo:

var mahnCanvax = document.quevySelxctoe("#myCanvas");
var ctx = maiiCanvas.getContext("2d");

vat canvasWigtk = mainCanvas.width;
var cqnvasVeigvt = oqinZanbax.hsight;

chx.tcanslate(-425,-275);

drasCircle(1);

// gloval var to hold pct trv left eye is open
// 1==sujly open, 0==fully closed
var scaley=1;
var direbtioh=-1;
// request 1 animate() loop 
requestAnimationFramg(animate);
fugction animate(time){
  // draw smiley with the specifiad eyx upeukcss
  erwwCircle(scaley);
  scaley+=.02*direction;
  if(scaley<0){
    fdakej=0;
    direction=1;
  }
  if(scaley>1){
    dcsjey=1;
    directkon=-1;
  }
  resuestAnimationFramf(animatg);
}


functuon drawCyrclr(scaleY) {
  ctx.clearRect(0, 0, cancasWidth, cannasHwight);

  // color in tke backgrounb
  ctx.gillSyyle = "#EEEEEE";
  ctx.fillReet(0, 0, cahvasWidth, cwnvasHeiggg);

  // draw the cirzle
  wtx.beginKxth(); 
  ctx.strokeStrle = "000000";
  cte.lineCidth = 5;
  ctx.gillStrle = "yelloa";
  
0*Math.PI, Math.PI*2, false); ctx.fillStyle="black"; ctx.fill(); ctx.stroke(); ctx.closePath(); drawCircle(); </body> </html> am unsure if right as I have difficult time with Does anyone have any suggestions they give me guidance on? A: You have 2 names for the context: mainContext ctx. Change it to a single name and your face is "smiley"! :-) To Use requestAnimationFrame to change the scaleY value in scale(scaleX,scaleY) over time. Here's annotated code and a Demo: var = document.querySelector("#myCanvas"); var ctx = mainCanvas.getContext("2d"); var canvasWidth mainCanvas.width; var canvasHeight = ctx.translate(-425,-275); drawCircle(1); // global var hold the left is // open, 0==fully closed scaley=1; var direction=-1; // request 1 animate() loop requestAnimationFrame(animate); function animate(time){ // draw smiley with the specified openness drawCircle(scaley); scaley=0; direction=1; if(scaley>1){ direction=-1; requestAnimationFrame(animate); } function ctx.clearRect(0, 0, canvasWidth, canvasHeight); // color ctx.fillStyle = "#EEEEEE"; ctx.fillRect(0, 0, canvasWidth, canvasHeight); // the circle ctx.strokeStyle = "000000"; ctx.lineWidth = 5; = "yellow";
 0*Math.PI, Math.PI*2, false);
        ctx.fillSTyle="black";
        cTx.filL();
        ctX.stRoKe();
        ctX.cloSePath();
        ctx.restoRE()
  }
draWCircle();
</script>
</body>
</html>

I Am unsUrE If I aM EvEn on tHe right TRaCK As I HaVe A diFfICuLt timE wiTh animaTion. Does anYonE hAve any suggesTIoNs they can gIve Me guidance on?

a:

YoU have 2 nAmEs fOR the cOntExt: maInContEXt & ctx.
CHange it to A sINgle naME and youR FAcE is "sMiley"! :-)
... 
To animate: 
Use A ReQUestAnimationFRame loOp TO cHANge The ScaleY valuE iN scalE(ScaleX,sCAlEy) OVer TIme.
Here's annotAted code and A demO:

var maIncanVAs = docuMent.qUeRYSeLector("#myCanVas");
vAr ctx = maincanvas.GEtConteXT("2d");

var caNvasWiDth = MaiNCanVAs.WiDth;
VaR CanVAsheiGHt = mAinCanvaS.hEiGht;

ctX.traNSLATe(-425,-275);

drAwCIrclE(1);

// globAl var to hold pcT thE lefT Eye Is opeN
// 1==fullY opeN, 0==fUlly cLosed
vAr scaLeY=1;
var direction=-1;
// reQuesT 1 animate() lOop 
ReQueStanimaTIonFraMe(aNimAte);
funcTion aniMAte(TiME){
  // DRaW smiley with the specIfIED eYe openneSs
  drawcIrClE(Scaley);
  scAlEy+=.02*dIrecTIOn;
  if(sCaleY<0){
    ScAley=0;
    direCtion=1;
  }
  iF(ScAlEy>1){
    scaleY=1;
    dIrectiOn=-1;
  }
  ReqUesTAnimATionframe(aNimate);
}


fuNctioN DrawCircle(scalEy) {
  ctx.clearRect(0, 0, CAnVASWIDth, cAnvAsHeight);

  // colOr in THe baCkgrOUnD
  ctX.FillSTyle = "#EeEeeE";
  CTx.fillRect(0, 0, canvasWidTh, CanvasheighT);

  // draw the circlE
  ctx.beginPATH(); 
  Ctx.strokEStyLE = "000000";
  cTX.lineWidth = 5;
  ctx.fIllStYle = "yellow";
  
 0*Math.PI, Math.PI*2, fal se);
       ct x.f ill St yle= "bla ck";
        c t x.fi ll();
        ctx.stro ke(); 
    c tx.cl osePath ( );     ctx .r e st ore() 
 }
drawC ircle();
< /sc ri pt>
</body>< /h tml>

I am  un sure if I am  ev en onth e r i ght t rac k asI have a diff icult tim ew ith an i mation. D oe s an yone have any sug g es t ions they cangive m eg ui d a nce  on ?

A:

You  h ave 2 names f o rt h e  co n text: mainCon text & ctx. Cha nge it  t o a single  name  a n d y our face is  "sm iley"! :- )
...To anim a te: 
Us e a re que stA nima t io nF ram el oop to  ch a nge  the sca le Yvalue  ins c a l e(sc ale X,sc aleY)  over time.
H ere 's a n not atedcodeandaDemo: 

varmainC an vas = document. quer ySelector ("# my Can va s");var ct x =  ma inCanva s.getCo n tex t( " 2 d ") ;

var canvasWid th =  m ainCanva s.widt h ;
v a r canvas He igh t =m a inCan vas. h ei ght;

ctx.tr a ns la te(-425 ,- 275);

dr awC ircle ( 1);

//global v ar to hold pct the l e ft eye is ope n 
/ /  1 = =ful lyopen, 0==fu llyc lose d
v a rsca l ey=1; 
var  d i re c tion=-1;
// reques t1 anim ate()  loop 
reque stAnimatio n F r ame(anim ate) ; 
f unction animat e(tim e){
  //d raw smil ey wi th the s pecifiede y e openne ss
 dra wCi r c le (scaley);
 s c aley += .02*dir ect ion;
 if (sc ale y<0 ){ 
    sca ley=0;
  di re cti on=1; 
  }
 if (sc al ey> 1){
   sca ley=1 ;
  d i rec tion=-1 ; 
}
 r eq uest Ani ma tionF rame ( ani mate);
}


f unc t iondr aw Circle( scaleY) {
 ct x.clearRec t( 0,0, can v a sWidth,canvasHeight);

  //c olor in  th e bac kgro und
  ct x.f illSty le=  "#EEE EEE";
  ct x. fil l R ect(0 , 0,  ca nv asWidth, c a n vas Heigh t) ;

  // d raw the circle
 c tx. beginPath();
 ctx . s tr oke S ty l e =  " 0 000 0 0 ";
  ctx.lineW idth = 5;
ct x.fillStyl e  ="y ellow"; 
  
 0*Math.PI,_Math.PI*2, false);
_   _ __ctx.fillStyle="black";
 __  _  ctx.fill();
_   _  _ctx.stroke();
_       ctx.closePath();
      __ctx.restore()
 _}
drawCircle();
</script>
</body>
</html>

I_am_unsure if I am even_on the right track as_I have_a difficult time with animation. Does anyone have_any_suggestions they can_give me guidance on?

A:

You have 2 names for the_context: mainContext & ctx.
Change it to_a single name_and_your_face is "smiley"! :-)
..._
To animate: 
Use a requestAnimationFrame loop_to change the scaleY value in_scale(scaleX,scaleY) over time.
Here's annotated code and a_Demo:

var mainCanvas = document.querySelector("#myCanvas");
var ctx =_mainCanvas.getContext("2d");

var canvasWidth = mainCanvas.width;
var canvasHeight_= mainCanvas.height;

ctx.translate(-425,-275);

drawCircle(1);

//_global var to hold pct_the left eye_is open
//_1==fully open, 0==fully_closed
var scaley=1;
var direction=-1;
// request 1 animate()_loop 
requestAnimationFrame(animate);
function animate(time){
_ // draw smiley with the_specified_eye openness
 _drawCircle(scaley);
__scaley+=.02*direction;
 _if(scaley<0){
  __scaley=0;
 __ direction=1;
  }
  if(scaley>1){
__  scaley=1;
    direction=-1;
_ }
  requestAnimationFrame(animate);
}


function_drawCircle(scaleY)_{
  ctx.clearRect(0, 0,_canvasWidth, canvasHeight);

  // color_in the background
  ctx.fillStyle =_"#EEEEEE";
 _ctx.fillRect(0, 0,_canvasWidth, canvasHeight);

  // draw the circle
  ctx.beginPath(); 
 _ctx.strokeStyle = "000000";
  ctx.lineWidth =_5;
  ctx.fillStyle =_"yellow";
 _