Browse Source

Init commit

master
Fabien 'BioWolf' Z 3 months ago
commit
0ecc1b6687
37 changed files with 993 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +2
    -0
      .idea/.gitignore
  3. +24
    -0
      EVALS/exo_1.py
  4. +49
    -0
      EVALS/exo_2.py
  5. +23
    -0
      EVALS/exo_3.py
  6. BIN
      ZIP/damier_spirale.zip
  7. BIN
      ZIP/robot.zip
  8. +53
    -0
      algorithmique_basique/guess_the_number.py
  9. +66
    -0
      algorithmique_basique/jeu_du_pendu.py
  10. +20
    -0
      algorithmique_basique/random_finder.py
  11. +22
    -0
      algorithmique_basique/scores_list.py
  12. +53
    -0
      turtle/damier_spirale/damier_spirale.py
  13. +48
    -0
      turtle/damier_spirale/spirale_corrected.py
  14. +0
    -0
      turtle/robot/Converter/__init__.py
  15. +20
    -0
      turtle/robot/Converter/__main__.py
  16. BIN
      turtle/robot/Converter/__pycache__/__init__.cpython-37.pyc
  17. BIN
      turtle/robot/Converter/__pycache__/__main__.cpython-37.pyc
  18. BIN
      turtle/robot/Converter/__pycache__/errors.cpython-37.pyc
  19. BIN
      turtle/robot/Converter/__pycache__/seeker.cpython-37.pyc
  20. +10
    -0
      turtle/robot/Converter/errors.py
  21. +45
    -0
      turtle/robot/Converter/seeker.py
  22. +0
    -0
      turtle/robot/Drawer/__init__.py
  23. +20
    -0
      turtle/robot/Drawer/__main__.py
  24. BIN
      turtle/robot/Drawer/__pycache__/__init__.cpython-37.pyc
  25. BIN
      turtle/robot/Drawer/__pycache__/__main__.cpython-37.pyc
  26. BIN
      turtle/robot/Drawer/__pycache__/draw.cpython-37.pyc
  27. BIN
      turtle/robot/Drawer/__pycache__/errors.cpython-37.pyc
  28. BIN
      turtle/robot/Drawer/__pycache__/master.cpython-37.pyc
  29. BIN
      turtle/robot/Drawer/__pycache__/transposer.cpython-37.pyc
  30. +43
    -0
      turtle/robot/Drawer/draw.py
  31. +38
    -0
      turtle/robot/Drawer/errors.py
  32. +56
    -0
      turtle/robot/Drawer/master.py
  33. +56
    -0
      turtle/robot/Drawer/transposer.py
  34. +86
    -0
      turtle/robot/bob.py
  35. +62
    -0
      turtle/robot/improved_bob.py
  36. +38
    -0
      turtle/robot/robot.py
  37. +156
    -0
      turtle/robot/test.toml

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
.vscode/
.idea/
.ZIP/

+ 2
- 0
.idea/.gitignore View File

@@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

+ 24
- 0
EVALS/exo_1.py View File

@@ -0,0 +1,24 @@
# EXO 1

# 1.
li = []

for n in range(10, 1001):
li.append(n ** 2 - 2 * n + 3)

# 2.a
L1 = []

for n in range(101):
if n % 2 == 0:
L1.append(n)

# 2.b
reversed_L1 = L1[::-1]

# 2.c
multiples = []

for e in L1:
if e % 10 == 0:
multiples.append(e)

+ 49
- 0
EVALS/exo_2.py View File

@@ -0,0 +1,49 @@
def fonction(x1, x2, x3, x4):
print(x1, x2, x3, x4)
if x2 < x1:
aux = x2
x2 = x1
x1 = aux
print(x1, x2, x3, x4)
if x3 < x1:
aux1 = x2
aux = x1
x1 = x3
x2 = aux
x3 = aux1
elif x3 < x2:
aux = x2
x2 = x3
x3 = aux
print(x1, x2, x3, x4)
if x4 < x1:
aux2 = x3
aux1 = x2
aux = x1
x1 = x4
x2 = aux
x3 = aux1
x4 = aux2
elif x4 < x2:
aux1 = x3
aux = x2
x2 = x4
x3 = aux
x4 = aux1
elif x4 < x3:
aux = x4
x4 = x3
x3 = aux
print(x1, x2, x3, x4)
return x1


# On obtiendra :
# 178 54 2 23
# 54 178 2 23
# 2 54 178 23
# 2 23 54 178
fonction(178, 54, 2, 23)

# On obtiendra 47 ici
print(fonction(178, 54, 2, 23) + fonction(678, 256, 145, 1078))

+ 23
- 0
EVALS/exo_3.py View File

@@ -0,0 +1,23 @@
from turtle import *


def zigzag(y, cote, couleur):
up()
goto(-200, y)
right(60)
for i in range(6):
dot(20, couleur)
left(120)
forward(cote)
dot(20, couleur)
right(120)
forward(cote)
left(60)
down()

speed(0)

for i in range(3):
zigzag(-87 + i*87, 50, "red")

exitonclick()

BIN
ZIP/damier_spirale.zip View File


BIN
ZIP/robot.zip View File


+ 53
- 0
algorithmique_basique/guess_the_number.py View File

@@ -0,0 +1,53 @@
from random import randint


def guess():
def check_guess(nb_, n):
if n == nb_:
return True
else:
if n < nb_:
return False, 'lower'
elif n > nb_:
return False, 'higher'

nb = randint(0, 1000)
broken = False
tries = 0
answers = {
'five': "Vous êtes à peine {}",
'ten': "Vous êtes un peu {}",
'twenty': "Vous êtes {}",
'fifty': "Vous êtes très {}",
'more': "Vous êtes très largement {}",
'lower': "en dessous",
'higher': "au dessus"
}

answer = int(input("Donnez un nombre : "))
while not broken:
tries += 1
result = check_guess(nb, answer)
if result:
broken = True
print(f"Vous avez trouvé en {tries} essais!")
else:
c = answers[result[1]]
ab = abs(nb - answer)
if ab <= 5:
end = answers['five'].format(c)
elif ab <= 10:
end = answers['ten'].format(c)
elif ab <= 20:
end = answers['twenty'].format(c)
elif ab <= 50:
end = answers['fifty'].format(c)
else:
end = answers['more'].format(c)

print(end)

answer = int(input("Donnez un nombre : "))


guess()

+ 66
- 0
algorithmique_basique/jeu_du_pendu.py View File

@@ -0,0 +1,66 @@
entry = input("Type a word: ").upper()
hiding_format = '-'
word = hiding_format * len(entry)

def sweep_word(letter):
global entry

found = []
for i, c in enumerate([a for a in entry]):
if c == letter:
found.append(i)
return found if found else None

def check_current_word_completion():
global word

found = 0
for c in word:
found += 1 if c == hiding_format else 0

return False if found > 0 else True

def reveal_letter_from_indexes(indexes):
global entry, word

new = [a for a in word]

for i in indexes:
new[i] = entry[i] if new[i] == hiding_format else new[i]

return "".join(new)


# INIT
word = reveal_letter_from_indexes([0, -1])
spaces = sweep_word(' ')
word = reveal_letter_from_indexes(spaces) if spaces else word

print(word)


# RESOLUTION
times, letters = 0, []
while True:
letter = input("Type a letter: ").upper()

if len(letter) > 1:
print("You have to type an only letter. Try again")
continue
if letter in letters or letter == " ":
print("You already gave this letter or this character is not allowed.")
continue

times += 1
letters.append(letter)
indexes = sweep_word(letter)
word = reveal_letter_from_indexes(indexes) if indexes else word

if check_current_word_completion():
print(f"Well done! You guessed the word in {times} times \n"
f"The word was: {entry}")
break
else:
print(word)

+ 20
- 0
algorithmique_basique/random_finder.py View File

@@ -0,0 +1,20 @@
from random import randint


def build_and_count_list(length: int, random_range: tuple):
li = []

s, e = random_range
for i in range(length):
li.append(randint(s, e))

result = {}
for n in range(s, e + 1):
result[n] = 0
for e in li:
result[n] += 1 if e == n else 0
return result


res = build_and_count_list(1000, (1, 10))
print(res)

+ 22
- 0
algorithmique_basique/scores_list.py View File

@@ -0,0 +1,22 @@
from random import randint


def insert_from_score(list_, score):
list_ = sorted(list_, reverse=True)

for k, v in enumerate(list_):
if v <= score:
list_.insert(k, score)
break
return list_



scores = sorted([randint(0, 100) for i in range(10)], reverse=True)
new_score = randint(1, 100)

print(scores)
print(new_score)

print(insert_from_score(scores, new_score))

+ 53
- 0
turtle/damier_spirale/damier_spirale.py View File

@@ -0,0 +1,53 @@
from turtle import*


def carre(c, colour='black', nofill=False):
if nofill is False:
begin_fill()

color(colour)
for i in range(4):
fd(c)
right(90)
if nofill is False:
end_fill()


def ligne(n, c, main_color, secondary_color):
for i in range(n):
if i%2 == 0:
carre(c, colour=main_color)
else:
carre(c, colour=secondary_color)
fd(c)


def damier(n, c, colors):
for i in range(n):
if i%2 == 0:
ligne(n, c, colors[0], colors[1])
else:
ligne(n, c, colors[1], colors[0])
up()
bk(n*c)
lt(90)
fd(c)
rt(90)
down()


def spirale(n, c, colors):
for i in range(n):
if i%2 == 0:
ligne(i, c, colors[0], colors[1])
else:
ligne(i, c, colors[1], colors[0])
up()
fd(c)
rt(90)
down()

speed(0)
spirale(10, 50, ['blue', 'red'])

+ 48
- 0
turtle/damier_spirale/spirale_corrected.py View File

@@ -0,0 +1,48 @@
from turtle import*

colour=0
nb=1

def carre(c):
global colour, nb
if colour:
begin_fill()
colour=0
else:
up()
rt(90)
fd(c/2)
lt(90)
fd(c/2)

write(nb)

bk(c/2)
lt(90)
fd(c/2)
rt(90)

nb += 1
colour=1
for i in range(4):
fd(c)
lt(90)
end_fill()

def ligne(c, n):
for i in range(n):
carre(c)
fd(c)

def spirale(c, n):
for i in range(n):
ligne(c, i+1)
up()
fd(c)
lt(90)
down()

speed(0)
spirale(30, 5)
exitonclick()

+ 0
- 0
turtle/robot/Converter/__init__.py View File


+ 20
- 0
turtle/robot/Converter/__main__.py View File

@@ -0,0 +1,20 @@
import argparse
from .seeker import *


def main():
parser_ = argparse.ArgumentParser()
parser_.add_argument("file", help="the file path which will be decoded")
parser_.add_argument("output_file", help="the name of the file which will be written at the end of the process")

args = parser_.parse_args()

ext = args.file.split('.')[-1]
if ext != 'py':
raise Exception(f"Expecting Python (.py) file, found .{ext} extension")

Seeker(args.file)()


if __name__ == '__main__':
main()

BIN
turtle/robot/Converter/__pycache__/__init__.cpython-37.pyc View File


BIN
turtle/robot/Converter/__pycache__/__main__.cpython-37.pyc View File


BIN
turtle/robot/Converter/__pycache__/errors.cpython-37.pyc View File


BIN
turtle/robot/Converter/__pycache__/seeker.cpython-37.pyc View File


+ 10
- 0
turtle/robot/Converter/errors.py View File

@@ -0,0 +1,10 @@
class MissingConversionBlock(Exception):

def __str__(self):
return "Missing conversion block start/end"


class MissingConversionDescriptor(Exception):

def __str__(self):
return "Missing conversion block descriptor for conversion"

+ 45
- 0
turtle/robot/Converter/seeker.py View File

@@ -0,0 +1,45 @@
from .errors import MissingConversionBlock, MissingConversionDescriptor


class Seeker:

def __init__(self, file_path: str):
self.file_path = file_path

with open(self.file_path, 'r') as file:
self.file = file.read()

self.input, self.output = self.generate_descriptors()

def generate_descriptors(self, *args, **kwargs):

# Now, we detect if the block is there
try:
block = self.file.split("# ########## BEGIN CONVERSION ##########")[1]
block = block.split("# ########## END CONVERSION ##########")[0]
except IndexError:
raise MissingConversionBlock()

try:
descriptor_input = block.split("# BEGIN DESCRIPTOR INPUT")[1]
descriptor_input = descriptor_input.split("# END DESCRIPTOR INPUT")[0]
descriptor_input = descriptor_input.strip()[2:]
except IndexError:
raise MissingConversionDescriptor()

