Beispiel #1
0
import random
import mscreen
reload(mscreen)  # debugging purposes


NUM_POINTS = 50
COLORS = (
    mscreen.COLOR_BLACK,
    mscreen.COLOR_GRAY,
    mscreen.COLOR_RED,
    mscreen.COLOR_GREEN,
    mscreen.COLOR_BLUE,
    mscreen.COLOR_YELLOW,
    mscreen.COLOR_MAGENTA,
    mscreen.COLOR_CYAN,
    mscreen.COLOR_WHITE,
)

# Lets draw some points...
for i in range(NUM_POINTS):
    pos = ((random.randint(-5, 5),
            random.randint(0, 10),
            random.randint(-5, 5)))
    mscreen.drawPoint(pos, color=COLORS[i % 9], size=random.randint(1, 10))

mscreen.refresh()
Beispiel #2
0
# let's draw a square
POINTS = ((2.0, 0.0, 2.0), (2.0, 0.0, -2.0), (-2.0, 0.0, -2.0),
          (-2.0, 0.0, 2.0), (2.0, 0.0, 2.0))
square = mscreen.drawCurve(POINTS, color=mscreen.COLOR_GRAY)

# we can move/rotate/scale it around
square.move(random.randint(-10, 10), random.randint(0, 10),
            random.randint(-10, 10))
square.rotate(random.random() * 180,
              random.random() * 180,
              random.random() * 180)

# mscreen primitives have a full transform (om2)
# let's draw it too!
xfo = mscreen.drawTransform(square.transform)

# let's draw a point on each corner
for p in square.points:
    mscreen.drawPoint(p, color=mscreen.COLOR_LIGHTGRAY, size=4)

# refresh the viewport, this is done explicitly to not slow down batch drawing
mscreen.refresh()

# What about removing stuff?
mscreen.erase(xfo)  # it can be done selectively
mscreen.refresh()

mscreen.clear()  # or just clear the entire screen
mscreen.refresh()