Advertisement
ferrettilorenzo

mixer

Nov 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1.  
  2.  
  3. def mixer(p1,p2,k):
  4. #@param p1: picture
  5. #@param p2:picture
  6. #@param k:int
  7.  canvas= makeEmptyPicture(getHeight(p1),getWidth(p2),white)
  8.  c=copy(p1,p2,canvas)
  9.  for cont in range(0,k):
  10.    for sourcex in range (0,getWidth(p2)):
  11.     targetx=sourcex
  12.     for sourcey in range (0,getHeight(p2)):
  13.      targety=sourcey
  14.      px1=getPixel(p1,targetx,targety)
  15.      px2=getPixel(p2,targetx,targety)
  16.      pc=getPixel(c,targetx,targety)
  17.      setRed=(pc,(getRed(pc)+((getRed(px1)-getRed(px2))/k)))
  18.      setGreen=(pc,(getGreen(pc)+((getGreen(px1)-getGreen(px2))/k)))
  19.      setBlue=(pc,(getBlue(pc)+((getBlue(px1)-getBlue(px2))/k)))
  20.    repaint(c)
  21.      
  22.    
  23. def copy(p1,p2,canvas):
  24. #paramp1:picture
  25. #paramp2:picture
  26. #param canvas :picture
  27. #return: pict
  28.  for sourcex in range (0,getWidth(p2)):
  29.   targetx=sourcex
  30.   for sourcey in  range (0, getHeight(p2)):
  31.    targety=sourcey
  32.    color=getColor(getPixel(p2,sourcex,sourcey))
  33.    setColor(getPixel(canvas,targetx,targety),color)
  34.  return canvas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement