ellipse in haskell CodeWorld

1.6k Views Asked by At

Can anyone tell me how to draw an Ellipse using the CodeWorld package of Haskell? I want it to be like the rectangle function where I give two arguments for length and width. I have tried using solidClosedCurve-am I heading in the right direction?

1

There are 1 best solutions below

1
Li-yao Xia On

Using a closed curve, you can set the 4 vertices like so:

ellipse'(a, b) = closedCurve([(a,0),(0,b),(-a,0),(0,-b)])

Another way to do it is to say that an ellipse is a circle rescaled in one direction.

ellipse(a, b) = scaled(circle(1), a, b)

https://code.world/#Ps8tKc4KH4v8Z4iq91NZsew