try:
descriptor_output = block.split("# BEGIN DESCRIPTOR OUTPUT")[1]
descriptor_output = descriptor_output.split("# END DESCRIPTOR OUTPUT")[0]
descriptor_output = descriptor_output.split("\n")
del(descriptor_output[0])
del(descriptor_output[-1])

for i in range(len(descriptor_output)):
descriptor_output[i] = descriptor_output[i].strip()[2:]

except IndexError:
raise MissingConversionDescriptor()

return descriptor_input, descriptor_output



+ 0
- 0
turtle/robot/Drawer/__init__.py View File


+ 20
- 0
turtle/robot/Drawer/__main__.py View File

@@ -0,0 +1,20 @@
import argparse
from .master import Master


def main():
parser_ = argparse.ArgumentParser()
parser_.add_argument("file", help="the file path which will be decoded")

args = parser_.parse_args()

ext = args.file.split('.')[-1]

if ext != 'toml':
raise Exception(f"Expecting TOML (.toml) file, found .{ext} extension")

Master(args.file)()


if __name__ == '__main__':
main()

BIN
turtle/robot/Drawer/__pycache__/__init__.cpython-37.pyc View File


BIN
turtle/robot/Drawer/__pycache__/__main__.cpython-37.pyc View File


BIN
turtle/robot/Drawer/__pycache__/draw.cpython-37.pyc View File


BIN
turtle/robot/Drawer/__pycache__/errors.cpython-37.pyc View File


BIN
turtle/robot/Drawer/__pycache__/master.cpython-37.pyc View File


BIN
turtle/robot/Drawer/__pycache__/transposer.cpython-37.pyc View File


+ 43
- 0
turtle/robot/Drawer/draw.py View File

@@ -0,0 +1,43 @@
from turtle import *


def draw_from_list(liste: list, fill=False, size=1):
up()
colour = liste[1]

if fill is True:
begin_fill()

if liste[0] == 'square' or liste[0] == 'rectangle':
color(colour)

for pos in liste:
if isinstance(pos, tuple):
goto(pos[0] * size, pos[1] * size)
down()

pos = liste[2]
goto(pos[0] * size, pos[1] * size)
end_fill()

elif liste[0] == 'dot':
pos, dot_size = liste[2], liste[3]

goto(pos[0] * size, pos[1] * size)
down()
dot(dot_size * size, colour)

elif liste[0] == 'circle':
pos, circle_size, angle = liste[2], liste[3], liste[4]

goto(pos[0] * size, pos[1] * size)
down()
width(2 * size)
color(colour)
circle(circle_size * size, angle)
width()


def draw_from_master(master_list: list, fill=False, size=1):
for element in master_list:
draw_from_list(element, fill=fill, size=size)

+ 38
- 0
turtle/robot/Drawer/errors.py View File

@@ -0,0 +1,38 @@
# Transposer
class WrongDrawingType(Exception):

def __init__(self, type_):
self.type = type_

def __str__(self):
return f"Wrong drawing type: {self.type}."


class MissingDrawingArgument(Exception):

def __init__(self, arg, drawing):
self.arg = arg
self.drawing = drawing

def __str__(self):
return f"Missing argument {self.arg} to draw {self.drawing}"


# TOML Parser
class TOMLParserErrors(Exception):

def __init__(self, name, arg=None):
self.name = name
self.arg = arg


class MissingType(TOMLParserErrors):

def __str__(self):
return f"Missing type in {self.name}"


class MissingStartingPosition(TOMLParserErrors):

def __str__(self):
return f"Missing starting position in {self.name}"

+ 56
- 0
turtle/robot/Drawer/master.py View File

@@ -0,0 +1,56 @@
import toml
from turtle import *
from .errors import *
from .transposer import PoslistTransposer
from .draw import draw_from_master


class Master:

def __init__(self, file_path):
self.parsed = toml.load(file_path)
self.list = []
self.size = 1

def __call__(self, *args, **kwargs):
self.evaluate_options()
self.construct_lists()

draw_from_master(self.list, fill=True, size=self.size)

# exitonclick must be placed in the end, dont ask me why...
if 'exitonclick' in self.parsed['options'] and self.parsed['options']['exitonclick']:
exitonclick()

def evaluate_options(self):
if 'options' in self.parsed:
options = self.parsed['options']

