Rev 7 | Rev 11 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 7 | Rev 8 | ||
|---|---|---|---|
| Line 237... | Line 237... | ||
| 237 | } |
237 | } |
| 238 | uint8_t pixData = 0; |
238 | uint8_t pixData = 0; |
| 239 | switch (m_colour) |
239 | switch (m_colour) |
| 240 | { |
240 | { |
| 241 | case BLACK: |
241 | case BLACK: |
| 242 | case INVERT: |
- | |
| 243 | pixData = pixel ? 0 : 1; |
242 | pixData = pixel ? 0 : 1; |
| 244 | break; |
243 | break; |
| 245 | default: |
244 | case WHITE: |
| - | 245 | case OVERLAY: |
|
| - | 246 | case INVERT: |
|
| 246 | pixData = pixel ? 1 : 0; |
247 | pixData = pixel ? 1 : 0; |
| 247 | break; |
248 | break; |
| 248 | } |
249 | } |
| 249 | 250 | ||
| 250 | m_data[x + (y / 8) * m_width] ^= (pixData << (y & 7)); |
251 | m_data[x + (y / 8) * m_width] ^= (pixData << (y & 7)); |
| 251 | 252 | ||
| Line 435... | Line 436... | ||
| 435 | } |
436 | } |
| 436 | 437 | ||
| 437 | /* using Bresenham draw algorithm */ |
438 | /* using Bresenham draw algorithm */ |
| 438 | void |
439 | void |
| 439 | display_t::drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |
440 | display_t::drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |
| 440 | colour_t color) |
441 | colour_t colour) |
| 441 | { |
442 | { |
| 442 | int16_t x, y, dx, dy, //deltas |
443 | int16_t x, y, dx, dy, //deltas |
| 443 | dx2, dy2, //scaled deltas |
444 | dx2, dy2, //scaled deltas |
| 444 | ix, iy, //increase rate on the x and y axis |
445 | ix, iy, //increase rate on the x and y axis |
| 445 | err; //the error term |
446 | err; //the error term |
| - | 447 | ||
| - | 448 | ||
| 446 | uint16_t i; //looping variable |
449 | uint16_t i; //looping variable |
| 447 | 450 | ||
| - | 451 | setPixelMode(colour); |
|
| - | 452 | ||
| 448 | // identify the first pixel |
453 | // identify the first pixel |
| 449 | x = x1; |
454 | x = x1; |
| 450 | y = y1; |
455 | y = y1; |
| 451 | 456 | ||
| 452 | // difference between starting and ending points |
457 | // difference between starting and ending points |
| Line 483... | Line 488... | ||
| 483 | // initialize the error term |
488 | // initialize the error term |
| 484 | err = dy2 - dx; |
489 | err = dy2 - dx; |
| 485 | 490 | ||
| 486 | for (i = 0; i <= dx; i++) |
491 | for (i = 0; i <= dx; i++) |
| 487 | { |
492 | { |
| 488 | drawPixel (x, y, color); |
493 | drawPixel (x, y, 1); |
| 489 | if (err >= 0) |
494 | if (err >= 0) |
| 490 | { |
495 | { |
| 491 | err -= dx2; |
496 | err -= dx2; |
| 492 | y += iy; |
497 | y += iy; |
| 493 | } |
498 | } |
| Line 501... | Line 506... | ||
| 501 | // initialize the error term |
506 | // initialize the error term |
| 502 | err = dx2 - dy; |
507 | err = dx2 - dy; |
| 503 | 508 | ||
| 504 | for (i = 0; i <= dy; i++) |
509 | for (i = 0; i <= dy; i++) |
| 505 | { |
510 | { |
| 506 | drawPixel (x, y, color); |
511 | drawPixel (x, y, 1); |
| 507 | if (err >= 0) |
512 | if (err >= 0) |
| 508 | { |
513 | { |
| 509 | err -= dy2; |
514 | err -= dy2; |
| 510 | x += ix; |
515 | x += ix; |
| 511 | } |
516 | } |