Merge pull request #285 from DanWaxman/master

Added the option to change color in extract scene.
This commit is contained in:
Grant Sanderson 2018-09-10 11:36:43 -07:00 committed by GitHub
commit 1ce9ce99aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,8 @@ from scene.scene import Scene
from utils.sounds import play_error_sound from utils.sounds import play_error_sound
from utils.sounds import play_finish_sound from utils.sounds import play_finish_sound
from colour import Color
HELP_MESSAGE = """ HELP_MESSAGE = """
Usage: Usage:
python extract_scene.py <module> [<scene name>] python extract_scene.py <module> [<scene name>]
@ -31,6 +33,7 @@ HELP_MESSAGE = """
-t use transperency when exporting images -t use transperency when exporting images
-n specify the number of the animation to start from -n specify the number of the animation to start from
-r specify a resolution -r specify a resolution
-c specify a background color
""" """
SCENE_NOT_FOUND_MESSAGE = """ SCENE_NOT_FOUND_MESSAGE = """
That scene is not in the script That scene is not in the script
@ -72,6 +75,7 @@ def get_configuration():
parser.add_argument("-o", "--output_name") parser.add_argument("-o", "--output_name")
parser.add_argument("-n", "--start_at_animation_number") parser.add_argument("-n", "--start_at_animation_number")
parser.add_argument("-r", "--resolution") parser.add_argument("-r", "--resolution")
parser.add_argument("-c", "--color")
args = parser.parse_args() args = parser.parse_args()
if args.output_name is not None: if args.output_name is not None:
output_name_root, output_name_ext = os.path.splitext( output_name_root, output_name_ext = os.path.splitext(
@ -135,6 +139,14 @@ def get_configuration():
"pixel_width": width, "pixel_width": width,
}) })
if args.color:
try:
config["camera_config"]["background_color"] = Color(args.color)
except AttributeError as err:
print("Please use a valid color")
print(err)
sys.exit(2)
# If rendering a transparent image/move, make sure the # If rendering a transparent image/move, make sure the
# scene has a background opacity of 0 # scene has a background opacity of 0
if args.transparent: if args.transparent: