javascript - Move bottom circle of cylinder to the bottom -


I am creating cylinders in the canvas . Actually the cylinder was fine till the first time when I modified the cylinder's XY position. On the left I have changed the value in translation to both functions. Now I am confused how to take me from the bottom of the cylinder to the bottom

Now towards the bottom of the cylinder towards the bottom increases.

I have changed the code here:

  function draw cylinder (x, y, w, h, vRadius, fillStyle, strokeStyle) {var w2 = w / 2; Var h2 = h / 2; Var ytop = -h2; Var cpYtop = -h2 - vRadius; Var ybottom = h2; Var cpYbottom = h2 + vRadius; Ctx.save (); Ctx.translate (40, 90); Ctx.beginPath (); Ctx.moveTo (-w2, ytop); Ctx.bezierCurveTo (-w2, cpYtop, w2, cpYtop, w2, ytop); Ctx.lineTo (w2, ybottom); Ctx.bezierCurveTo (w2, cpybottom, -w2, cpybottom, -w2, ybottom); Ctx.closePath (); Performance Scare (Freestyle, Stroke Style); Ctx.restore (); }   

and

  function drawCylinderTop (x, y, w, h, vRadius, fillStyle, strokeStyle) {var w2 = w / 2; Var h2 = h / 2; Var ytop = -h2; Var cpYtop = -h2 - vRadius; Var cpYLowtop = -h2 + vRadius; Ctx.save (); Ctx.translate (40, 90); Ctx.beginPath (); Ctx.moveTo (-w2, ytop); Ctx.bezierCurveTo (-w2, cpYtop, w2, cpYtop, w2, ytop); Ctx.bezierCurveTo (w2, cpYLowtop, -w2, cpYLowtop, -w2, ytop); Ctx.stroke (); Ctx.lineWidth = 3; Performance Scare (Freestyle, Stroke Style); Ctx.restore ();  

Please help me.

Please help me.

You just cx and Cy status:

  var cx = 40; Var cy = 70; Fix   

and Dreselinder Top translation:

  ctx.translate (cx, cy);   



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -