• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            TanZek's 技術空間

            勇往直前,專注于技術...

            首頁 新隨筆 聯系 聚合 管理
              7 Posts :: 19 Stories :: 13 Comments :: 0 Trackbacks
            DDA直線的生成算法:
            [初級版]
            ?1 POINT?A = { 100 , 100 } ,?B = { 200 , 200 } ;
            ?2 void ?dda_line(HDC & ?hdc)
            ?3 {
            ?4 ????? double ?length;
            ?5 ????? double ?dx,dy;
            ?6 ????? double ?x,y;
            ?7 ????? char ?a[ 20 ];
            ?8
            ?9 ????? if (abs(B.x - A.x)? >= ?abs(B.y - A.y))
            10 ??????????length = abs(B.x - A.x);
            11 ????? else
            12 ??????????length = abs(B.y - A.y);
            13 ?????
            14 ?????dx = ((B.x - A.x) / length);
            15 ?????dy = ((B.y - A.y) / length);
            16
            17 ?????x = A.x + 0.5 ;
            18 ?????y = A.y + 0.5 ;
            19 ?????sprintf(a, " A(%d,%d) " , int (x), int (y));
            20 ?????TextOut(hdc, int (x), int (y),a, 10 );
            21 ????? int ?i = 1 ;
            22 ????? while (i? <= ?length)
            23 ????? {
            24 ??????????SetPixel(hdc, int (x), int (y),RGB( 0 , 0 , 0 ));
            25 ??????????x = x + dx;
            26 ??????????y = y + dy;
            27 ??????????i ++ ;
            28 ?????}

            29 ????sprintf(a, " B(%d,%d) " , int (x), int (y));
            30 ????TextOut(hdc, int (x), int (y),a, 10 );
            31 ???? return ;
            32 }

            33

            看書上出來的一段DDA算法。實踐出來了,拿上來記憶~~
            [修改版]
            ?1 void ?dda_line(HDC & ?hdc,?POINT?A,?POINT?B,? int ?color)
            ?2 {
            ?3 ????? double ?length;
            ?4 ????? double ?dx,dy;
            ?5 ????? double ?x,y;
            ?6 ????? if (abs(B.x - A.x)? >= ?abs(B.y - A.y))
            ?7 ??????????length = abs(B.x - A.x);
            ?8 ????? else
            ?9 ??????????length = abs(B.y - A.y);
            10 ????
            11 ?????dx = ((B.x - A.x) / length);
            12 ?????dy = ((B.y - A.y) / length);
            13
            14 ?????x = A.x + 0.5 ;
            15 ?????y = A.y + 0.5 ;
            16 ????? int ?i = 1 ;
            17 ????? while (i? <= ?length)
            18 ????? {
            19 ??????????SetPixel(hdc, int (x), int (y),?color);
            20 ??????????x = x + dx;
            21 ??????????y = y + dy;
            22 ??????????i ++ ;
            23 ?????}

            24 ???? return ;
            25 }

            26

            為使算法更適用于各種編程方法,加入A和B的點參數,更加入顏色值color。在我的實際應用中,color被用來清除上一條畫線結果的。
            posted on 2006-10-07 06:42 TanZek 閱讀(2356) 評論(0)  編輯 收藏 引用 所屬分類: Subject-Study
            欧美性大战久久久久久| 久久99热只有频精品8| 国内精品久久久人妻中文字幕| 亚洲国产成人久久综合野外| 一本一道久久精品综合| 99麻豆久久久国产精品免费| 人人狠狠综合久久88成人| 97精品依人久久久大香线蕉97| 亚洲国产精品无码久久青草| 亚洲欧美精品一区久久中文字幕| 色婷婷综合久久久久中文字幕| 日韩精品无码久久一区二区三| 亚洲精品高清一二区久久| 久久WWW免费人成一看片| 久久久久久久久久久精品尤物| 亚洲精品tv久久久久| 精品久久久久久久国产潘金莲| 国产毛片欧美毛片久久久| 人妻精品久久无码区| 国产精品毛片久久久久久久 | 午夜天堂精品久久久久| 亚洲国产精品无码久久久秋霞2| 久久久国产乱子伦精品作者| 久久99国产综合精品女同| 91精品观看91久久久久久| 久久久久久毛片免费看| 国产美女亚洲精品久久久综合| 国产精品久久久久久| 亚洲国产天堂久久久久久| 亚洲精品无码专区久久久| 91亚洲国产成人久久精品网址| 久久久久国产精品三级网| 一本色道久久88精品综合| 久久99毛片免费观看不卡| 亚洲国产精品成人AV无码久久综合影院| 色播久久人人爽人人爽人人片aV| 久久久噜噜噜久久中文福利| 无码人妻久久一区二区三区蜜桃| 日本欧美久久久久免费播放网| 青青草原综合久久大伊人导航 | 99久久精品免费看国产一区二区三区 |