国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

C#繪制螞蟻線(xiàn)

2024-07-21 02:25:49
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
菜鳥(niǎo)學(xué)堂:

delegate void lineddaproc(int x, int y, intptr lpdata);
[dllimport("gdi32.dll")]
static extern int linedda(int nxstart, int nystart, int nxend, int nyend,
    lineddaproc lplinefunc, intptr lpdata);
 
private const byte pt_closefigure = 1;
private const byte pt_lineto = 2;
private const byte pt_bezierto = 4;
private const byte pt_moveto = 6;
 
[dllimport("gdi32.dll")]
static extern int setpixel(intptr hdc, int x, int y, int crcolor);
 
graphicspath graphicspath = new graphicspath();
private int counter = 0;
private intptr graphicshandle = intptr.zero;
//設(shè)計(jì)zswang 2007-04-30 wjhu111#21cn.com 尊重作者,轉(zhuǎn)貼請(qǐng)注明出處
 
private void button1_click(object sender, eventargs e)
{
    graphicspath.clearmarkers();
    graphicspath.addrectangle(new rectangle(10, 10, 100, 100));
    timer1.interval = 100;
    timer1.enabled = true;
}
 
private void movingdots(int x, int y, intptr lpdata)
{
    counter = (counter + 1) % 15;
    color vcolor;
    if (counter < 5)
        vcolor = color.white;
    else if (counter < 12)
        vcolor = color.red;
    else vcolor = color.blue;
    setpixel(graphicshandle, x, y, vcolor.r | vcolor.g << 8 | vcolor.b << 16);
}
 
private void timer1_tick(object sender, eventargs e)
{
    graphicshandle = graphics.fromhwnd(handle).gethdc();
    for (int i = 0; i < graphicspath.pathpoints.length; i++)
    {
        if (graphicspath.pathtypes[i] == (byte)(pt_closefigure | pt_lineto))
        {
            for (int j = i; j >= 0; j--)
            {
                if (graphicspath.pathtypes[j] == pt_moveto)
                {
                    linedda(
                        (int)graphicspath.pathpoints[i].x,
                        (int)graphicspath.pathpoints[i].y,
                        (int)graphicspath.pathpoints[j].x,
                        (int)graphicspath.pathpoints[j].y,
                        movingdots, intptr.zero);
                    break;
                }
            }
            continue;
        }
        if (i == graphicspath.pathpoints.length - 1)
            linedda(
                (int)graphicspath.pathpoints[i].x,
                (int)graphicspath.pathpoints[i].y,
                (int)graphicspath.pathpoints[0].x,
                (int)graphicspath.pathpoints[0].y,
                movingdots, intptr.zero);
        else
            linedda(
                (int)graphicspath.pathpoints[i].x,
                (int)graphicspath.pathpoints[i].y,
                (int)graphicspath.pathpoints[i + 1].x,
                (int)graphicspath.pathpoints[i + 1].y,
                movingdots, intptr.zero);
    }
}


 

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 大新县| 遵化市| 石柱| 广安市| 龙游县| 峨眉山市| 青川县| 垣曲县| 常州市| 忻州市| 阳谷县| 临高县| 黄大仙区| 赤城县| 玉环县| 正阳县| 莲花县| 湖南省| 二手房| 荥阳市| 托克托县| 山西省| 保靖县| 耒阳市| 太康县| 额敏县| 玛多县| 共和县| 遂平县| 桂平市| 周至县| 贵州省| 隆化县| 湾仔区| 甘谷县| 百色市| 六枝特区| 郓城县| 长海县| 濮阳市| 扬州市|