You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, you can do somePoint + someDirection to translate a point in a direction, however there are a few similar operations that either feel like they should work but don't, or would be handy in similar ways to this one:
varp=new Point(1,2);// Translate UpLeft using the translate function.// Feels like it should work since the function accepts a delta,// but overload does not exist.p= p.Translate(Direction.UpLeft);// Either one of these could translate the coordinate up left 3 times;// Doesn't work because the * operator for Directions doesn't exist.
p.Translate(Direction.UpLeft *3);p=p+ Direction.UpLeft *3;
I propose the definition of the following functions to remedy this:
// In Point classpublic Point Translate(Directiondir)=> return new Point(X + dir.DeltaX, Y + dir.DeltaY);// In direction classpublicstatic Point operator*(Directiondir,intvalue)=>new Point(dir.DeltaX *value, dir.DeltaY *value);publicstatic implicit operator Point(Directiondir)=>new Point(dir.DeltaX, dir.DeltaY);
The text was updated successfully, but these errors were encountered:
Currently, you can do
somePoint + someDirection
to translate a point in a direction, however there are a few similar operations that either feel like they should work but don't, or would be handy in similar ways to this one:I propose the definition of the following functions to remedy this:
The text was updated successfully, but these errors were encountered: