Completed
Pull Request — master (#8)
by Erik
01:16
created

example_004   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 17
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A start() 0 17 5
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