geek points if you understand this double points if you
play

Geek points if you understand this. Double points if you can do it - PowerPoint PPT Presentation

Geek points if you understand this. Double points if you can do it in your head. What can we do to improve drawBorder() ? Drawing two vertical lines uses one "recipe"! Each uses a different y value. So: Create a parameterized method


  1. Geek points if you understand this. Double points if you can do it in your head.

  2. What can we do to improve drawBorder() ? Drawing two vertical lines uses one "recipe"! Each uses a different y value. So: Create a parameterized method to draw a vertical line. Do the same for horizontal lines. Make the size of the border a parameter. Make the size of the border grow with the size of the image. Others?

  3. STEP BY STEP public void lighter( double amount ) { Pixel[] pixels = this.getPixels(); double factor = 1 + amount; for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } }

  4. STEP BY STEP Pixel[] pixels = this.getPixels(); double factor = 1 + amount; pixels Pixel[0] Pixel red=127 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5

  5. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } pixels Pixel[0] Pixel red=127 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5

  6. STEP BY STEP for ( int i = 0 ; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } pixels Pixel[0] Pixel red=127 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  7. STEP BY STEP for ( int i = 0; i < pixels.length ; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } pixels Pixel[0] Pixel red=127 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  8. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=127 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  9. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red= 190 green=163 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  10. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=190 green= 244 blue=197 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  11. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=190 green=244 blue= 295 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  12. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=190 green=244 blue=295 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 0

  13. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=190 green=244 blue=295 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  14. STEP BY STEP for ( int i = 0; i < pixels.length ; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } p -> Pixel[0] Pixel red=190 green=244 blue=295 Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  15. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red=127 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  16. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red= 190 green=163 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  17. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red=190 green= 244 blue=197 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  18. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red=190 green=244 blue= 295 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 1

  19. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red=190 green=244 blue=295 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 2

  20. STEP BY STEP for ( int i = 0; i < pixels.length ; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[1] Pixel red=190 green=244 blue=295 Pixel[2] Pixel red=128 green=164 blue=198 ... factor 1.5 i 2

  21. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } Pixel[0] Pixel red=190 green=244 blue=295 Pixel[0] Pixel red=190 green=244 blue=295 p -> Pixel[0] Pixel red=128 green=164 blue=198 ... factor 1.5 i 2 ... AND SO ON

  22. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } ... Pixel[179197] Pixel red=69 green=75 blue=30 p -> Pixel[179198] Pixel red=69 green=75 blue= 30 Pixel[179199] Pixel red=40 green=50 blue=18 factor 1.5 i 179198

  23. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } ... Pixel[179197] Pixel red=69 green=75 blue=30 p -> Pixel[179198] Pixel red=69 green=75 blue=30 Pixel[179199] Pixel red=40 green=50 blue=18 factor 1.5 i 179199

  24. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } ... Pixel[179197] Pixel red=69 green=75 blue=30 Pixel[179198] Pixel red=69 green=75 blue=30 p -> Pixel[179199] Pixel red=40 green=50 blue=18 factor 1.5 i 179199

  25. STEP BY STEP for ( int i = 0; i < pixels.length; i++ ) { Pixel p = pixels[i]; p.setRed ( (int) (p.getRed () * factor) ); p.setGreen( (int) (p.getGreen() * factor) ); p.setBlue ( (int) (p.getBlue () * factor) ); } ... Pixel[179197] Pixel red=69 green=75 blue=30 Pixel[179198] Pixel red=69 green=75 blue=30 p -> Pixel[179199] Pixel red= 60 green=50 blue=18 factor 1.5 i 179199

Recommend


More recommend