javascript - Move bottom circle of cylinder to the bottom -
I am creating cylinders in the Now towards the bottom of the cylinder towards the bottom increases. I have changed the code here: and Please help me. Please help me. You just and 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
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 (); }
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 ();
cx and
Cy status:
var cx = 40; Var cy = 70; Fix
Dreselinder Top translation:
ctx.translate (cx, cy);
Comments
Post a Comment