def shapeGen():
	x, y = yield
	(x,y) = yield vibes.drawArrow([x-1, y-1], [x+1, y+1], 0.6, 'k[k]')
	(x,y) = yield vibes.drawAUV(x,y,45,2, 'k[y]')
	(x,y) = yield vibes.drawBox(x-1,x+1,y-2,y+2, "[b]")
	(x,y) = yield vibes.drawBoxesUnion([[x-1,x,y-2,y], [x-0.5,x+1,y-0.5,y+2]], "[r]")
	(x,y) = yield vibes.drawCircle(x,y,1, "g[m]")
	(x,y) = yield vibes.drawEllipse(x,y,2,1,45, color="r[darkCyan]")
	(x,y) = yield vibes.drawLine([[x-0.5, y-1], [x+1, y+0.5]], "k")
	(x,y) = yield vibes.drawPie( (x-2, y-2), (1,2.5), [20,70] , "y[cyan]")
	(x,y) = yield vibes.drawPolygon([[x-1,y-1], [x, y+1], [ x+1, y-1]], "k[orange]")
	(x,y) = yield vibes.drawRing(x,y, 1,2, '[red]')
	# (x,y) = yield vibes.drawPie( (x, y), (1,2), [0,360] , "y[cyan]")
	(x,y) = yield vibes.drawVehicle( x, y, 20, 1, "[darkBlue]")
	(x,y) = yield vibes.drawPoint( x,y, 1, "[k]")
	(x,y) = yield vibes.drawText( x,y, "Text", 1)
Ejemplo n.º 2
0
def shapeGen():
    x, y = yield
    (x, y) = yield vibes.drawArrow([x - 1, y - 1], [x + 1, y + 1], 0.6, 'k[k]')
    (x, y) = yield vibes.drawAUV(x, y, 45, 2, 'k[y]')
    (x, y) = yield vibes.drawBox(x - 1, x + 1, y - 2, y + 2, "[b]")
    (x, y) = yield vibes.drawBoxesUnion(
        [[x - 1, x, y - 2, y], [x - 0.5, x + 1, y - 0.5, y + 2]], "[r]")
    (x, y) = yield vibes.drawCircle(x, y, 1, "g[m]")
    (x, y) = yield vibes.drawEllipse(x, y, 2, 1, 45, color="r[darkCyan]")
    (x, y) = yield vibes.drawLine([[x - 0.5, y - 1], [x + 1, y + 0.5]], "k")
    (x, y) = yield vibes.drawPie((x - 2, y - 2), (1, 2.5), [20, 70], "y[cyan]")
    (x,
     y) = yield vibes.drawPolygon([[x - 1, y - 1], [x, y + 1], [x + 1, y - 1]],
                                  "k[orange]")
    (x, y) = yield vibes.drawRing(x, y, 1, 2, '[red]')
    # (x,y) = yield vibes.drawPie( (x, y), (1,2), [0,360] , "y[cyan]")
    (x, y) = yield vibes.drawVehicle(x, y, 20, 1, "[darkBlue]")
    (x, y) = yield vibes.drawPoint(x, y, 1, "[k]")
    (x, y) = yield vibes.drawText(x, y, "Text", 1)
Ejemplo n.º 3
0
def main(stdscr):
    # Clear screen
    stdscr.clear()
    stdscr.keypad(1)
    begin_x = 20; begin_y = 7
    height = 5; width = 40
    win = curses.newwin(height, width, begin_y, begin_x)
    stdscr.addstr(0,10,"Hit 'space' to quit")
    stdscr.refresh()
    cpt = 0
    key = ''
    x = Interval(1,1.5)
    y = Interval(2,3)
    dth = Interval.HALF_PI.mid()/32.
    th = Interval(0).inflate(2*dth)


    Interval.__str__ = print2
    fout = open("test.txt", "a")
    fout.write("#================ RUN ===============\n")

    while key != ord(' '):

        key = stdscr.getch()
        lower_key = chr(key).lower()

        if lower_key == 'z' :
          y += 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 's' :
          y -= 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'd' :
          x += 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'q' :
          x -= 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'a':
          th += dth/8. if curses.ascii.isupper(key) else dth
        elif lower_key == 'e':
          th -= dth/8. if curses.ascii.isupper(key) else dth

        elif key == curses.KEY_NPAGE:
          th = th.lb() + (Interval(0,th.diam()-dth) | Interval(0))
        elif key == curses.KEY_PPAGE:
          th = th.lb() + (Interval(0,th.diam()+dth) | Interval(0))
        elif key == curses.KEY_RIGHT:
          x = x.lb() + (Interval(0,x.diam()+1) | Interval(0))
        elif key == curses.KEY_LEFT:
          x = x.lb() + (Interval(0,x.diam()-1) | Interval(0))
        elif key == curses.KEY_UP:
          y = y.lb() + (Interval(0,y.diam()+1) | Interval(0))
        elif key == curses.KEY_DOWN:
          y = y.lb() + (Interval(0,y.diam()-1) | Interval(0))

        #
        # # if curses.ascii.ascii(key) == "a":
        #
        # if key == curses.KEY_UP or key == 566:
        #   y += 0.5 if key==566 else 0.1
        # elif key == curses.KEY_DOWN or key == 525:
        #   y -= 0.5 if key==525 else 0.1
        # elif key == curses.KEY_RIGHT or key == 560:
        #   x += 0.5 if key==560 else 0.1
        # elif key == curses.KEY_LEFT or key == 545:
        #   x -= 0.5 if key==545 else 0.1
        # elif key == ord('a') or key == 1:
        #   th += 0.1 if key==1 else 0.05
        # elif key == ord('e') or key == 5:
        #   th -= 0.1 if key==5 else 0.05
        #
        # elif key == ord('A'):
        #   th = th.lb() + (Interval(0,th.diam()-0.1) | Interval(0))
        # elif key == ord('E'):
        #   th = th.lb() + (Interval(0,th.diam()+0.1) | Interval(0))
        # elif key == ord('z'):
        #   x = x.lb() + (Interval(0,x.diam()+1) | Interval(0))
        # elif key == ord('s'):
        #   x = x.lb() + (Interval(0,x.diam()-1) | Interval(0))
        # elif key == ord('d'):
        #   y = y.lb() + (Interval(0,y.diam()+1) | Interval(0))
        # elif key == ord('q'):
        #   y = y.lb() + (Interval(0,y.diam()-1) | Interval(0))

        elif key == ord('R'):
          x = Interval(1,1.5)
          y = Interval(2,3)
          th = Interval(0).inflate(1)


        xx,yy,thh = Catan2(x,y,Interval(th))

        # print(event.Key, event.Ascii, th, thh)
        # print(x, y, th  )
        vibes.clearFigure()
        vibes.drawBox(x[0], x[1], y[0], y[1], 'r')
        vibes.drawPie((0,0), (1e-5,5), th*180./math.pi, "r")
        vibes.drawPie((0,0), (1e-5,5), thh*180./math.pi, "b")
        vibes.drawBox(xx[0], xx[1], yy[0], yy[1], 'b')

        # if key in actions:
        #   x, y, th = actions[key]( x,y,th )
        # fct = actions.get(key, lambda x,y,th:x,y,th)

        stdscr.clear()
        stdscr.addstr(1, 10, "Pressed %s %d"%(lower_key, key))
        stdscr.addstr(1,25,str(curses.ascii.ctrl(key)))
        stdscr.addstr(1,40,str(curses.ascii.ascii(key)))
        stdscr.addstr(1,40,str(curses.ascii.alt(key)))
        stdscr.addstr(3, 20, "x    : %s\t\t%s"%(x,xx))
        stdscr.addstr(4, 20, "y    : %s\t\t%s"%(y,yy))
        stdscr.addstr(5, 20, "theta : %s\t\t%s"%(th, thh))
        if key == ord("t"):
          fout.write("%s %s %s -> %s %s %s\n"%(x,y,th, xx, yy, thh))
        stdscr.refresh()

    curses.endwin()
    fout.write("#===================== END ===============\n");
Ejemplo n.º 4
0
vibes.beginDrawing()
vibes.newFigure("test")
vibes.drawBox(0,1,4,6,color='[#FF12FFA0]', figure='test')
vibes.drawText(12, 12, 'My Text', 0.1, 'b[r]')
vibes.axisAuto()
vibes.drawBox(0.5,2,4,7,color='[#00FFFF66]', figure='test')
vibes.drawBox(-1,0,-4,-6,color='r', figure='test')
vibes.drawLine([[0,0], [4,4]])
vibes.drawEllipse(3, 5, 1, 3, 45)
vibes.drawEllipse(5, 5, 3, 3, 0, angles=[30,60], color='g')

