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

example_004   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 6

2 Functions

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