import os
import sys
sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from smartphone_connector import Connector, SpriteClickedMsg, Colors
from examples.server_address import SERVER_ADDRESS

device = Connector(SERVER_ADDRESS, 'FooBar')
device.clear_playground()
device.configure_playground(width=100, height=50, origin_x=50, origin_y=25)
device.add_line(-50, -25, 50, 25, color="purple", line_width=0.2)
lw = 0.1
for x in range(-50, 100, 25):
    device.add_circle(pos_x=x,
                      pos_y=x / 2,
                      radius=2,
                      color='red',
                      border_width=lw,
                      border_color='black',
                      border_style='dashed')
    device.add_line(x1=-50, y1=x / 2, x2=50, y2=x / 2)
    device.add_line(x, -25, x, 25)
    lw = lw + 0.3
device.disconnect()
Пример #2
0
from math import cos, sin, pi, radians

device = Connector(SERVER_ADDRESS, 'FooBar')

RADIUS = 40
device.clear_playground()
device.configure_playground(width=100,
                            height=100,
                            shift_x=-50,
                            shift_y=-50,
                            color=Colors.WHITE)
device.add_circle(radius=RADIUS, pos_x=0, pos_y=0, border_color="black")
for deg in range(0, 360, 6):
    device.add_line(x1=sin(radians(deg)) * (RADIUS - 3),
                    y1=cos(radians(deg)) * (RADIUS - 3),
                    y2=cos(radians(deg)) * RADIUS,
                    x2=sin(radians(deg)) * RADIUS,
                    line_width=0.3)

for deg in range(0, 360, 30):
    device.add_line(x1=sin(radians(deg)) * (RADIUS - 5),
                    y1=cos(radians(deg)) * (RADIUS - 5),
                    y2=cos(radians(deg)) * RADIUS,
                    x2=sin(radians(deg)) * RADIUS,
                    line_width=1)

device.add_line(id='hour',
                x1=0,
                y1=0,
                x2=0,
                y2=RADIUS - 10,
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from examples.server_address import SERVER_ADDRESS
from smartphone_connector import Connector
from math import sin, cos, pi

device = Connector(SERVER_ADDRESS, 'FooBar')

device.clear_playground()
device.configure_playground(
    width=100,
    height=100,
    origin_x=50,
    origin_y=50,
    color="#FF3366"
)
device.add_line(0, 0, 20, 20, line_width=2)
device.add_line(0, 0, 0, 20, line_width=2)
device.add_line(-20, 0, 0, 0, color="white")
device.add_line(0, 20, -20, 20, color="white")
device.add_line(0, 0, 10, 10, color="white")
id = device.add_line(0, 0, 10, 0, color="yellow")
device.sleep(1)
device.update_line(id, x2=0, y2=-10)
with device.add_lines() as add:
    for i in range(30):
        add(x1=-25, y1=i * 2, x2=-45, y2=i * 2, line_width=1, color="lightblue")


device.add_line(0, 0, 10, 0, line_width=2, color='hsla(0, 100%, 50%, 0.5)')
device.add_line(0, 0, 10, 10, line_width=2, color='hsla(120, 100%, 50%, 0.5)')
device.add_line(0, 0, 0, 10, line_width=2, color='hsla(240, 100%, 50%, 0.5)')