vibes.drawCircle(0, 0, 5)
vibes.drawAUV(0,0, 2, 3, color='r[yellow]')


vibes.drawPie([0,0], [3,4], [45, 90])

vibes.newGroup("Pie", figure="test", format='[cyan]')
vibes.drawPie([0,0], [5,9], [-120, -40], group="Pie")
# vibes.drawPie([0,0], [5,9], [-120, -40], "[b]")

vibes.drawPie([5,2], [1,2], [160, 220]) #, 'g[y]')

# vibes.clearGroup("Pie", figure="test")

vibes.drawPie([0,0], [1,2], [160, 220]) #, 'g[y]')


# exit()
vibes.newFigure("test2")
vibes.setFigureProperties({'x':0, 'y':0, 'width':600, 'height':600})
Ejemplo n.º 5
0
vibes.beginDrawing()
vibes.newFigure("test")
vibes.drawBox(0, 1, 4, 6, color='[#FF12FFA0]', figure='test')
vibes.drawText(12, 12, 'My Text', 0.1, 'b[r]')
vibes.axisAuto()
vibes.drawBox(0.5, 2, 4, 7, color='[#00FFFF66]', figure='test')
vibes.drawBox(-1, 0, -4, -6, color='r', figure='test')
vibes.drawLine([[0, 0], [4, 4]])
vibes.drawEllipse(3, 5, 1, 3, 45)
vibes.drawEllipse(5, 5, 3, 3, 0, angles=[30, 60], color='g')

vibes.drawCircle(0, 0, 5)
vibes.drawAUV(0, 0, 2, 3, color='r[yellow]')

vibes.drawPie([0, 0], [3, 4], [45, 90])

vibes.newGroup("Pie", figure="test", format='[cyan]')
vibes.drawPie([0, 0], [5, 9], [-120, -40], group="Pie")
# vibes.drawPie([0,0], [5,9], [-120, -40], "[b]")

vibes.drawPie([5, 2], [1, 2], [160, 220])  #, 'g[y]')

# vibes.clearGroup("Pie", figure="test")

vibes.drawPie([0, 0], [1, 2], [160, 220])  #, 'g[y]')

