Übung 3: Zeichnen mit Funktionen

This lab uses what we learned in Funktionen erstellen and Zeichnen mit Funktionen to extend our ability to draw to the screen.

Anforderungen

Your goal: Draw an image using functions.

../../_images/example.png ../../_images/example_2.png ../../_images/lab_03_example_01.gif

Anforderungen an die Zeichnung

Du kannst dein Programm aus der Übung 2 weiterverwenden oder ein neues Programm erstellen. Für diese Übung gibt es 20 Punkte. Beachte die Punkteverteilung unten.

Baue die folgenden Teile ein:

  • Suche den Ordner für die Übung 3 in PyCharm und beginne dort deinen Code einzugeben. Wenn du willst kannst du beliebigen Code aus der Übung 2 verwenden, kopiere ihn einfach herüber.

  • Sei dir sicher, dass du dein Programm im Ordner Übung 3 schreibst und nicht einfach die Übung 2 an die Anforderungen der Übung 3 anpasst.

  • Wir werden den Anweisungen/Beispielen in Zeichnen mit Funktionen folgen.

  • Put everything into a function as shown in Erstelle die Funktion main. 1 pt.

  • Create three functions that draw something. (18 pts total, up to 6 pts per function)

    • Definiere die Funktion und rufe sie erfolgreich auf. (1Punkt)

    • Mach deine Zeichenfunktion komplex. 0 Punkte gibt es für einen Einzeiler, der nur ein Rechteck zeichnet. Es gibt auch 0 Punkte für das Kopieren des Beispiels aus dem Buch. 2 Punkte gibt es für eine zusammenhängende mehrzeilige Funktion.

    • Übergebe x und y als Argumente und positioniere erfolgreich das Objekt wie in Erstelle die Zeichenfunktion gezeigt. (2 Punkte)

    • Make sure the image you draw is centered around the x and y, and not off-set. (1 pts)

  • Call at least one of the functions more than once, and in a different location. (1 pt.)

Doppelcheck

Stell sicher, dass du keine Funktionen in eine andere Funktion packst. Nach der import-Anweisung sollte jede Funktion angegeben sein. Ein def nach dem anderen, aber kein def in einem anderen def.

Make sure you have three functions that take in an (x, y) position to draw an object, not just one.

The most frequent source of confusion on this lab, and way to lose points, is a drawing function that is not centered around the specified (x, y). You can confirm this is working by drawing a point right at the x, y as the last line of your code. If the point draws near the center of your item, you are good. If the point is nowhere near the center, you need to re-center it.