-1

Here is a bit of my code.

drawingContext.DrawEllipse(this.handOpenBrush, null, handPosition, HandSize, HandSize);

That code works fine.

Though, as soon as I do this, I get the errors that it has some invalid arguments.

drawingContext.DrawEllipse(this.handOpenBrush, null, (handPosition.Offset(20,20)), HandSize, HandSize);

All I am doing is offsetting the handPosition point by (20,20). I do not see what I could of done to cause the program to all of sudden have argument errors.

Anthony
  • 36,459
  • 25
  • 97
  • 163
dyllandry
  • 113
  • 1
  • 11
  • 2
    What language and API are you using (is it actually C# as Anthony's edit guesses)? It's going to be hard for you to get help if you make us guess. Also, what sort of "errors?" Are these compilation errors, errors at runtime? What's the actual *text* of the error? –  Oct 02 '14 at 21:23
  • 3
    Look at what `Point.Offset` returns (or more to the point what it _doesn't_ return) – D Stanley Oct 02 '14 at 21:41
  • looking at your 'This Code Works fine` pline it's only common sense that `handPosition.OffSet` is causing an error can you show all relevant code perhaps you're putting `(handPosition.Offset(20,20))` there is no need for the first `(` – MethodMan Oct 02 '14 at 21:45

2 Answers2

2

Point.Offset doesn't return a new point - it mutates the existing Point. So you need to either mutate the point before making the call to DrawEllipse:

handPosition.Offset(20,20);
drawingContext.DrawEllipse(this.handOpenBrush, null, handPosition, HandSize, HandSize);

or use a method that does return a new Point:

drawingContext.DrawEllipse(this.handOpenBrush, null, Point.Add(handPosition, new Vector(20,20)), HandSize, HandSize);
D Stanley
  • 149,601
  • 11
  • 178
  • 240
0

handPosition is a Point.

Point.Offset() is a method returning void, not a Point, therefore the argument is invalid.

Instead, call handPosition.Offset(20,20) before the drawingContext.DrawEllipse() call, and you can then still pass handPosition in as the third argument.

dyson
  • 866
  • 6
  • 12