# exit()
vibes.newFigure("test2")
vibes.setFigureProperties({'x': 0, 'y': 0, 'width': 600, 'height': 600})
def main(stdscr):
    # Clear screen
    stdscr.clear()
    stdscr.keypad(1)
    begin_x = 20
    begin_y = 7
    height = 5
    width = 40
    win = curses.newwin(height, width, begin_y, begin_x)
    stdscr.addstr(0, 10, "Hit 'space' to quit")
    stdscr.refresh()
    cpt = 0
    key = ''
    x = Interval(1, 1.5)
    y = Interval(2, 3)
    dth = Interval.HALF_PI.mid() / 32.
    th = Interval(0).inflate(2 * dth)

    Interval.__str__ = print2
    fout = open("test.txt", "a")
    fout.write("#================ RUN ===============\n")

    while key != ord(' '):

        key = stdscr.getch()
        lower_key = chr(key).lower()

        if lower_key == 'z':
            y += 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 's':
            y -= 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'd':
            x += 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'q':
            x -= 0.5 if curses.ascii.isupper(key) else 0.1
        elif lower_key == 'a':
            th += dth / 8. if curses.ascii.isupper(key) else dth
        elif lower_key == 'e':
            th -= dth / 8. if curses.ascii.isupper(key) else dth

        elif key == curses.KEY_NPAGE:
            th = th.lb() + (Interval(0, th.diam() - dth) | Interval(0))
        elif key == curses.KEY_PPAGE:
            th = th.lb() + (Interval(0, th.diam() + dth) | Interval(0))
        elif key == curses.KEY_RIGHT:
            x = x.lb() + (Interval(0, x.diam() + 1) | Interval(0))
        elif key == curses.KEY_LEFT:
            x = x.lb() + (Interval(0, x.diam() - 1) | Interval(0))
        elif key == curses.KEY_UP:
            y = y.lb() + (Interval(0, y.diam() + 1) | Interval(0))
        elif key == curses.KEY_DOWN:
            y = y.lb() + (Interval(0, y.diam() - 1) | Interval(0))

        #
        # # if curses.ascii.ascii(key) == "a":
        #
        # if key == curses.KEY_UP or key == 566:
        #   y += 0.5 if key==566 else 0.1
        # elif key == curses.KEY_DOWN or key == 525:
        #   y -= 0.5 if key==525 else 0.1
        # elif key == curses.KEY_RIGHT or key == 560:
        #   x += 0.5 if key==560 else 0.1
        # elif key == curses.KEY_LEFT or key == 545:
        #   x -= 0.5 if key==545 else 0.1
        # elif key == ord('a') or key == 1:
        #   th += 0.1 if key==1 else 0.05
        # elif key == ord('e') or key == 5:
        #   th -= 0.1 if key==5 else 0.05
        #
        # elif key == ord('A'):
        #   th = th.lb() + (Interval(0,th.diam()-0.1) | Interval(0))
        # elif key == ord('E'):
        #   th = th.lb() + (Interval(0,th.diam()+0.1) | Interval(0))
        # elif key == ord('z'):
        #   x = x.lb() + (Interval(0,x.diam()+1) | Interval(0))
        # elif key == ord('s'):
        #   x = x.lb() + (Interval(0,x.diam()-1) | Interval(0))
        # elif key == ord('d'):
        #   y = y.lb() + (Interval(0,y.diam()+1) | Interval(0))
        # elif key == ord('q'):
        #   y = y.lb() + (Interval(0,y.diam()-1) | Interval(0))

        elif key == ord('R'):
            x = Interval(1, 1.5)
            y = Interval(2, 3)
            th = Interval(0).inflate(1)

        xx, yy, thh = Catan2(x, y, Interval(th))

        # print(event.Key, event.Ascii, th, thh)
        # print(x, y, th  )
        vibes.clearFigure()
        vibes.drawBox(x[0], x[1], y[0], y[1], 'r')
        vibes.drawPie((0, 0), (1e-5, 5), th * 180. / math.pi, "r")
        vibes.drawPie((0, 0), (1e-5, 5), thh * 180. / math.pi, "b")
        vibes.drawBox(xx[0], xx[1], yy[0], yy[1], 'b')

        # if key in actions:
        #   x, y, th = actions[key]( x,y,th )
        # fct = actions.get(key, lambda x,y,th:x,y,th)

        stdscr.clear()
        stdscr.addstr(1, 10, "Pressed %s %d" % (lower_key, key))
        stdscr.addstr(1, 25, str(curses.ascii.ctrl(key)))
        stdscr.addstr(1, 40, str(curses.ascii.ascii(key)))
        stdscr.addstr(1, 40, str(curses.ascii.alt(key)))
        stdscr.addstr(3, 20, "x    : %s\t\t%s" % (x, xx))
        stdscr.addstr(4, 20, "y    : %s\t\t%s" % (y, yy))
        stdscr.addstr(5, 20, "theta : %s\t\t%s" % (th, thh))
        if key == ord("t"):
            fout.write("%s %s %s -> %s %s %s\n" % (x, y, th, xx, yy, thh))
        stdscr.refresh()

    curses.endwin()
    fout.write("#===================== END ===============\n")
Ejemplo n.º 7
0
print(vibes.channel, vibes.current_fig)

vibes.beginDrawing()
vibes.newFigure("test")
vibes.drawBox(0, 1, 4, 6, color="[#FF12FFA0]", figure="test")
vibes.drawBox(0.5, 2, 4, 7, color="[#00FFFF66]", figure="test")
vibes.drawBox(-1, 0, -4, -6, color="r", figure="test")
vibes.drawLine([[0, 0], [4, 4]])
vibes.drawEllipse(3, 5, 1, 3, 45)
vibes.drawEllipse(5, 5, 3, 3, 0, angles=[30, 60], color="g")

vibes.drawCircle(0, 0, 5)
vibes.drawAUV(0, 0, 2, 3, color="r[yellow]")

vibes.drawPie([0, 0], [3, 4], [45, 90])

vibes.drawPie([0, 0], [5, 9], [-120, -40], "[b]")

vibes.drawPie([0, 0], [1, 2], [160, 220], "g[y]")

vibes.drawPie([5, 2], [1, 2], [160, 220], "g[y]")


vibes.newFigure("test2")
# vibes.drawBox(-1,0,-4,-6,color='[r]', figure='test2')

# vibes.selectFigure("test")
# vibes.clearFigure()
# vibes.selectFigure("test2")
# vibes.saveImage('./test.svg', "test")