• <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
            久久精品毛片免费观看| 激情久久久久久久久久| 久久婷婷五月综合色高清| 久久精品aⅴ无码中文字字幕重口| 久久精品欧美日韩精品| 999久久久免费国产精品播放| 欧美粉嫩小泬久久久久久久| 亚洲日韩欧美一区久久久久我| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 久久Av无码精品人妻系列 | 亚洲国产成人精品91久久久 | www久久久天天com| 久久久久久极精品久久久 | 中文字幕亚洲综合久久2| 亚洲国产成人久久综合一区77| 国产色综合久久无码有码| 国产激情久久久久影院| 精品国产VA久久久久久久冰 | 丰满少妇人妻久久久久久| 亚洲伊人久久综合影院| 99久久精品免费| 国产欧美一区二区久久| 日韩乱码人妻无码中文字幕久久 | 久久精品国产影库免费看| 久久99精品国产麻豆宅宅| 日韩AV毛片精品久久久| 久久久久久青草大香综合精品| 97热久久免费频精品99| 久久国产亚洲精品无码| 久久亚洲美女精品国产精品| 久久久久久久波多野结衣高潮 | 亚洲国产小视频精品久久久三级| 伊人久久免费视频| 久久se这里只有精品| 久久精品三级视频| 久久综合伊人77777| 国产精品久久久久久久人人看| 狠狠色丁香婷婷综合久久来来去 | 伊人久久亚洲综合影院| 久久精品国产亚洲av麻豆图片| 久久丫忘忧草产品|