Here's the crucial statement from the Visual help description of the
faces object (choose "Visual" on the Help menu in IDLE):
If you don't specify normals at the vertices,
the face is illuminated only by "ambient" light.
Because you had set the background color to white, the parallelogram
looked completely black but was actually colored, but only dimly, due
solely to ambient light. Here is a version of your parallelogram routine
which constructs the necessary normals:
def parallelogram(v1,v2,v3,trianglecolor):
c = color.hsv_to_rgb(trianglecolor)
n = norm(cross(v2-v1,v3-v1))
triangle1=faces(pos=[v1,v2,v3],normal=n,color=c)
triangle2=faces(pos=[v2,v2+v3-v1,v3],normal=n,color=c)
triangle3=faces(pos=[v2,v1,v3],normal=-n,color=c)
triangle4=faces(pos=[v2+v3-v1,v2,v3],normal=-n,color=c)
The information about built-in colors is in the Help; see "Specifying
Colors". The module itself has the file name "crayola" but one actually
says "color.orange", not "crayola.orange".
Bruce Sherwood
Poul Riis wrote:
> I can't extract from the manual how to control the color of the faces
> object. The attached example works, but the rectangle always has the same
> color, no matter the trianglecolor parameter. In fact, I would like to
> make the back side of the rectangle somewhat darker than the front side -
> automatically.
>
> Btw - where can I find information about crayola colors?
>
> Yours,
> Poul Riis
|