• <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 閱讀(2355) 評論(0)  編輯 收藏 引用 所屬分類: Subject-Study
            久久精品中文闷骚内射| 久久精品国产亚洲Aⅴ蜜臀色欲| 亚洲欧美国产精品专区久久| 久久有码中文字幕| 久久久久亚洲AV无码观看| 天堂久久天堂AV色综合| AA级片免费看视频久久| 热久久国产欧美一区二区精品 | 久久亚洲欧洲国产综合| 久久国产色av免费看| 青青草国产成人久久91网| 亚洲国产成人久久综合一区77| 久久精品中文无码资源站| 国产AV影片久久久久久 | 国产成人精品综合久久久| 亚洲精品无码久久久久AV麻豆| 久久青青草原亚洲av无码app| 久久精品中文字幕有码| 久久精品国产亚洲av高清漫画 | 伊人久久国产免费观看视频| 久久免费视频观看| 亚洲AV无码一区东京热久久 | 久久精品国产亚洲AV香蕉| 久久午夜无码鲁丝片秋霞| 国产精品嫩草影院久久| 热99re久久国超精品首页| 国产偷久久久精品专区| 人人狠狠综合88综合久久| 久久99精品国产麻豆不卡| 久久国产亚洲精品麻豆| 久久精品a亚洲国产v高清不卡| 久久综合亚洲色一区二区三区| 久久婷婷色综合一区二区| 久久久久亚洲av毛片大| 久久久久这里只有精品| 久久国产精品波多野结衣AV| 97久久精品人人澡人人爽| 国产成人久久精品二区三区| 国内精品久久久久影院网站 | 久久国产AVJUST麻豆| 超级碰碰碰碰97久久久久|