Set the material properties when rendering.

After calling material() all subsequent rendering will use the specified material value. Material values must be in the range 0.0 to 1.0. There a number of different ways this function can be called. See the examples section below for usage.

Be sure to enable lighting when using the material. Additionally, the various geometry functions should be called with the optional style="solid" argument.

syntax

material(grey)
material(r, g, b)
material(r, g, b, a)
material([r, g, b])
material([r, g, b, a])

paramaters

grey grey-scale value
r red value
g green value
b blue value
a alpha (transparency) value

examples

set material using grey-scale value

def display():
   translateX(-5)
   material(0.1)
   sphere(2.0, style="solid")

   translateX(5)
   material(0.5)
   sphere(2.0, style="solid")

   translateX(5)
   material(0.9)
   sphere(2.0, style="solid")

set material using rgb values

def display():
   material(0.0, 1.0, 1.0)
   sphere(3.0, style="solid")

set material using rgb list

def display():
   material([1.0, 1.0, 0.0])
   sphere(3.0, style="solid")

set material using variable

def display():
   my_material = [1.0, 0.0, 1.0]
   material(my_material)
   sphere(3.0, style="solid")

set material using alias

def display():
   # using color alias
   material(blue)
   sphere(3.0, style="solid")