Пример #1
0
def draw_board(reversi, dom, playability=True):
    board = atlastk.createHTML("tbody")
    for y, row in enumerate(reversi.board.array()):
        board.pushTag("tr")
        for x, r in enumerate(row):
            board.pushTag("td")
            board.putAttribute("id", str(x) + str(y))
            playable = playability and (r == core.EMPTY) and (
                reversi.board.isAllowed(
                    y, x,
                    reversi.bw if reversi.bw != core.EMPTY else core.BLACK))
            if playable:
                board.putAttribute("xdh:onevent", "Play")
            board.putAttribute("class", {
                core.EMPTY: 'none',
                core.BLACK: 'black',
                core.WHITE: 'white'
            }[r] + (" playable" if playable else ""))
            board.putValue({
                core.EMPTY: ' ',
                core.BLACK: 'X',
                core.WHITE: 'O'
            }[r])
            board.popTag()
        board.popTag()

    dom.inner("board", board)

    dom.setValues({
        "black": reversi.board.count(core.BLACK),
        "white": reversi.board.count(core.WHITE)
    })
Пример #2
0
def drawBoard(reversi, dom, prefetch=False):
    board = atlastk.createHTML("tbody")
    for y, row in enumerate(reversi.board):
        board.pushTag("tr")
        for x, r in enumerate(row):
            board.pushTag("td")
            board.putAttribute("id", str(x) + str(y))
            if (r == EMPTY) and (reversi.isAllowed(y, x, reversi.player)):
                board.putAttribute("xdh:onevent", "Play")
                if (prefetch == True):
                    r = reversi.player
                    board.putAttribute(
                        "style", "opacity: 0.1; background-color: white;")
            board.putAttribute("class", {
                EMPTY: 'none',
                BLACK: 'black',
                WHITE: 'white'
            }[r])
            board.popTag()
        board.popTag()

    dom.inner("board", board)

    dom.setValues({
        "black": reversi.count(BLACK),
        "white": reversi.count(WHITE)
    })
Пример #3
0
def drawSet(set, dom):
    seq = [item['value'] for item in set]
    max = builtins.max(seq)
    min = builtins.min(seq)

    height = int(dom.getAttribute("SVG", "height"))

    min = 0 if min > 0 else min

    svg = atlastk.createHTML()

    for i in range(len(set)):
        svg.pushTag("rect")
        svg.putAttribute("x",
                         str(i * 100 / len(set)) + "%")
        svg.putAttribute("y", height - set[i]["value"] * height / max)
        svg.putAttribute("width",
                         str(100 / len(set)) + "%")
        svg.putAttribute("height",
                         str(100 * set[i]["value"] / max) + "%")
        svg.putTagAndValue("title",
                           set[i]["date"] + " : " + str(set[i]["value"]))
        svg.popTag()

    dom.inner("SVG", svg)

    dom.setValue("Text", set[0]["date"] + " - " + set[len(set) - 1]["date"])
Пример #4
0
    def _draw(self, dom=None):
        if dom == None:
            dom = self._dom

        dom.appendLayout(self._id, self._path)
        self._path = atlastk.createHTML()
        self._autoDrawCount = 0
        dom.flush()
Пример #5
0
 def _reset(self):
     self._posx = 0
     self._posy = 0
     self._angle = 0
     self._color = (0, 0, 0)
     self._autoDrawCount = 0
     self._state = _S_UP
     self._path = atlastk.createHTML()
Пример #6
0
def showWord(dom, secretWord, correctGuesses):
    output = ("_" * len(secretWord))

    for i in range(len(secretWord)):
        if secretWord[i] in correctGuesses:
            output = output[:i] + secretWord[i] + output[i + 1:]

    html = Atlas.createHTML()
    html.put_tag_and_value("h1", output)
    dom.set_layout("output", html)
Пример #7
0
def showWord(dom, secretWord, correctGuesses):
  output = ("_" * len(secretWord))
  
  for i in range(len(secretWord)):
    if secretWord[i] in correctGuesses:
      output = output[:i] + secretWord[i] + output[i + 1:]

  html = atlastk.createHTML()
  html.putTagAndValue("h1", output)
  dom.inner("output", html)
Пример #8
0
def drawBoard(reversi, dom, prefetch=False):
    board = Atlas.createHTML("tbody")
    for y, row in enumerate(reversi.board):
        board.pushTag("tr")
        for x, r in enumerate(row):
            board.pushTag("td")
            board.putAttribute("id", str(x) + str(y))
            if (r == EMPTY) and (reversi.isAllowed(y, x, reversi.player)):
                board.putAttribute("data-xdh-onevent", "Play")
            board.putValue({EMPTY: ' ', BLACK: 'X', WHITE: 'O'}[r])
            board.popTag()
        board.popTag()

    dom.setLayout("board", board)

    dom.setContents({
        "black": reversi.count(BLACK),
        "white": reversi.count(WHITE)
    })
Пример #9
0
def displayContacts(dom, contacts):
  #   html="<tr><td>a</td><td>b</td><td>c</td></tr>"
  html = atlastk.createHTML()
  notes = {}

  for i in range(len(contacts)):
    contact = contacts[i]
    html.pushTag("tr")
    html.putAttribute("id", i)
    html.putAttribute("xdh:onevent", "Select")
    for key in contact:
      if (key == 'Note'):
        id = "Note." + str(i)
        html.pushTag("td")
        html.putAttribute("id", id)
        notes[id] = contact[key]
      else:
        html.putTagAndValue("td", contact[key])
    html.popTag()

  dom.inner("Content", html)

  dom.setValues(notes)
Пример #10
0
def drawGrid(dom):
    board = Atlas.createHTML("g")
    for x in range(0, 4):
        for y in range(0, 4):
            drawSquare(board, x, y)
    dom.setLayout("Stones", board)
Пример #11
0
def setTexts(dom):
    texts = Atlas.createHTML("text")
    for x in range(0, 4):
        for y in range(0, 4):
            setText(texts, x, y)
    dom.setLayout("Texts", texts)
Пример #12
0
    def _clear(self, dom):
        if dom == None:
            dom = self._dom

        self._reset()
        dom.setLayout(self._id, atlastk.createHTML())