3

As a part of a bigger project, I'm trying to figure out how to move an object (ellipse in this case). Here is the part of my code that is giving me trouble:

//updating the position of the ellipse
let updatePoints (form : Form) (coords : vector3Dlist ) dtheta showtime =
  let mutable fsttuple = 0
  let mutable sndtuple = 0
  for i in 0..coords.Length-1 do
    fsttuple <- (int (round (fst coords.[i])))
    sndtuple <- (int (round (snd coords.[i])))
    (fillEllipseform.Paint.Add(fun draw->
    let brush=new SolidBrush(Color.Red)  
    draw.Graphics.FillEllipse(brush,fsttuple,sndtuple,10.0f,10.0f)))
    form.Refresh ()

The function uses a list of coordinates to get the new x and y values. This gives me the syntax error "possible overload". I think I'm looking to do something like this:

fillEllipseform.X <- fsttuple

How exactly do i change the x/y-coordinates? The .NET library is very limited with F# example when it comes to the ellipse.

Average_guy
  • 509
  • 4
  • 16
  • 1
    `Form` does not have `X` and `Y` properties. It has a `Location` property of type `Point`. Try fillEllipseform.Location <- Point(fsttuple, sndtuple)` – gradbot Jan 14 '17 at 22:12
  • For being more idiomatic, you might want to remove the mutable variables here, there's really no need for them – Anton Schwaighofer Jan 15 '17 at 16:31

1 Answers1

3

Your issue here is that FillEllipse takes a Brush, and then either 4 ints, or 4 float32s. At the moment you are passing in a mixture, so it isn't sure which overload to pick.

If you chose float32 and without rounding (not sure what the type of vector3Dlist is) then a working version would look like:

//updating the position of the ellipse
let updatePoints (form : Form) (coords : vector3Dlist ) dtheta showtime =
  let mutable fsttuple = 0.0f
  let mutable sndtuple = 0.0f
  for i in 0..coords.Length-1 do
    fsttuple <- fst coords.[i]
    sndtuple <- snd coords.[i]
    (fillEllipseform.Paint.Add(fun draw->
    let brush=new SolidBrush(Color.Red)  
    draw.Graphics.FillEllipse(brush,fsttuple,sndtuple,10.0f,10.0f)))
    form.Refresh ()
Stuart
  • 5,358
  • 19
  • 28