Part 1, create a graphics window and place at least three buttons in it. One button should be "Exit" or "Quit". The other two buttons do something like:
Part 2, create round buttons that change color when activated.
Part 3, use an image as a button
Hint: create a class called Button. Put all (most) of the button functionality in it:
Part 1. pong
Part 2. breakout
Part 3. hangman
Part #1, create a 12 hour clock with a hour and second hand
Part #2, add hour numbers.
Part #3, add minute tick marks of some kind.
Part #4, create a 24 hour clock and a way to switch between 12 hour and 24 hour clocks.
Part #1, draw the normal vectors pointing toward the viewer in black, and the normal vectors pointing away from the viewer in red.
Note: The program should allow you to rotate/translate the wire frame object and its normal vectors.
Draw the normal vector from the center of each side of the cube? A normal vector may be calculated using a cross product of two vectors in a plane. create a vector from the center of a side of the cube to two corners of the cube. (Make sure they are not the "same" vector. That is, don't point in the same direction.)
The normal vector may be very long. Scale it to a reasonable size for viewing.
A normal vector may be calculated using a cross product of two vectors in a plane. Possible code?
import numpy as np # three points in a plane # (the obvious choice is three corners of a side of the cube) p1 = np.array([x1, y1, z1]) p2 = np.array([x2, y2, z2]) p3 = np.array([x3, y3, z3]) # ---- cross product (normal vector to plane) # ---- Note: remember the right hand rule xp = np.cross(p2-p1, p3-p1) # ---- scale normal vector to fit the drawing # ---- find max x,y,z dimension value max = np.abs(xp[0]) if np.abs(xp[1]) > max: max = np.abs(xp[1]) elif np.abcs(xp[2]) > max: max = np.abs(xp[2]) # ---- scale x,y,z dimension values - maximum value is 50 scale_factor = 50.0/max cp[0] = int(np.round(cp[0] * scale_factor)) cp[1] = int(np.round(cp[1] * scale_factor)) cp[2] = int(np.round(cp[2] * scale_factor))
Part #2, draw only the wire frame lines for surfaces that the normal vector points toward the viewer. This should give the illusion of a solid object.
Part #3, draw other wire frame shapes. (Ask the instructor.)