Changeset 2005
- Timestamp:
- Nov 17, 2007, 12:35:59 PM (13 years ago)
- Location:
- www/study
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
www/study/part5.html
r2002 r2005 68 68 <h3> 5.2. Accounting for other dimensions </h3> 69 69 70 <p> The following patterns show s three ways to dither the same colour71 using our 8-colour palette. The first one mixes black, yellow and white72 pixels. The second one mixes red, green and cyan pixels. The last one 73 mixes red, green and magenta pixels. But they all visually blend to the 74 same colour: </p>70 <p> The following patterns show four ways to dither the same colour using 71 our 8-colour palette. The first one mixes black, red and white pixels. The 72 second one mixes black, red and cyan pixels. The third mixes black, red, green 73 and magenta pixels. The last one mixes black, red, green and blue pixels. But 74 all patterns visually blend to the same shade: </p> 75 75 76 76 <p style="text-align: center;"> 77 <img src="pat5-1-2.png" width=" 240" height="160"77 <img src="pat5-1-2.png" width="320" height="160" 78 78 class="inline" alt="3 ways to dither the same colour" /> 79 79 </p> -
www/study/study.py
r2002 r2005 536 536 537 537 # Pattern 5.1.2: different colours give the same result 538 dest = Image(( 240, 160))538 dest = Image((320, 160)) 539 539 for x in range(80): 540 540 for y in range(80): 541 r = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7542 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13543 b = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7541 r = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 7 542 g = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 13 543 b = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 13 544 544 dest.setRgb(x, y, r, b, g) 545 545 for y in range(80, 160): 546 546 r = DITHER_BAYER44[y % 4][x % 4] > 7 547 547 g = DITHER_BAYER44[y % 4][x % 4] > 13 548 b = DITHER_BAYER44[y % 4][x % 4] > 7548 b = DITHER_BAYER44[y % 4][x % 4] > 13 549 549 dest.setRgb(x, y, r, b, g) 550 550 for x in range(80, 160): 551 551 for y in range(80): 552 r = DITHER_BAYER44[(y / 4) % 4][(x / 4 + 1) % 4] > 7553 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13554 b = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7552 r = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 7 553 g = DITHER_BAYER44[(y / 8) % 4][(x / 8 + 1) % 4] > 13 554 b = DITHER_BAYER44[(y / 8) % 4][(x / 8 + 1) % 4] > 13 555 555 dest.setRgb(x, y, r, b, g) 556 556 for y in range(80, 160): 557 r = DITHER_BAYER44[y % 4][ (x + 1)% 4] > 7558 g = DITHER_BAYER44[y % 4][ x% 4] > 13559 b = DITHER_BAYER44[y % 4][ x % 4] > 7557 r = DITHER_BAYER44[y % 4][x % 4] > 7 558 g = DITHER_BAYER44[y % 4][(x + 1) % 4] > 13 559 b = DITHER_BAYER44[y % 4][(x + 1) % 4] > 13 560 560 dest.setRgb(x, y, r, b, g) 561 561 for x in range(160, 240): 562 562 for y in range(80): 563 r = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4+ 1) % 4] > 7564 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13565 b = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4) % 4] > 7563 r = DITHER_BAYER44[(y / 8 + 1) % 4][(x / 8 + 1) % 4] > 7 564 g = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 13 565 b = DITHER_BAYER44[(y / 8 + 1) % 4][(x / 8) % 4] > 13 566 566 dest.setRgb(x, y, r, b, g) 567 567 for y in range(80, 160): 568 568 r = DITHER_BAYER44[(y + 1) % 4][(x + 1) % 4] > 7 569 569 g = DITHER_BAYER44[y % 4][x % 4] > 13 570 b = DITHER_BAYER44[(y + 1) % 4][x % 4] > 7 570 b = DITHER_BAYER44[(y + 1) % 4][x % 4] > 13 571 dest.setRgb(x, y, r, b, g) 572 for x in range(240, 320): 573 for y in range(80): 574 r = DITHER_BAYER44[(y / 8 + 1) % 4][(x / 8) % 4] > 7 575 g = DITHER_BAYER44[(y / 8) % 4][(x / 8) % 4] > 13 576 b = DITHER_BAYER44[(y / 8) % 4][(x / 8 + 2) % 4] > 13 577 dest.setRgb(x, y, r, b, g) 578 for y in range(80, 160): 579 r = DITHER_BAYER44[(y + 1) % 4][x % 4] > 7 580 g = DITHER_BAYER44[y % 4][x % 4] > 13 581 b = DITHER_BAYER44[y % 4][(x + 2) % 4] > 13 571 582 dest.setRgb(x, y, r, b, g) 572 583 dest.writePng("pat5-1-2.png")
Note: See TracChangeset
for help on using the changeset viewer.