if 'bgcolor' in options:
bgcolor(options['bgcolor'])
if 'ht' in options and options['ht']:
ht()
if 'setup' in options:
setup(options['setup'][0], options['setup'][1])
if 'size' in options:
self.size = options['size']

def construct_lists(self):
for name in self.parsed:
if name != 'options':
element = self.parsed[name]

if 'type' not in element:
raise MissingType(name)
if 'pos' not in element:
raise MissingStartingPosition(name)

t, p, c = element['type'], element['pos'], element['color'] if 'color' in element else None
args_left = element
del(args_left['type'])
del(args_left['pos'])
if 'color' in args_left:
del(args_left['color'])

drawing = PoslistTransposer(t, p, color=c)(args_left)
self.list.append(drawing)

+ 56
- 0
turtle/robot/Drawer/transposer.py View File

@@ -0,0 +1,56 @@
from .errors import WrongDrawingType, MissingDrawingArgument


class PoslistTransposer:

"""
This class, used coupled with draw_from_list() or draw_from_master(), tend to simplify expression needed
to codify positional drawing in Turtle module.

Author: Fabien "BioWolf" Z.
"""

def __init__(self, type_: str, starting_pos: tuple, color=None):
self.type = type_
self.pos = tuple(starting_pos)
self.color = color

def __call__(self, toml_special_arg=None, **kwargs):
args = toml_special_arg if toml_special_arg is not None else kwargs

arguments = {
"square": ["size"],
"rectangle": ["length", "width"],
"dot": ["size"],
"circle": ["size", "angle"]
}

r = arguments[self.type]
if r is None:
raise WrongDrawingType(self.type)

for arg in r:
if arg not in args:
raise MissingDrawingArgument(arg, self.type)

final = [self.type, self.color if self.color is not None else 'black']
result = PoslistTransposer.__dict__[self.type](self, *[args[e] for e in r])

for i in result:
final.append(i)

return final

def square(self, size: int):
pos = self.pos
return [pos, (pos[0] + size, pos[1]), (pos[0] + size, pos[1] - size), (pos[0], pos[1] - size)]

def rectangle(self, length: int, width: int):
pos = self.pos
return [pos, (pos[0] + length, pos[1]), (pos[0] + length, pos[1] - width), (pos[0], pos[1] - width)]

def dot(self, size: int):
return [self.pos, size]

def circle(self, size: int, angle: int):
return [self.pos, size, angle]

+ 86
- 0
turtle/robot/bob.py View File

@@ -0,0 +1,86 @@
from turtle import *
from random import *
import turtle

bgcolor('gray12')
ht()
setup(700, 700)

# Rectangles:
corps = [-40, 40, 40, 40, 40, -40, -40, -40, 'gold']
ceinture = [-40, -40, 40, -40, 40, -50, -40, -50, 'white']
piedg = [-20, -80, -10, -80, -10, -110, -20, -110, 'gold']
piedd = [20, -80, 10, -80, 10, -110, 20, -110, 'gold']
short = [-40, -50, 40, -50, 40, -70, -40, -70, 'brown']
hanche = [-30, -70, 30, -70, 30, -80, -30, -80, 'brown']
boucle = [-5, -40, 5, -40, 5, -60, -5, -60, 'red']
brasg = [-50, -20, -40, -20, -40, -60, -50, -60, 'gold']
brasd = [50, -20, 40, -20, 40, -60, 50, -60, 'gold']
bouche = [-20, -10, 20, -10, 20, -12, -20, -12, 'black']
shoesg = [-30, -110, -10, -110, -10, -120, -30, -120, 'black']
shoesd = [30, -110, 10, -110, 10, -120, 30, -120, 'black']
epg = [-50, -10, -40, -10, -40, -20, -50, -20, 'white']
epd = [50, -10, 40, -10, 40, -20, 50, -20, 'white']
dent1 = [-10, -12, -3, -12, -3, -17, -10, -17, 'white']
dent2 = [10, -12, 3, -12, 3, -17, 10, -17, 'white']

# Taches aleatoires
points = [1, 1, 1, 'orange', 20, 'red']

# Dots
yeux1 = [15, 15, 30, 'white']
yeux2 = [-15, 15, 30, 'white']
ir1 = [20, 15, 15, 'blue']
ir2 = [-10, 15, 15, 'blue']
pup1 = [20, 15, 10, 'black']
pup2 = [-10, 15, 10, 'black']

