zoukankan      html  css  js  c++  java
  • 标准十字座标系

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace CoordinateSystem
    {
        public partial class Form1 : Form
        {
            int orgX = 20;
            int orgY = 20;//原点距离边框左,下距离
            int move = 20;//格子间隔
            int timerI = 0;
           
            public Form1()
            {
                InitializeComponent();
                timer1.Interval = 1000;
                timer1.Enabled = true;
            }
           
            private void panel1_Paint(object sender, PaintEventArgs e)
            {
               
              
                Draw draw = new Draw();
                draw.DrawX(move,panel1,orgX,orgY);
                draw.DrawY(move, panel1, orgX, orgY);
               
            }
            private void timer1_Tick(object sender, EventArgs e)
            {
                Graphics g = panel1.CreateGraphics();
              
                //double a = Math.Sin(timerI);
                //double c = a * 100;
                //int b = (int)c;
                //g.DrawLine(new Pen(Color.Red), new Point(orgX, panel1.Height - orgY),
                //           new Point(orgX + timerI, panel1.Width - orgY - b));
                g.DrawLine(new Pen(Color.Red), new Point(orgX+timerI*10, panel1.Height - orgY- timerI * 10),
                                           new Point(orgX + timerI * 10+10, panel1.Height - orgY- timerI * 10-10));
                timerI += 1;
            }
        }
        public class Draw
        {
            //X轴方法
            public void DrawX(int move,Panel panel,int orgX,int orgY)//画X轴上分格
            {
               
              
                int a = (panel.Width/2) / move;//X轴有多少格
                Graphics g = panel.CreateGraphics();
               
                g.DrawLine(new Pen(Color.Black, 3), new Point(panel.Width/2, panel.Height),//画X轴长线
                                                    new Point(panel.Width/2, 0));

                for (int i = 0; i < a; i++)
                {
                    g.DrawLine(new Pen(Color.Black, 3), new Point(panel.Width/2+ move * i, panel.Height/2),
                               new Point(panel.Width / 2 + move * i, panel.Height / 2 - 4));//划分+格子
                    g.DrawLine(new Pen(Color.Black, 3),new Point(panel.Width / 2 - move * i, panel.Height / 2),
                                new Point(panel.Width / 2 - move * i, panel.Height / 2 - 4));//划分-格子
                    g.DrawString(i.ToString(), new Font("宋体", 8f), Brushes.Black, panel.Width / 2 + move * i,
                                                                          panel.Height / 2 + 4 );//写X轴+的数字
                    if (i!=0)
                    {
                        g.DrawString("-" + i.ToString(), new Font("宋体", 8f), Brushes.Black, panel.Width / 2 - move * i,
                                                                                              panel.Height / 2 + 4);//写X轴-的数字
                    }
                   
                }
                g.DrawString("X轴", new Font("宋体", 10f), Brushes.Black, panel.Width-30, panel.Height/2+20);
            }
            public void DrawY(int move,Panel pan,int orgX,int orgY)
            {
                Graphics g = pan.CreateGraphics();
                g.DrawLine(new Pen(Color.Black, 3), new Point(0, pan.Height/2),
                                                    new Point(pan.Width, pan.Height / 2));//画Y轴长线
                int a = (pan.Height/2) / move;
                for (int i = 0; i < a; i++)
                {
                    g.DrawLine(new Pen(Color.Black, 3), new Point(pan.Width/2, pan.Height/2 - move * i),
                               new Point(pan.Width / 2 + 4, pan.Height / 2 - move * i));
                    g.DrawLine(new Pen(Color.Black, 3), new Point(pan.Width / 2, pan.Height / 2 + move * i),
                               new Point(pan.Width / 2 + 4, pan.Height / 2 + move * i));
                    if (i!=0)
                    {
                        g.DrawString(i.ToString(), new Font("宋体", 8f), Brushes.Black, pan.Width / 2 - 10,
                        pan.Height / 2 - move * i);
                        g.DrawString("-"+i.ToString(), new Font("宋体", 8f), Brushes.Black, pan.Width / 2 - 15,
                        pan.Height / 2 + move * i);
                    }
                   
                }
                g.DrawString("Y轴", new Font("宋体", 10f),Brushes.Black, orgX, orgY - 20);
               
            }
        }
    }
    自动驱动未来
  • 相关阅读:
    Linux内核的ioctl函数学习
    两个VLC实现播放串流测试
    嵌入Linux启动配置文件
    Qt/Embedded中使用jpeglib
    Flex中使用TabBar ViewStack 控件不加载问题
    Flex 特殊字符及转义符
    undefined reference to `jpeg_std_error(jpeg_error_mgr*)
    OK6410预览并实现截图操作(RGB565)
    C# 工具条控件设置背景色去除边框
    TeamFoundation Server 使用技巧
  • 原文地址:https://www.cnblogs.com/rb-huang/p/hrb_190417_2.html
Copyright © 2011-2022 走看看