Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_plasma_ripple.py
- import random
- from Tkinter import *
- from PIL import Image, ImageTk
- bell_curve = '''1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 5 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 61 62 63 65 66 67 69 70 71 72 74 75 76 78 79 80 82 83 85 86 88 89 91 92 94 96 97 99 101 103 105 107 108 110 112 114 116 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 160 162 164 167 169 172 174 177 179 182 185 187 190 193 195 198 201 204 206 209 212 215 218 221 224 226 229 232 235 238 241 245 248 251 255 258 262 265 268 272 275 279 282 286 289 292 296 299 303 306 309 313 316 320 323 326 330 333 337 340 344 347 350 354 357 361 364 367 371 374 378 381 384 388 391 395 398 402 405 408 412 415 419 422 425 429 432 436 439 442 446 449 453 456 460 463 466 470 473 477 480 483 487 490 494 497 500 504 507 511 514 518 521 524 528 531 535 538 542 546 549 553 557 561 565 569 572 576 579 582 586 589 593 596 599 603 606 609 613 616 620 623 626 630 633 637 640 643 647 650 653 657 660 664 667 670 674 677 680 684 687 690 694 697 700 704 707 711 714 717 721 724 727 731 734 737 741 744 747 751 754 757 761 764 767 771 774 777 781 784 787 791 794 797 801 804 808 811 814 818 821 825 828 831 835 838 842 845 848 852 855 859 862 866 869 872 875 878 881 884 887 890 893 896 899 901 904 906 909 912 914 916 919 921 924 926 928 930 933 935 937 939 941 943 945 947 949 951 953 955 957 958 960 961 963 964 966 967 968 970 971 972 973 974 975 976 977 978 979 981 982 983 984 984 985 985 986 986 987 987 988 988 989 989 990 990 991 991 992 992 992 993 993 993 994 994 994 995 995 995 995 996 996 996 996 997 997 997 997 997 997 998 998 998 998 998 998 998 998 999 999 999 999 999 999 999 999 999 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000'''.split()
- zzz = ' '.join([z for z in bell_curve[::-1]])
- bell_curve = [int(z)*0.001 for z in bell_curve]
- bell_curve += bell_curve[::-1]
- root = Tk()
- root.title("Tk Plasma Ripple")
- ww = 600
- hh = 600
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- pixels = [(255,0,0)]*(ww*hh)
- img = Image.new("RGB",(ww,hh))
- seq = []
- label = Label(root, image=None)
- label.grid(row=0, column=0)
- rainbow=[]
- def z(r,g,b):
- rainbow.append((r,g,b))
- r,g,b=255,0,0
- for g in range(256):
- z(r,g,b)
- for r in range(254, -1, -1):
- z(r,g,b)
- for b in range(256):
- z(r,g,b)
- for g in range(254, -1, -1):
- z(r,g,b)
- for r in range(256):
- z(r,g,b)
- for b in range(254, -1, -1):
- z(r,g,b)
- rainbow = rainbow[1:-1]+rainbow[::-1]
- max_rgb=len(rainbow)
- def color(z):
- return rainbow[int(z)%max_rgb]
- def plot():
- r2 = cv.index
- for y in range(hh):
- for x in range(ww):
- i = int(x+y*ww)
- sig=0
- x2,y2,r = blobs[0]
- d = (abs(x-y)**2+abs(y-y2)**2)**0.5
- sig += bell_curve[int(d*6)%1000]*1000
- for x2,y2,r in blobs[1:]:
- d = (abs(x-x2)**2+abs(y-y2)**2)**0.5
- sig += bell_curve[int(d*1.5)%1000]*r
- pixels[i] = color(sig)
- cv.index += 1
- #
- class Cv():
- 0
- cv = Cv()
- cv.index = 0
- while 1:
- blobs = [0]*5
- L = len(blobs)
- for i in range(L):
- blobs[i]=[random.randint(20,ww/2-20),random.randint(hh/2-20,hh),random.randint(0,500)]
- plot()
- img.putdata(tuple(pixels))
- photo = ImageTk.PhotoImage(img)
- label.configure(image=photo)
- label.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement