Make +y UP, Move Origin C# System.Drawing.Graphics

前端 未结 3 1629
礼貌的吻别
礼貌的吻别 2021-01-05 16:10

I want the origin to be at the center of my window.


______________
|     ^      |
|     |      |
|     o----->|
|            |
|____________|

.NET wan

3条回答
  •  清歌不尽
    2021-01-05 16:38

    One solution would be to use the TranslateTransform property. Then, instead of using the Point/PointF structs you could create a FlippedPoint/FlippedPointF structs of your own that have implicit casts to Point/PointF (but by casting them the coords get flipped):

    public struct FlippedPoint
    {
        public int X { get; set; }
        public int Y { get; set; }
    
        public FlippedPoint(int x, int y) : this()
        { X = x; Y = y; }
    
        public static implicit operator Point(FlippedPoint point)
        { return new Point(-point.X, -point.Y); }
    
        public static implicit operator FlippedPoint(Point point)
        { return new FlippedPoint(-point.X, -point.Y); }
    }
    

提交回复
热议问题