# Cercles
nez = [2, -2, 5, 260, 'black']

# Liste
liste = [corps, ceinture, short, hanche, boucle, piedg, piedd, shoesg, shoesd, epg, epd, brasg, brasd, points, dent1,
dent2, bouche, yeux1, yeux2, ir1, ir2, pup1, pup2, nez]


# Traceur
def tracer(provided, size=1):
print(provided, len(provided))
if len(provided) == 9:
up()
begin_fill()
for j in range(0, len(provided) - 1, 2):
color(provided[8])
goto(size * provided[j], size * provided[j + 1])
down()
goto(size * provided[0], size * provided[1])
end_fill()
elif len(provided) == 4:
up()
goto(size * provided[0], size * provided[1])
down()
dot(size * provided[2], provided[3])
elif len(provided) == 5:
up()
goto(size * provided[0], size * provided[1])
down()
width(size * 2)
color(provided[4])
circle(size * provided[2], provided[3])
width(1)
elif len(provided) == 6:
for j in range(points[4]):
x = randint(-34, 34)
y = randint(-34, 34)
wid = randint(3, 15)
up()
goto(size * x * provided[0], size * y * provided[1])
down()
dot(size * wid * provided[2], provided[3])


# Calls
for i in range(len(liste)):
tracer(liste[i], size=2)

exitonclick()

+ 62
- 0
turtle/robot/improved_bob.py View File

@@ -0,0 +1,62 @@
from turtle import *
from .Drawer.transposer import PoslistTransposer
from .Drawer.draw import draw_from_master

bgcolor('gray12')
ht()
setup(700, 700)

# ########## BEGIN CONVERSION ##########
# BEGIN DESCRIPTOR INPUT
# {{name}} = PoslistTransposer({{type}}, {{pos}}, {{color|None}})({{*values}})
# END DESCRIPTOR INPUT

# BEGIN DESCRIPTOR OUTPUT
# [{{name}}]
# type = {{type}}
# pos = {{pos}}
# color = {{color}}
# {{*values}}
# END DESCRIPTOR OUTPUT

# Squares
corps = PoslistTransposer('square', (-40, 40), 'gold')(size=80)
epg = PoslistTransposer('square', (-50, -10), 'white')(size=10)
epd = PoslistTransposer('square', (40, -10), 'white')(size=10)

# Rectangles
ceinture = PoslistTransposer('rectangle', (-40, -40), 'white')(length=80, width=10)
piedg = PoslistTransposer('rectangle', (-20, -80), 'gold')(length=10, width=30)
piedd = PoslistTransposer('rectangle', (10, -80), 'gold')(length=10, width=30)
short = PoslistTransposer('rectangle', (-40, -50), 'brown')(length=80, width=20)
hanche = PoslistTransposer('rectangle', (-30, -70), 'brown')(length=60, width=10)
boucle = PoslistTransposer('rectangle', (-5, -40), 'red')(length=10, width=20)
brasg = PoslistTransposer('rectangle', (-50, -20), 'gold')(length=10, width=40)
brasd = PoslistTransposer('rectangle', (40, -20), 'gold')(length=10, width=40)
bouche = PoslistTransposer('rectangle', (-20, -10))(length=40, width=2)
shoesg = PoslistTransposer('rectangle', (-30, -110))(length=20, width=10)
shoesd = PoslistTransposer('rectangle', (10, -110))(length=20, width=10)
dent1 = PoslistTransposer('rectangle', (-10, -12), 'white')(length=7, width=5)
dent2 = PoslistTransposer('rectangle', (0, -12), 'white')(length=7, width=5)

# Dots
yeux1 = PoslistTransposer('dot', (15, 15), 'white')(size=30)
yeux2 = PoslistTransposer('dot', (-15, 15), 'white')(size=30)
ir1 = PoslistTransposer('dot', (20, 15), 'blue')(size=15)
ir2 = PoslistTransposer('dot', (-10, 15), 'blue')(size=15)
pup1 = PoslistTransposer('dot', (20, 15))(size=10)
pup2 = PoslistTransposer('dot', (-10, 15))(size=10)

# Cercle
nez = PoslistTransposer('circle', (2, -2))(size=5, angle=260)

# ########## END CONVERSION ##########

