From 8a3aa1ab08857042cf9de16e6576349f81e8ee61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 17 Dec 2018 11:57:40 +0100 Subject: [PATCH] [apps/code] Add turtle functions in th python toolbox --- apps/code/catalog.de.i18n | 39 +++++++++++++++++++++++--------- apps/code/catalog.en.i18n | 39 +++++++++++++++++++++++--------- apps/code/catalog.es.i18n | 39 +++++++++++++++++++++++--------- apps/code/catalog.fr.i18n | 39 +++++++++++++++++++++++--------- apps/code/catalog.pt.i18n | 39 +++++++++++++++++++++++--------- apps/code/catalog.universal.i18n | 28 +++++++++++++++++++---- apps/code/python_toolbox.cpp | 31 ++++++++++++++++++------- 7 files changed, 186 insertions(+), 68 deletions(-) diff --git a/apps/code/catalog.de.i18n b/apps/code/catalog.de.i18n index 680267547..85677229a 100644 --- a/apps/code/catalog.de.i18n +++ b/apps/code/catalog.de.i18n @@ -94,16 +94,33 @@ PythonSum = "Sum the items of a list" PythonTan = "Tangent" PythonTanh = "Hyperbolic tangent" PythonTrunc = "x truncated to an integer" +PythonTurtleBackward = "Move backward by x pixels" +PythonTurtleBlack = "Black color" +PythonTurtleBlue = "Blue color" +PythonTurtleBrown = "Brown color" +PythonTurtleCircle = "Circle of radius r pixels" +PythonTurtleColor = "Set the pen color" +PythonTurtleForward = "Move forward by x pixels" PythonTurtleFunction = "turtle module function prefix" -PythonTurtleForward = "Move the turtle forward" -PythonTurtleBackward = "Move the turtle backward" -PythonTurtleLeft = "Turn turtle to the left" -PythonTurtleRight = "Turn turtle to the right" -PythonTurtlePosition = "Get turtle position" -PythonTurtleSetposition = "Set turtle position" -PythonTurtleHeading = "Get turtle angle" -PythonTurtleSetheading = "Set turtle angle" -PythonTurtleSpeed = "Set turtle speed" -PythonTurtlePencolor = "Set pen color" -PythonTurtlePensize = "Get/Set pen width" +PythonTurtleGoto = "Move to (x,y) coordinates" +PythonTurtleGreen = "Green color" +PythonTurtleGrey = "Grey color" +PythonTurtleHeading = "Return the current heading" +PythonTurtleIsdown = "Return True if the pen is down" +PythonTurtleLeft = "Turn left by a degrees" +PythonTurtleOrange = "Orange color" +PythonTurtlePendown = "Pull the pen down" +PythonTurtlePensize = "Set the line thickness to x pixels" +PythonTurtlePenup = "Pull the pen up" +PythonTurtlePink = "Pink color" +PythonTurtlePosition = "Return the current (x,y) location" +PythonTurtlePurple = "Purple color" +PythonTurtleRed = "Red color" +PythonTurtleReset = "Reset the drawing" +PythonTurtleRight = "Turn right by a degrees" +PythonTurtleSetheading = "Set the orientation to a degrees" +PythonTurtleSetposition = "Positionne la tortue" +PythonTurtleSpeed = "Drawing speed between 0 and 10" +PythonTurtleWhite = "White color" +PythonTurtleYellow = "Yellow color" PythonUniform = "Floating point number in [a,b]" diff --git a/apps/code/catalog.en.i18n b/apps/code/catalog.en.i18n index e308b0f3c..e81f085b6 100644 --- a/apps/code/catalog.en.i18n +++ b/apps/code/catalog.en.i18n @@ -94,16 +94,33 @@ PythonSum = "Sum the items of a list" PythonTan = "Tangent" PythonTanh = "Hyperbolic tangent" PythonTrunc = "x truncated to an integer" +PythonTurtleBackward = "Move backward by x pixels" +PythonTurtleBlack = "Black color" +PythonTurtleBlue = "Blue color" +PythonTurtleBrown = "Brown color" +PythonTurtleCircle = "Circle of radius r pixels" +PythonTurtleColor = "Set the pen color" +PythonTurtleForward = "Move forward by x pixels" PythonTurtleFunction = "turtle module function prefix" -PythonTurtleForward = "Move the turtle forward" -PythonTurtleBackward = "Move the turtle backward" -PythonTurtleLeft = "Turn turtle to the left" -PythonTurtleRight = "Turn turtle to the right" -PythonTurtlePosition = "Get turtle position" -PythonTurtleSetposition = "Set turtle position" -PythonTurtleHeading = "Get turtle angle" -PythonTurtleSetheading = "Set turtle angle" -PythonTurtleSpeed = "Set turtle speed" -PythonTurtlePencolor = "Set pen color" -PythonTurtlePensize = "Get/Set pen width" +PythonTurtleGoto = "Move to (x,y) coordinates" +PythonTurtleGreen = "Green color" +PythonTurtleGrey = "Grey color" +PythonTurtleHeading = "Return the current heading" +PythonTurtleIsdown = "Return True if the pen is down" +PythonTurtleLeft = "Turn left by a degrees" +PythonTurtleOrange = "Orange color" +PythonTurtlePendown = "Pull the pen down" +PythonTurtlePensize = "Set the line thickness to x pixels" +PythonTurtlePenup = "Pull the pen up" +PythonTurtlePink = "Pink color" +PythonTurtlePosition = "Return the current (x,y) location" +PythonTurtlePurple = "Purple color" +PythonTurtleRed = "Red color" +PythonTurtleReset = "Reset the drawing" +PythonTurtleRight = "Turn right by a degrees" +PythonTurtleSetheading = "Set the orientation to a degrees" +PythonTurtleSetposition = "Positionne la tortue" +PythonTurtleSpeed = "Drawing speed between 0 and 10" +PythonTurtleWhite = "White color" +PythonTurtleYellow = "Yellow color" PythonUniform = "Floating point number in [a,b]" diff --git a/apps/code/catalog.es.i18n b/apps/code/catalog.es.i18n index e308b0f3c..e81f085b6 100644 --- a/apps/code/catalog.es.i18n +++ b/apps/code/catalog.es.i18n @@ -94,16 +94,33 @@ PythonSum = "Sum the items of a list" PythonTan = "Tangent" PythonTanh = "Hyperbolic tangent" PythonTrunc = "x truncated to an integer" +PythonTurtleBackward = "Move backward by x pixels" +PythonTurtleBlack = "Black color" +PythonTurtleBlue = "Blue color" +PythonTurtleBrown = "Brown color" +PythonTurtleCircle = "Circle of radius r pixels" +PythonTurtleColor = "Set the pen color" +PythonTurtleForward = "Move forward by x pixels" PythonTurtleFunction = "turtle module function prefix" -PythonTurtleForward = "Move the turtle forward" -PythonTurtleBackward = "Move the turtle backward" -PythonTurtleLeft = "Turn turtle to the left" -PythonTurtleRight = "Turn turtle to the right" -PythonTurtlePosition = "Get turtle position" -PythonTurtleSetposition = "Set turtle position" -PythonTurtleHeading = "Get turtle angle" -PythonTurtleSetheading = "Set turtle angle" -PythonTurtleSpeed = "Set turtle speed" -PythonTurtlePencolor = "Set pen color" -PythonTurtlePensize = "Get/Set pen width" +PythonTurtleGoto = "Move to (x,y) coordinates" +PythonTurtleGreen = "Green color" +PythonTurtleGrey = "Grey color" +PythonTurtleHeading = "Return the current heading" +PythonTurtleIsdown = "Return True if the pen is down" +PythonTurtleLeft = "Turn left by a degrees" +PythonTurtleOrange = "Orange color" +PythonTurtlePendown = "Pull the pen down" +PythonTurtlePensize = "Set the line thickness to x pixels" +PythonTurtlePenup = "Pull the pen up" +PythonTurtlePink = "Pink color" +PythonTurtlePosition = "Return the current (x,y) location" +PythonTurtlePurple = "Purple color" +PythonTurtleRed = "Red color" +PythonTurtleReset = "Reset the drawing" +PythonTurtleRight = "Turn right by a degrees" +PythonTurtleSetheading = "Set the orientation to a degrees" +PythonTurtleSetposition = "Positionne la tortue" +PythonTurtleSpeed = "Drawing speed between 0 and 10" +PythonTurtleWhite = "White color" +PythonTurtleYellow = "Yellow color" PythonUniform = "Floating point number in [a,b]" diff --git a/apps/code/catalog.fr.i18n b/apps/code/catalog.fr.i18n index ba3c0ad1f..6e5a46881 100644 --- a/apps/code/catalog.fr.i18n +++ b/apps/code/catalog.fr.i18n @@ -94,16 +94,33 @@ PythonSum = "Somme des éléments d'une liste" PythonTan = "Tangente" PythonTanh = "Tangente hyperbolique" PythonTrunc = "Troncature entière" -PythonTurtleFunction = "Préfixe fonction du module math" -PythonTurtleForward = "Avance la tortue" -PythonTurtleBackward = "Recule la tortue" -PythonTurtleLeft = "Tourne la tortue à gauche" -PythonTurtleRight = "Tourne la tortue à droite" -PythonTurtlePosition = "Position de la tortue" +PythonTurtleBackward = "Recule de x pixels" +PythonTurtleBlack = "Couleur noire" +PythonTurtleBlue = "Couleur bleue" +PythonTurtleBrown = "Couleur marron" +PythonTurtleCircle = "Cercle de rayon r pixels" +PythonTurtleColor = "Modifie la couleur du tracé" +PythonTurtleForward = "Avance de x pixels" +PythonTurtleFunction = "Préfixe fonction du module turtle" +PythonTurtleGoto = "Va au point de coordonnées (x,y)" +PythonTurtleGreen = "Couleur verte" +PythonTurtleGrey = "Couleur grise" +PythonTurtleHeading = "Renvoie l'orientation actuelle" +PythonTurtleIsdown = "True si le crayon est abaissé" +PythonTurtleLeft = "Pivote de a degrés vers la gauche" +PythonTurtleOrange = "Couleur orange" +PythonTurtlePendown = "Abaisse le crayon" +PythonTurtlePensize = "Taille du tracé en pixels" +PythonTurtlePenup = "Relève le crayon" +PythonTurtlePink = "Couleur rose" +PythonTurtlePosition = "Renvoie la position (x,y) actuelle" +PythonTurtlePurple = "Couleur violette" +PythonTurtleRed = "Couleur rouge" +PythonTurtleReset = "Réinitialise le dessin" +PythonTurtleRight = "Pivote de a degrés vers la droite" +PythonTurtleSetheading = "Met une orientation de a degrés" PythonTurtleSetposition = "Positionne la tortue" -PythonTurtleHeading = "Direction de la tortue" -PythonTurtleSetheading = "Tourne la tortue" -PythonTurtleSpeed = "Vitesse de la tortue" -PythonTurtlePencolor = "Couleur du crayon" -PythonTurtlePensize = "Largeur du crayon" +PythonTurtleSpeed = "Vitesse du tracé entre 0 et 10" +PythonTurtleWhite = "Couleur blanche" +PythonTurtleYellow = "Couleur jaune" PythonUniform = "Nombre décimal dans [a,b]" diff --git a/apps/code/catalog.pt.i18n b/apps/code/catalog.pt.i18n index f471d749c..029dad770 100644 --- a/apps/code/catalog.pt.i18n +++ b/apps/code/catalog.pt.i18n @@ -94,16 +94,33 @@ PythonSum = "Sum the items of a list" PythonTan = "Tangent" PythonTanh = "Hyperbolic tangent" PythonTrunc = "x truncated to an integer" +PythonTurtleBackward = "Move backward by x pixels" +PythonTurtleBlack = "Black color" +PythonTurtleBlue = "Blue color" +PythonTurtleBrown = "Brown color" +PythonTurtleCircle = "Circle of radius r pixels" +PythonTurtleColor = "Set the pen color" +PythonTurtleForward = "Move forward by x pixels" PythonTurtleFunction = "turtle module function prefix" -PythonTurtleForward = "Move the turtle forward" -PythonTurtleBackward = "Move the turtle backward" -PythonTurtleLeft = "Turn turtle to the left" -PythonTurtleRight = "Turn turtle to the right" -PythonTurtlePosition = "Get turtle position" -PythonTurtleSetposition = "Set turtle position" -PythonTurtleHeading = "Get turtle angle" -PythonTurtleSetheading = "Set turtle angle" -PythonTurtleSpeed = "Set turtle speed" -PythonTurtlePencolor = "Set pen color" -PythonTurtlePensize = "Get/Set pen width" +PythonTurtleGoto = "Move to (x,y) coordinates" +PythonTurtleGreen = "Green color" +PythonTurtleGrey = "Grey color" +PythonTurtleHeading = "Return the current heading" +PythonTurtleIsdown = "Return True if the pen is down" +PythonTurtleLeft = "Turn left by a degrees" +PythonTurtleOrange = "Orange color" +PythonTurtlePendown = "Pull the pen down" +PythonTurtlePensize = "Set the line thickness to x pixels" +PythonTurtlePenup = "Pull the pen up" +PythonTurtlePink = "Pink color" +PythonTurtlePosition = "Return the current (x,y) location" +PythonTurtlePurple = "Purple color" +PythonTurtleRed = "Red color" +PythonTurtleReset = "Reset the drawing" +PythonTurtleRight = "Turn right by a degrees" +PythonTurtleSetheading = "Set the orientation to a degrees" +PythonTurtleSetposition = "Positionne la tortue" +PythonTurtleSpeed = "Drawing speed between 0 and 10" +PythonTurtleWhite = "White color" +PythonTurtleYellow = "Yellow color" PythonUniform = "Floating point number in [a,b]" diff --git a/apps/code/catalog.universal.i18n b/apps/code/catalog.universal.i18n index d147d85af..e38392864 100644 --- a/apps/code/catalog.universal.i18n +++ b/apps/code/catalog.universal.i18n @@ -108,14 +108,32 @@ PythonCommandTrunc = "trunc(x)" PythonCommandTurtleFunction = "turtle.function" PythonCommandTurtleFunctionWithoutArg = "turtle.ø" PythonCommandUniform = "uniform(a,b)" -PythonTurtleCommandBackward = "backward(d)" -PythonTurtleCommandForward = "forward(d)" +PythonTurtleCommandBackward = "backward(x)" +PythonTurtleCommandBlack = "'black'" +PythonTurtleCommandBlue = "'blue'" +PythonTurtleCommandBrown = "'brown'" +PythonTurtleCommandCircle = "circle(r)" +PythonTurtleCommandColor = "color('c')/color(r,g,b)" +PythonTurtleCommandColorWithoutArg = "color(ø)" +PythonTurtleCommandForward = "forward(x)" +PythonTurtleCommandGoto = "goto(x,y)" +PythonTurtleCommandGreen = "'green'" +PythonTurtleCommandGrey = "'grey'" PythonTurtleCommandHeading = "heading()" +PythonTurtleCommandIsdown= "isdown()" PythonTurtleCommandLeft = "left(a)" -PythonTurtleCommandPencolor = "pencolor(r, g, b)" -PythonTurtleCommandPensize = "pensize([w])" +PythonTurtleCommandOrange = "'orange'" +PythonTurtleCommandPendown = "pendown()" +PythonTurtleCommandPensize = "pensize(x)" +PythonTurtleCommandPenup = "penup()" +PythonTurtleCommandPink = "'pink'" PythonTurtleCommandPosition = "position()" +PythonTurtleCommandPurple = "'purple'" +PythonTurtleCommandRed = "'red'" +PythonTurtleCommandReset = "reset()" PythonTurtleCommandRight = "right(a)" PythonTurtleCommandSetheading = "setheading(a)" PythonTurtleCommandSetposition = "setposition(x, [y])" -PythonTurtleCommandSpeed = "speed(s)" +PythonTurtleCommandSpeed = "speed(x)" +PythonTurtleCommandWhite = "'white'" +PythonTurtleCommandYellow = "'yellow'" diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index d09b73f80..d64b8eb3d 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -13,7 +13,7 @@ static constexpr int MathModuleChildrenCount = 43; static constexpr int KandinskyModuleChildrenCount = 7; static constexpr int CMathModuleChildrenCount = 13; static constexpr int RandomModuleChildrenCount = 10; -static constexpr int TurtleModuleChildrenCount = 14; +static constexpr int TurtleModuleChildrenCount = 30; static constexpr int conditionsChildrenCount = 9; static constexpr int forLoopChildrenCount = 4; @@ -146,16 +146,31 @@ const ToolboxMessageTree TurtleModuleChildren[TurtleModuleChildrenCount] = { ToolboxMessageTree(I18n::Message::PythonCommandTurtleFunction, I18n::Message::PythonTurtleFunction, I18n::Message::PythonCommandTurtleFunctionWithoutArg), ToolboxMessageTree(I18n::Message::PythonTurtleCommandForward, I18n::Message::PythonTurtleForward, I18n::Message::PythonTurtleCommandForward), ToolboxMessageTree(I18n::Message::PythonTurtleCommandBackward, I18n::Message::PythonTurtleBackward, I18n::Message::PythonTurtleCommandBackward), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandLeft, I18n::Message::PythonTurtleLeft, I18n::Message::PythonTurtleCommandLeft), ToolboxMessageTree(I18n::Message::PythonTurtleCommandRight, I18n::Message::PythonTurtleRight, I18n::Message::PythonTurtleCommandRight), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandPosition, I18n::Message::PythonTurtlePosition, I18n::Message::PythonTurtleCommandPosition), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandSetposition, I18n::Message::PythonTurtleSetposition, I18n::Message::PythonTurtleCommandSetposition), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandHeading, I18n::Message::PythonTurtleHeading, I18n::Message::PythonTurtleCommandHeading), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandLeft, I18n::Message::PythonTurtleLeft, I18n::Message::PythonTurtleCommandLeft), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandGoto, I18n::Message::PythonTurtleGoto, I18n::Message::PythonTurtleCommandGoto), ToolboxMessageTree(I18n::Message::PythonTurtleCommandSetheading, I18n::Message::PythonTurtleSetheading, I18n::Message::PythonTurtleCommandSetheading), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandCircle, I18n::Message::PythonTurtleCircle, I18n::Message::PythonTurtleCommandCircle), ToolboxMessageTree(I18n::Message::PythonTurtleCommandSpeed, I18n::Message::PythonTurtleSpeed, I18n::Message::PythonTurtleCommandSpeed), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandPencolor, I18n::Message::PythonTurtlePencolor, I18n::Message::PythonTurtleCommandPencolor), - ToolboxMessageTree(I18n::Message::PythonTurtleCommandPensize, I18n::Message::PythonTurtlePensize, I18n::Message::PythonTurtleCommandPensize)}; - + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPosition, I18n::Message::PythonTurtlePosition, I18n::Message::PythonTurtleCommandPosition), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandHeading, I18n::Message::PythonTurtleHeading, I18n::Message::PythonTurtleCommandHeading), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPendown, I18n::Message::PythonTurtlePendown, I18n::Message::PythonTurtleCommandPendown), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPenup, I18n::Message::PythonTurtlePenup, I18n::Message::PythonTurtleCommandPenup), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPensize, I18n::Message::PythonTurtlePensize, I18n::Message::PythonTurtleCommandPensize), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandIsdown, I18n::Message::PythonTurtleIsdown, I18n::Message::PythonTurtleCommandIsdown), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandReset, I18n::Message::PythonTurtleReset, I18n::Message::PythonTurtleCommandReset), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandColor, I18n::Message::PythonTurtleColor, I18n::Message::PythonTurtleCommandColorWithoutArg), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandBlue, I18n::Message::PythonTurtleBlue, I18n::Message::PythonTurtleCommandBlue), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandRed, I18n::Message::PythonTurtleRed, I18n::Message::PythonTurtleCommandRed), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandGreen, I18n::Message::PythonTurtleGreen, I18n::Message::PythonTurtleCommandGreen), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandYellow, I18n::Message::PythonTurtleYellow, I18n::Message::PythonTurtleCommandYellow), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandBrown, I18n::Message::PythonTurtleBrown, I18n::Message::PythonTurtleCommandBrown), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandBlack, I18n::Message::PythonTurtleBlack, I18n::Message::PythonTurtleCommandBlack), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandWhite, I18n::Message::PythonTurtleWhite, I18n::Message::PythonTurtleCommandWhite), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPink, I18n::Message::PythonTurtlePink, I18n::Message::PythonTurtleCommandPink), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandOrange, I18n::Message::PythonTurtleOrange, I18n::Message::PythonTurtleCommandOrange), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandPurple, I18n::Message::PythonTurtlePurple, I18n::Message::PythonTurtleCommandPurple), + ToolboxMessageTree(I18n::Message::PythonTurtleCommandGrey, I18n::Message::PythonTurtleGrey, I18n::Message::PythonTurtleCommandGrey)}; const ToolboxMessageTree modulesChildren[modulesChildrenCount] = { ToolboxMessageTree(I18n::Message::MathModule, I18n::Message::Default, I18n::Message::Default, MathModuleChildren, MathModuleChildrenCount),