Completed
Push — master ( 47eeac...631ca5 )
by
unknown
25s queued 11s
created

example_004.start()   A

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 17
rs 9.2833
c 0
b 0
f 0
cc 5
nop 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