Total Complexity | 5 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from pypen import * |
||
2 | from math import sqrt |
||
3 | |||
4 | |||
5 | def start(): |
||
6 | pixel_size = 2 |
||
7 | points = [] |
||
8 | for i in range(10): |
||
9 | points.append((random(640), random(480))) |
||
10 | |||
11 | for x, y in grid(pixel_size): |
||
12 | |||
13 | least_dis = 1000000000000000000 |
||
14 | |||
15 | for point in points: |
||
16 | d = sqrt((x - point[0])**2 + (y - point[1])**2) |
||
17 | least_dis = d if d < least_dis else least_dis |
||
18 | |||
19 | value = clamp(remap(least_dis, 0, 300, 255, 0), 0, 255) |
||
20 | color = (value, 30, 125 + 125 * sin((value**3) / 170000)) |
||
21 | rectangle(x, y, pixel_size, pixel_size, color) |
||
22 |