valerio_mazza

Funzione scala

Oct 28th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. #Problema della scala slide4b n60.
  2. #scritto in collaborazione con Matteo Giustini
  3.  
  4. def scala(pict, startY, w, h, col):
  5. # @param pict: Picture
  6. # @param startY: Int.
  7. ## coordinata y del primo scalino
  8. # @param w: Int.
  9. ## lunghezza dello scalino
  10. # @param h: Int.
  11. ## altezza dello scalino
  12. # @param col: Color
  13.   HEIGHT = getHeight(pict)
  14.   WIDTH = getWidth(pict)
  15.   endX = w                                  
  16.   endY = startY + h
  17.   startX = 0
  18.   scalaX(pict, startY, HEIGHT, WIDTH, w, h, col, endX, startX)
  19.   scalaY(pict, startY, HEIGHT, WIDTH, w, h, col, endY)
  20.  
  21. def scalaX(pict, startY, HEIGHT, WIDTH, w, h, col, endX, startX):
  22. # disegna le linee orizzontali
  23. # @param endX: Int.
  24. ## coordinata x finale dello scalino
  25. # @param startX: Int.
  26. ## coordinata x iniziale dello scalino
  27.   for y in range(startY, HEIGHT, h):
  28.     for x in range(min(startX, WIDTH), min(endX, WIDTH)):
  29.       pixel = getPixel(pict, x, y)
  30.       setColor(pixel, col)
  31.     startX = endX
  32.     endX = endX + w
  33.    
  34.  
  35. def scalaY(pict, startY, HEIGHT, WIDTH, w, h, col, endY):
  36. # disegna le linee verticali
  37. # @param endY: Int.
  38. ## coordinata y finale dello scalino
  39.   for x in range(w, WIDTH, w):
  40.     for y in range(min(startY, HEIGHT), min(endY, HEIGHT)):
  41.       pixel=getPixel(pict, x, y)
  42.       setColor(pixel, col)
  43.     startY = endY
  44.     endY = endY + h
Add Comment
Please, Sign In to add comment