Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Problema della scala slide4b n60.
- #scritto in collaborazione con Matteo Giustini
- def scala(pict, startY, w, h, col):
- # @param pict: Picture
- # @param startY: Int.
- ## coordinata y del primo scalino
- # @param w: Int.
- ## lunghezza dello scalino
- # @param h: Int.
- ## altezza dello scalino
- # @param col: Color
- HEIGHT = getHeight(pict)
- WIDTH = getWidth(pict)
- endX = w
- endY = startY + h
- startX = 0
- scalaX(pict, startY, HEIGHT, WIDTH, w, h, col, endX, startX)
- scalaY(pict, startY, HEIGHT, WIDTH, w, h, col, endY)
- def scalaX(pict, startY, HEIGHT, WIDTH, w, h, col, endX, startX):
- # disegna le linee orizzontali
- # @param endX: Int.
- ## coordinata x finale dello scalino
- # @param startX: Int.
- ## coordinata x iniziale dello scalino
- for y in range(startY, HEIGHT, h):
- for x in range(min(startX, WIDTH), min(endX, WIDTH)):
- pixel = getPixel(pict, x, y)
- setColor(pixel, col)
- startX = endX
- endX = endX + w
- def scalaY(pict, startY, HEIGHT, WIDTH, w, h, col, endY):
- # disegna le linee verticali
- # @param endY: Int.
- ## coordinata y finale dello scalino
- for x in range(w, WIDTH, w):
- for y in range(min(startY, HEIGHT), min(endY, HEIGHT)):
- pixel=getPixel(pict, x, y)
- setColor(pixel, col)
- startY = endY
- endY = endY + h
Add Comment
Please, Sign In to add comment