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

pypen.grid()   A

Complexity

Conditions 3

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 14
rs 9.85
c 0
b 0
f 0
cc 3
nop 3
1
import sys
2
import re
3
import os
4
from pypen.settings import settings
5
6
def _check_if_executed_with_python():
7
    if not sys.argv:
8
        return
9
10
    if sys.argv[0] == "-m":
11
        return
12
13
    match = re.search("pypen", sys.argv[0])
14
    if match:
15
        return
16
17
    print()
18
    print("It seems like you are trying to run a PyPen sketch using the python command.")
19
    print("Try instead running it with 'pypen {}'!".format(" ".join(sys.argv)))
20
    print()
21
    print("Run 'pypen --help' for more information.")
22
    print()
23
    settings._is_executing_with_python = True
24
25
26
_check_if_executed_with_python()
27
28
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
29
30
from pypen.utils import *
31
from pypen.drawing import *
32
33
TIME = T = DELTA_TIME = DT = FRAME = F = 0
34
WIDTH = settings.width
35
HEIGHT = settings.height
36
37
38
def grid(spacing=1, start_x=0, start_y=0):
39
    global HEIGHT, WIDTH
40
    spacing = max(1, abs(spacing))
41
42
    x = start_x
43
    y = start_y
44
    while y < HEIGHT:
45
        yield x, y
46
47
        x = (x + spacing)
48
49
        if x >= WIDTH:
50
            x = start_x
51
            y += spacing
52
53
54
def pixels():
55
    return grid(1, 0, 0)