Example #1
0
def ttt_segments(text):
    wr = ttt.SEG_Writer()
    wr.arc = False   # approximate arcs with lines
    wr.conic = False # approximate conic with arc/line
    wr.cubic = False # approximate cubic with arc/line
    wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = 50 # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10 # no effect?
    wr.cubic_line_subdivision = 10 # no effect?
    wr.scale = 1
    
    wr.setFont(3)
    # 0  freeserif
    # 1  freeserif bold
    # 2  freeserif italic
    # 3  freeserif bold italic
    # 4  "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf" );
    # 5  "/usr/share/fonts/truetype/freefont/FreeMonoBoldOblique.ttf" ); 
    # 6  "/usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf" )
    # 7  "/usr/share/fonts/truetype/freefont/FreeSans.ttf" );
    # 8  "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf" );
    # 9  "/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf" );
    # 10 "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf" );
    
    ttt.ttt(text,wr) 
    segs = wr.get_segments()
    ext = wr.extents
    return [ext, segs]
Example #2
0
def ttt_segments(text):
    wr = ttt.SEG_Writer()
    wr.arc = False  # approximate arcs with lines
    wr.conic = False  # approximate conic with arc/line
    wr.cubic = False  # approximate cubic with arc/line
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 50  # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.scale = 1

    wr.setFont(3)
    # 0  freeserif
    # 1  freeserif bold
    # 2  freeserif italic
    # 3  freeserif bold italic
    # 4  "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf" );
    # 5  "/usr/share/fonts/truetype/freefont/FreeMonoBoldOblique.ttf" );
    # 6  "/usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf" )
    # 7  "/usr/share/fonts/truetype/freefont/FreeSans.ttf" );
    # 8  "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf" );
    # 9  "/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf" );
    # 10 "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf" );

    ttt.ttt(text, wr)
    segs = wr.get_segments()
    ext = wr.extents
    return [ext, segs]
Example #3
0
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Example #4
0
def ttt_segments(text,scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1)/float(scale)
    ttt.ttt(text,wr) 
    segs = wr.get_segments()
    return segs
Example #5
0
def ttt_segments(text,scale):
    wr = ttt.SEG_Writer()
    wr.arc = False   # approximate arcs with lines
    wr.conic = False # approximate conic with arc/line
    wr.cubic = False # approximate cubic with arc/line
    wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = 50 # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10 # no effect?
    wr.cubic_line_subdivision = 10 # no effect?
    wr.scale = float(1)/float(scale)
    ttt.ttt(text,wr) 
    segs = wr.get_segments()
    return segs
Example #6
0
def draw_ttt(myscreen, text, x, y, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 10  # this increasesn nr of points to 366
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?

    s3 = ttt.ttt(text, wr)
    ext = wr.extents
    print ext
    dx = ext[1] - ext[0]

    segs = wr.get_segments()
    segs = translate(segs, x, y)
    print "number of polygons: ", len(segs)
    np = 0
    for s in segs:
        print " polygon ", np, " has ", len(s), " points"
        np = np + 1
    segs = modify_segments(segs)
    drawLoops(myscreen, segs, ovdvtk.yellow)
Example #7
0
def ttt_segments(text,scale):
    wr = ttt.SEG_Writer()
    wr.arc = False   # approximate arcs with lines
    wr.conic = False # approximate conic with arc/line
    wr.cubic = False # approximate cubic with arc/line
    
    # these parameters influence how we subdivide curves
    wr.conic_biarc_subdivision = 50
    wr.conic_line_subdivision = 50
    wr.cubic_biarc_subdivision = 50
    wr.cubic_line_subdivision = 50
    
    wr.scale = float(1)/float(scale)
    ttt.ttt(text,wr) 
    segs = wr.get_segments()
    return segs
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False  # approximate arcs with lines
    wr.conic = False  # approximate conic with arc/line
    wr.cubic = False  # approximate cubic with arc/line

    # these parameters influence how we subdivide curves
    wr.conic_biarc_subdivision = 50
    wr.conic_line_subdivision = 50
    wr.cubic_biarc_subdivision = 50
    wr.cubic_line_subdivision = 50

    wr.scale = float(1) / float(scale)
    ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Example #9
0
def ttt2ngc(text,scale):
    wr = ttt.NGC_Writer()
    wr.arc   = False   # if False, approximate arcs with lines.
    wr.conic = False   # if False, approximate conic with arc/line 
    wr.cubic = False   # if False, approximate cubic with arc/line 
    
    wr.scale = float(1)/float(scale)
    return ttt.ttt(text,wr)
Example #10
0
def ttt_segments():
    wr = ttt.SEG_Writer()
    wr.scale=1
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    s3 = ttt.ttt("ABC",wr)
    segs = wr.get_segments()
    return segs
Example #11
0
def ttt_segments(text, scale, conic_subdiv):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = conic_subdiv  # this increases nr of points
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.scale = float(1) / float(scale)
    s3 = ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Example #12
0
def ttt_segments(text,scale,conic_subdiv):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = conic_subdiv # this increases nr of points 
    wr.cubic_biarc_subdivision = 10 # no effect?
    wr.cubic_line_subdivision = 10 # no effect?
    wr.scale = float(1)/float(scale)
    s3 = ttt.ttt(text,wr) 
    segs = wr.get_segments()
    return segs
Example #13
0
def ttt_segments(text,scale):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1)/float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = 50 # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10 # no effect?
    wr.cubic_line_subdivision = 10 # no effect?
    s3 = ttt.ttt(text,wr) 
    segs = wr.get_segments()
    return segs
