def draw(): background(255) grid.draw() grid.show() # Partition if image_score != None: α = image_score.width / image_score.height h = 50 image(image_score, (200, 10), (α * h, h)) # Légende des descripteurs totalisés # if len(tot_harmonicChange)>=2: # text_font(f0) # fill(0) # text_align("CENTER") # p5.text('Somme sur les transitions : HarmonicChange : {}, DiffConcordance = {}, DiffRoughness : {}'.format(int(np.sum(tot_harmonicChange[1:])), int(np.sum(tot_diffConcordance[1:])), int(np.sum(tot_diffRoughness[1:]))),(largeur/2,hauteur-70)) # Légende text_font(f0) fill(50) text_align("CENTER") p5.text( 'Tonnetz [{},{},{}]'.format(geom[0], geom[1], geom[2]) + ', timbre ({},{},{})'.format(K, decr, σ) + ', mémoire ({} acc, decr: {})'.format(L_mem, decr_mem), (largeur / 2, hauteur - 30))
def display(self): """ Display the letter on the window. """ fill(DEFAULT_SENTENCE_COLOR) text_align(DEFAULT_SENTENCE_ALIGNMENT) text_font(self.font) text(self.character, (self.x, self.y))
def draw(self): stroke(0) fill(255) circle((self.x, self.y), self.R * 2, mode='CENTER') text_font(f) fill(0) text_align("CENTER") # text(self.pitch, (self.x, self.y - p5.text_ascent()/2)) p5.text(self.pitch, (self.x, self.y - text_ascent() / 2))
def text(self): if self.is_text: with pf.push_style(): pf.text(self.str, (self.x, self.y + 30)) print(pf.text_ascent(), pf.text_descent(), pf.text_width(self.str)) pf.no_fill() pf.stroke(*self.stroke_rgb) pf.rect((self.x, self.y + 30), pf.text_width(self.str), pf.text_ascent() + pf.text_descent(), mode="CORNER")
def draw(): # pf.image_mode("center") pf.background(255) pf.image(img0,(100,100)) pf.fill(255,0,0) # pf.text_align("LEFT","CENTER") pf.text_size(100) # pf.image_mode("corner") en_str = "hello 你好" pf.text(en_str,(200,200)) pf.rect((100,100), *[100,100])
def displayWord(self, word): self.word = word self.wordLength = len(word) self.spacing = (self.width / (self.wordLength)) / 2 self.offset = (width / 2 - self.width / 2) + self.spacing / 2 self.txt_size = int(self.spacing * 4 / 3) self.GuessFont = p5.create_font("arial.ttf", self.txt_size) p5.text_font(self.GuessFont, self.txt_size) p5.text_align("CENTER", "BASELINE") self.txt_width = p5.text_width("A") for i in range(self.wordLength): p5.fill(255) p5.text(word[i], ((i * 2 * self.spacing) + self.spacing / 2 + self.offset, self.y - (self.txt_width * 4 / 3) - 2)) p5.line((i * 2 * self.spacing + self.offset, self.y), (((i * 2) + 1) * self.spacing + self.offset, self.y))
def draw(): # pf.image_mode("center") # pf.tint() # img_size[0]-=1 pf.background(255) # pf.image(img0,(100,100)) pf.text_font(font) # pf.stroke_weight(0) pf.text_align("center", "center") # pf.stroke(255,0,0) # pf.no_fill() pf.text_size(100) en_str = "hello 你好" pf.fill(255, 0, 0) gap = 100 height = 20 pf.text(en_str, (50, height)) pf.stroke(0, 0, 255) pf.stroke_weight(5) height += gap pf.text(en_str, (50, height)) pf.stroke_weight(-5) height += gap pf.text(en_str, (50, height)) pf.no_fill() height += gap pf.stroke_weight(5) pf.text(en_str, (50, height)) height += gap pf.stroke_weight(-5) pf.text(en_str, (50, height))
def draw(self): for chord in self.chords: chord.draw() for chord in self.chords_dim + self.chords_aug + self.chords_quarte: chord.draw() #Bouton save stroke(0) fill(95, 95, 100, 250) rect((largeur - 90, 0), 90, 25) # stroke(255,255) text_font(f0) fill(0) text_align("RIGHT") p5.text('Enregistrer', (largeur - 10, 5)) #Bouton paramètres fill(95, 95, 100, 250) rect((0, 0), 160, 25) # stroke(255,255) text_font(f0) fill(0) text_align("LEFT") p5.text('Paramètres d\'affichage', (5, 5))
def render(self): self.tank.render() self.render_balls() p.text(str(self.reward), (700, 30))
def draw(): global Man, wordDisplay, newLetter, Game p5.background(0) p5.fill(255) p5.stroke(255) p5.stroke_weight(1) if not Man.GameWon and not Man.GameOver: wordDisplay.displayWord(Game.revealed) p5.fill(255) p5.stroke(255) Man.draw() if not Man.GameWon and not Man.GameOver: if key_is_pressed: if key not in [ "ENTER", "SHIFT", "BACKSPACE", "UNKNOWN", "tab", "UP", "DOWN", "LEFT", "RIGHT" ]: newLetter = str(key).lower() elif key == "BACKSPACE": newLetter = "" elif key == "ENTER": if len(newLetter ) != 0 and newLetter not in Game.guessedLetters: Game.enterLetter(newLetter, Man) newLetter = "" if len(newLetter) != 0: txt_size = 40 EnteredLetterFont = p5.create_font("arial.ttf", txt_size) p5.text_font(EnteredLetterFont, txt_size) p5.text_align("CENTER", "CENTER") p5.text(newLetter, (width / 2, height * 3 / 4 - 20)) guessedLettersstring = "" for i in range(len(Game.guessedLetters)): guessedLettersstring += Game.guessedLetters[i] guessedLettersstring += " " guessedLetterFont = p5.create_font("arial.ttf", 20) p5.text_font(guessedLetterFont, 20) p5.text_align("CENTER", "CENTER") p5.text(("Already used Letters:"), (width / 2, height * 7 / 8)) p5.text(str(guessedLettersstring), (width / 2, (height * 7 / 8) + 25)) Man.checkIfGameOver(Game) if Man.GameWon: txt_size = 30 #txt_size=int((width/7)*4/3) GameWonFont = p5.create_font("arial.ttf", txt_size) p5.text_font(GameWonFont, txt_size) p5.text_align("CENTER", "CENTER") p5.text("YOU WON", (width / 2, height / 2)) p5.text("The Right word was:", (width / 2, height / 2 + 30)) p5.text("{}".format(word), (width / 2, height / 2 + 60)) newLetter = "" if Man.GameOver: txt_size = 30 #txt_size=int((width/9)*4/3) GameOverFont = p5.create_font("arial.ttf", txt_size) p5.text_font(GameOverFont, txt_size) p5.text_align("CENTER", "CENTER") p5.text("YOU LOST", (width / 2, height / 2)) p5.text("The Right word was:", (width / 2, height / 2 + 30)) p5.text("{}".format(word), (width / 2, height / 2 + 60)) newLetter = ""