Passed
Push — master ( d162e0...e74029 )
by Erik
53s
created

example_004.update()   A

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nop 0
dl 0
loc 17
rs 9.2833
c 0
b 0
f 0
1
from pypen import *
2
from math import sqrt
3
4
def start():
5
    settings.fps = 5
6
7
8
def update():
9
    pixel_size = 2
10
    points = []
11
    for i in range(3):
12
        points.append((random(WIDTH), random(HEIGHT)))
13
14
    for x, y in grid(pixel_size):
15
16
        least_dis = 1000000000000000000
17
18
        for point in points:
19
            d = sqrt((x - point[0])**2 + (y - point[1])**2)
20
            least_dis = d if d < least_dis else least_dis
21
22
        value = clamp(remap(least_dis, 0, 300, 255, 0), 0, 255)
23
        color = (value, 30, 125 + 125 * sin((value**3) / 170000))
24
        rectangle(x, y, pixel_size, pixel_size, color)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable rectangle does not seem to be defined.
Loading history...
25