Example #14
0
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 20  # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    s3 = ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Example #15
0
def run_play_game(m):
    tt = ttt.ttt(w=w, h=h, to_win=tw)
    print("yo")
    while True:
        moves = list(tt.legal_moves())
        if False and tt.player() == 'O':
            _, move = minimax(tt)
        else:
            move, p = m.next_move_policy(tt, True)
        tt.play(move)
        print("\033[0;36m\033[1m", end='')
        print(tt)
        print("\033[0m", end='')
        print()
        if tt.game_over():
            print("game over, {}".format(
                "x wins" if tt.state == ttt.X_WINS else "o wins" if tt.state ==
                ttt.O_WINS else "draw"))
            exit(0)
Example #16
0
def ttt2ngc(text, scale):
    wr = ttt.NGC_Writer()
    wr.arc = False  # if False, approximate arcs with lines.
    wr.conic = False  # if False, approximate conic with arc/line
    wr.cubic = False  # if False, approximate cubic with arc/line

    wr.scale = float(1) / float(scale)
    # set the font
    wr.setFont(0)  # FreeSerif
    #wr.setFont(1) # FreeSerifBold
    #wr.setFont(2) # FreeSerifItalic
    #wr.setFont(3) # FreeSerifBoldItalic
    #wr.setFont(4) # FreeMono
    #wr.setFont(5) # FreeMonoBold
    #wr.setFont(6) # FreeMonoBoldOblique
    #wr.setFont(7) # FreeMonoOblique
    #wr.setFont(8) # FreeSans
    #wr.setFont(9) # FreeSansBold
    #wr.setFont(10) # FreeSansBoldOblique
    #wr.setFont(11) # FreeSansOblique

    return ttt.ttt(text, wr)
Example #17
0
def ttt2ngc(text,scale):
    wr = ttt.NGC_Writer()
    wr.arc   = False   # if False, approximate arcs with lines.
    wr.conic = False   # if False, approximate conic with arc/line 
    wr.cubic = False   # if False, approximate cubic with arc/line 
    
    wr.scale = float(1)/float(scale)
    # set the font
    wr.setFont(0) # FreeSerif
    #wr.setFont(1) # FreeSerifBold
    #wr.setFont(2) # FreeSerifItalic
    #wr.setFont(3) # FreeSerifBoldItalic
    #wr.setFont(4) # FreeMono
    #wr.setFont(5) # FreeMonoBold
    #wr.setFont(6) # FreeMonoBoldOblique
    #wr.setFont(7) # FreeMonoOblique
    #wr.setFont(8) # FreeSans
    #wr.setFont(9) # FreeSansBold
    #wr.setFont(10) # FreeSansBoldOblique
    #wr.setFont(11) # FreeSansOblique

    
    return ttt.ttt(text,wr)
Example #18
0
def tt():
    from ttt import ttt
    ttt()
Example #19
0
import ttt

t1 = ttt.ngc()
t = ttt.ngc("abc")
print t

s = ttt.dxf()
print s
s2 = ttt.dxf("dxf")

wr = ttt.NGC_Writer()
# wr.scale = 3
s3 = ttt.ttt("",wr)
print s3
Example #20
0
import sys
import os

import go
import ttt

import numpy as np
import random
import re

if len(sys.argv) == 3:
    tt = ttt.ttt(w=19, h=19, to_win=5)

    print("go")
    while True:
        if False and tt.player() == 'O':
            move = None
        else:
            i = str(input())
            if i == "exit" or i == "quit" or i == "q":
                break
            regex = re.compile('([\d]+), ?([\d]+)')
            rf = regex.findall(i)
            if not rf:
                print("indecipherable")
                continue
            x, y = rf[0]
            x = int(x)
            y = int(y)
            if x < 0 or y < 0 or x >= tt.w or y >= tt.h:
                print("space ({}, {}) is out of bounds".format(x, y))
Example #21
0
 def __init__(self):
     self.board = []
     self.winStatus = EMPTY
     for i in range(9):
         self.board.append(ttt.ttt())
Example #22
0
import ttt

#wr = ttt.NGC_Writer()
wr = ttt.SEG_Writer()

# wr.scale = 3
wr.arc = False
wr.conic = False
wr.cubic = False
s3 = ttt.ttt("LT",wr)
print s3
s = wr.get_segments()
print s