-1

We were drawing arc in my java application using drawArc method provided by java api. That is

drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

I am searching for similar method in Html but i couldn't succed. There is only

drawArc(x, y, radius, startangle, arcangle) method there.

Is there any equivalent method in Html as it in Java. If not then could you please guide me about any alternate method so that i can succeed.

Kosuke Ogawa
  • 7,383
  • 3
  • 31
  • 52
Suri
  • 1
  • 3

1 Answers1

0

There exists an experimental ellipse function in some browsers, but you can use a geometrical transformation (a vertical/horizontal scaling) to obtain the effect. If your original Java call was:

drawArc(x, y, width, height, startAngle, arcAngle)

It be realized with:

if (width>height) {
    gctx.setTransform(width/(float)height,0,0,1,0,0)
    radius = height
} else {
    gctx.setTransform (1,0,0,height/(float)width,0,0)       
    radius = width
}
gctx.drawArc(x, y, radius, startAngle, arcAngle)
Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69