( self, x1, y1, x2, y2, type=LINE_SOLID )
| 290 | self._drawLine( x1, y1, x2, y2 ) |
| 291 | |
| 292 | def drawLine( self, x1, y1, x2, y2, type=LINE_SOLID ): |
| 293 | if type == BitMap.LINE_SOLID: |
| 294 | self._drawLine( x1, y1, x2, y2 ) |
| 295 | elif type == BitMap.LINE_DASHED: |
| 296 | # how many segs? |
| 297 | len = hypot( x2-x1, y2-y1 ) |
| 298 | numsegs = len / BitMap._DASH_LEN |
| 299 | dx = ( x2 - x1 ) / numsegs |
| 300 | dy = ( y2 - y1 ) / numsegs |
| 301 | dx2 = dx / 2.0 |
| 302 | dy2 = dy / 2.0 |
| 303 | if ( x2 < x1 ): |
| 304 | x1,x2 = x2,x1 |
| 305 | y1,y2 = y2,y1 |
| 306 | segs = [] |
| 307 | curx = x1 |
| 308 | cury = y1 |
| 309 | for i in range( int(numsegs) ): |
| 310 | segs.append( ( curx, cury, curx + dx2, cury + dy2 ) ) |
| 311 | curx += dx |
| 312 | cury += dy |
| 313 | if curx + dx2 > x2: |
| 314 | segs.append( ( curx, cury, x2, y2 ) ) |
| 315 | else: |
| 316 | segs.append( ( curx, cury, curx + dx2, cury + dy2 ) ) |
| 317 | self._drawLines( segs ) |
| 318 | elif type == BitMap.LINE_DOTTED: |
| 319 | len = hypot( x2-x1, y2-y1 ) |
| 320 | numsegs = len / BitMap._DOT_LEN |
| 321 | dx = ( x2 - x1 ) / numsegs |
| 322 | dy = ( y2 - y1 ) / numsegs |
| 323 | dx2 = dx / 2.0 |
| 324 | dy2 = dy / 2.0 |
| 325 | if ( x2 < x1 ): |
| 326 | x1,x2 = x2,x1 |
| 327 | y1,y2 = y2,y1 |
| 328 | segs = [] |
| 329 | curx = x1 |
| 330 | cury = y1 |
| 331 | for i in range( int(numsegs) ): |
| 332 | segs.append( ( curx, cury, curx + dx2, cury + dy2 ) ) |
| 333 | curx += dx |
| 334 | cury += dy |
| 335 | if curx + dx2 > x2: |
| 336 | segs.append( ( curx, cury, x2, y2 ) ) |
| 337 | else: |
| 338 | segs.append( ( curx, cury, curx + dx2, cury + dy2 ) ) |
| 339 | self._drawLines( segs ) |
| 340 | elif type == BitMap.LINE_DOT_DASH: |
| 341 | len = hypot( x2-x1, y2-y1 ) |
| 342 | numsegs = len / BitMap._DOT_DASH_LEN |
| 343 | dx = ( x2 - x1 ) / numsegs |
| 344 | dy = ( y2 - y1 ) / numsegs |
| 345 | dx3 = dx / 3.0 |
| 346 | dy3 = dy / 3.0 |
| 347 | dx23 = 0.62*dx |
| 348 | dy23 = 0.62*dy |
| 349 | dx56 = 0.78*dx |
no test coverage detected