Some of the functions in ribs use a Python feature you may not have come
across: default arguments. These allow you to only specify a few of the
arguments to a function, and leave the rest. For example, the definition of
draw_transformed
looks like this:
draw_transformed( img, position, scale=(1., 1.), degrees=0 )
The =x
part of the scale
and degrees
mean that you can call the function as one of
draw_transformed( img, (100, 100)) # Default scale and degrees
draw_transformed( img, (100, 100), (2, 2)) # Scale up by 2, leave degrees unchanged
draw_transformed( img, (100, 100), (2, 2), 90) # Scale up by 2, rotate by 90 degrees
You can also specify one of many arguments by typing out its name. This is useful if you want
to leave the first argument as default, but change another
draw_transformed( img, (100, 100), , degrees = 90) # Rotate 90 degrees, default scale