# Liste
liste = [corps, ceinture, short, hanche, boucle, piedg, piedd, shoesg, shoesd, epg, epd, brasg, brasd, dent1,
dent2, bouche, yeux1, yeux2, ir1, ir2, pup1, pup2, nez]

# Draw
draw_from_master(liste, fill=True, size=2)

exitonclick()

+ 38
- 0
turtle/robot/robot.py View File

@@ -0,0 +1,38 @@
from turtle import *
from Drawer.transposer import PoslistTransposer
from Drawer.draw import draw_from_master

c1 = PoslistTransposer('square', (-50, 50), color='purple')(size=100)
c2 = [
'yellow',
(-70, 80),
(70, 80),
(70, 60),
(-70, 60)
]
c3 = [
'red',
(-70, -60),
(70, -60),
(70, -80),
(-70, -80)

]

body = PoslistTransposer('square', (-50, 50), color='purple')(size=100)
head = PoslistTransposer('square', (-20, 100), color='yellow')(size=40)
left_eye = PoslistTransposer('square', (-15, 90), color='green')(size=10)
right_eye = PoslistTransposer('square', (5, 90), color='green')(size=10)
mouth = PoslistTransposer('rectangle', (-10, 70), color='green')(length=20, width=5)

left_leg = PoslistTransposer('rectangle', (-30, -60), color='blue')(length=20, width=60)
right_leg = PoslistTransposer('rectangle', (10, -60), color='blue')(length=20, width=60)

left_arm = PoslistTransposer('rectangle', (-120, 10), color='blue')(length=60, width=20)
right_arm = PoslistTransposer('rectangle', (60, 10), color='blue')(length=60, width=20)

person = [body, head, left_eye, right_eye, mouth, left_leg, right_leg, left_arm, right_arm]

draw_from_master(person, fill=True)

exitonclick()

+ 156
- 0
turtle/robot/test.toml View File

@@ -0,0 +1,156 @@
[options]
bgcolor = 'gray12'
ht = true
setup = [700, 700]
exitonclick = true
size = 2

# Squares
[corps]
type = 'square'
pos = [-40, 40]
color = 'gold'
size = 80

[epg]
type = 'square'
pos = [-50, -10]
color = 'white'
size = 10

[epd]
type = 'square'
pos = [40, -10]
color = 'white'
size = 10

# Rectangles
[ceinture]
type = 'rectangle'
pos = [-40, -40]
color = 'white'
length = 80
width = 10

[piedg]
type = 'rectangle'
pos = [-20, -80]
color = 'gold'
length = 10
width = 30

[piedd]
type = 'rectangle'
pos = [10, -80]
color = 'gold'
length = 10
width = 30

[short]
type = 'rectangle'
pos = [-40, -50]
color = 'brown'
length = 80
width = 20

[hanche]
type = 'rectangle'
pos = [-30, -70]
color = 'brown'
length = 60
width = 10

[boucle]
type = 'rectangle'
pos = [-5, -40]
color = 'red'
length = 10
width = 20

[brasg]
type = 'rectangle'
pos = [-50, -20]
color = 'gold'
length = 10
width = 40

[brasd]
type = 'rectangle'
pos = [40, -20]
color = 'gold'
length = 10
width = 40

[bouche]
type = 'rectangle'
pos = [-20, -10]
length = 40
width = 2

[shoesg]
type = 'rectangle'
pos = [-30, -110]
length = 20
width = 10

[shoesd]
type = 'rectangle'
pos = [10, -110]
length = 20
width = 10

[dent1]
type = 'rectangle'
pos = [-10, -12]
color = 'white'
length = 7
width = 5

[dent2]
type = 'rectangle'
pos = [0, -12]
color = 'white'
length = 7
width = 5

# Dots
[yeux1]
type = 'dot'
pos = [15, 15]
color = 'white'
size = 30

[yeux2]
type = 'dot'
pos = [-15, 15]
color = 'white'
size = 30

[ir1]
type = 'dot'
pos = [20, 15]
color = 'blue'
size = 15

[ir2]
type = 'dot'
pos = [-10, 15]
color = 'blue'
size = 15

[pup1]
type = 'dot'
pos = [20, 15]
size = 10

[pup2]
type = 'dot'
pos = [-10, 15]
size = 10

# Circle
[nez]
type = 'circle'
pos = [2, -2]
size = 5
angle = 260

Loading…
Cancel
Save