zoukankan      html  css  js  c++  java
  • C#利用鼠标绘图

            bool G_MouseFlag;
            Pen pen = new Pen(Color.Black);
            Point lastPoint;
            private void _018_MouseMove(object sender, MouseEventArgs e)
            {
                Graphics graphics = this.CreateGraphics();
                if (lastPoint.Equals(Point.Empty))//判断绘图开始点是否为空
                {
                    lastPoint = new Point(e.X, e.Y);//记录鼠标当前位置
                }
                if (G_MouseFlag)//开始绘图
                {
                    Point currentPoint = new Point(e.X, e.Y);//获取鼠标当前位置
                    graphics.DrawLine(pen, currentPoint, lastPoint);//绘图
                }
                lastPoint = new Point(e.X,e.Y);//记录鼠标当前位置
            }
    
            private void _018_MouseDown(object sender, MouseEventArgs e)
            {
                G_MouseFlag = true;//开始绘图标识设置为true
            }
    
            private void _018_MouseUp(object sender, MouseEventArgs e)
            {
                G_MouseFlag = false;//开始绘图标识设置为false
            }
            //画圆
            private void button1_Click(object sender, EventArgs e)
            {
                Graphics graphics = this.CreateGraphics();
                Rectangle gle=new Rectangle(20,20,200,200);
                graphics.DrawEllipse(pen,gle);
            }
  • 相关阅读:
    ugui点击穿透判断
    c#字符串代码,动态创建编译器
    github项目分享
    unity 2d 版的lookAt
    unity全屏截图
    shader例子
    AcWing 329. 围栏障碍训练场
    AcWing 326. XOR和路径
    AcWing 324. 贿赂FIPA
    AcWing 322. 消木块
  • 原文地址:https://www.cnblogs.com/topsyuan/p/11332247.html
Copyright © 2011-2022 走看看