zoukankan      html  css  js  c++  java
  • GDI编程开发

    1、GDI:图形设备接口,是windows提供的图形技术,可以方便的在屏幕、打印机及其它输出设备上输出各种颜色各种形状的图形;   

    (1)命名空间:using System.Drawing.Text;                

                      using System.Drawing.Imaging;                

                      using System.Drawing.Drawing2D;

    2、GDI+是对以前的版本的一个升级,添加了许多新的功能;是托管的只有在.net的运行库下才能运行.   

    (1)画图的时候一般情况下,写在paint事件中   

    (2)Pen p = new Pen(Color.Red,20);        

           Brush brush = new SolidBrush(Color.Yellow);//刷子派生出了很多刷子,这个是固体的        

           Color c = Color.Black;//定义颜色        

           Color c1 = Color.FromArgb(200, 200, 200);//定义颜色,四个参数可以设置透明度        

           Font mf = new Font("Arial",12);//封闭类,无法继承        

           Point p1 = new Point(0,0);        

           Point p2 = new Point(100,100);//定义点可以画线        

           f.DrawLine(p, p1, p2);        

           Graphics f = this.button2.CreateGraphics();//在控件中画图   

    (3)用按钮画图不会重绘,用Timer事件反复去画;在paint事件中可重绘;   

    (4)DrawString添加字符串

    例子:八卦图形

    Pen p = new Pen(Color.Black, 3);          

    Pen p12 = new Pen(Color.Yellow, 6);           

    Pen p13 = new Pen(Color.Black, 3);           

    Brush brush = new SolidBrush(Color.Red);            

     Brush brush1 = new SolidBrush(Color.Blue);            

    Font mf = new Font("宋体", 12);            

    Graphics f = e.Graphics;             //工具            

    //三个圆            

    f.DrawEllipse(p, 150, 150, 250,250);       

    f.DrawEllipse(p12, 154, 154, 243, 243);            

    f.DrawEllipse(p13, 157, 157, 236, 236);            

    //四个半圆            

    f.FillPie(brush, 157, 157, 236, 236, 90, 180);            

    f.FillPie(brush1, 157, 157, 236, 236, 270, 180);            

    f.FillPie(brush1, 220, 157, 118, 118, 90, 180);            

    f.FillPie(brush, 216, 275, 118, 118, 270, 180);             //两个小圆            

    f.FillEllipse(brush,256,200,38,38);            

    f.FillEllipse(brush1,256, 308, 38, 38);

  • 相关阅读:
    Python 杨辉三角形
    Python 输出由星号*组成的菱形图案
    Python 计算组合数C(n,i),即从n个元素中任选i个,有多少种选法
    Python 快速判断一个数是不是素数
    判断今天是今年的第几天
    Pyhon 输入若干个成绩,求所有成绩的平均分。每输入一个成绩后询问是 否继续输入下一个成绩,回答“yes”就继续输入下一个成绩,回答“no” 就停止输入成绩
    KMP算法
    递归实现求解幂集问题
    Python 用大量小矩形来画曲线
    Python 所谓的艺术操作2(带颜色)
  • 原文地址:https://www.cnblogs.com/heluo/p/2390804.html
Copyright © 2011-2022 走看看