Advertisement
Guest User

Image unscrambling for certain sites

a guest
Apr 28th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.37 KB | None | 0 0
  1. def calcPositionWithRest(a, f, b, e):
  2.     return a * e + (b if a >= f else 0)
  3.  
  4. def calcXCoordinateXRest(a, f, b):
  5.     return (a + 61 * b) % f
  6.  
  7. def calcYCoordinateXRest(a, f, b, e, d):
  8.     c = (1 == d % 2)
  9.     if (c if a < f else not c):
  10.         e = b
  11.         f = 0
  12.     else:
  13.         e = e - b
  14.         f = b
  15.     return (a + 53 * d + 59 * b) % e + f
  16.  
  17. def calcXCoordinateYRest(a, f, b, e, d):
  18.     c = (1 == d % 2)
  19.     if (c if a < b else not c):
  20.         e = e - f
  21.         b = f
  22.     else:
  23.         e = f
  24.         b = 0
  25.     return (a + 67 * d + f + 71) % e + b
  26.  
  27. def calcYCoordinateYRest(a, f, b):
  28.     return (a + 73 * b) % f
  29.  
  30. def shuffle(a,f,b,e,d):
  31.     c = a // b
  32.     h = f // e
  33.     a = a % b
  34.     f = f % e
  35.     u = []
  36.     g = c - 43 * d % c
  37.     if g % c == 0:
  38.         g = (c - 4) % c
  39.     l = h - 47 * d % h
  40.     if l % h == 0:
  41.         l = (h - 4) % h
  42.     if (a > 0) and (f > 0):
  43.         k = g * b
  44.         m = l * e
  45.         u.append({"srcX": k, "srcY": m, "destX": k, "destY": m, "width": a, "height": f})
  46.     if (f > 0):
  47.         for s in range(c):
  48.             p = calcXCoordinateXRest(s,c,d)
  49.             k = calcYCoordinateYRest(p,g,l,h,d)
  50.             p = calcPositionWithRest(p,g,a,b)
  51.             q = k * e
  52.             k = calcPositionWithRest(s,g,a,b)
  53.             m = l * e
  54.             u.append({"srcX": k, "srcY": m, "destX": p, "destY": q, "width": b, "height": f})
  55.     if (a > 0):
  56.         for r in range(h):
  57.             k = calcYCoordinateYRest(r,h,d)
  58.             p = calcXCoordinateYRest(k,g,l,c,d)
  59.             p = p * b
  60.             q = calcPositionWithRest(k,l,f,e)
  61.             k = g * b
  62.             m = calcPositionWithRest(r,l,f,e)
  63.             u.append({"srcX": k, "srcY": m, "destX": p, "destY": q, "width": a, "height": e})
  64.     for s in range(c):
  65.         for r in range(h):
  66.             p = (s + 29 * d + 31 * r) % c
  67.             k = (r + 37 * d + 41 * p) % h
  68.             if p >= calcXCoordinateYRest(k,g,l,c,d):
  69.                 q = a
  70.             else:
  71.                 q = 0
  72.             if k >= calcYCoordinateXRest(p,g,l,h,d):
  73.                 m = f
  74.             else:
  75.                 m = 0
  76.             p = p * b + q
  77.             q = k * e + m
  78.             k = s * b + (a if (s >= g) else 0)
  79.             m = r * e + (f if (r >= l) else 0)
  80.             u.append({"srcX": k, "srcY": m, "destX": p, "destY": q, "width": b, "height": e})
  81.     return u
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement