I am still new to blender and am working on an animation of a light-responsive protein network in blender-python. I have been asked to create a shaded background whose color changes in accordance with the frequency of light shining on it. My question: how do I code a shaded background in python whose color I can change over the course of the animation:
Implementing the basic background using Blender's UI was straight forward: add blend-sky to the world and adjust its color's accordingly (Picture 1). Using the info tab, I attempted to recreate these commands in python:
bpy.context.space_data.context = 'WORLD' bpy.context.scene.world.use_sky_blend = True self.world.horizon_color = (0, 0, 0) self.world.zenith_color = (1.0, 0.0, 1.0)
This however only results in "AttributeError: 'SpaceTextEditor' object as no attribute 'context'".
Next, I used a snippet of code from a previous answer I found on this very site (source: Creating cycles background light (world lighting) from Python), which produced a colored background but lacked the shading of the desired result (Picture 1).
enter codbpy.data.scenes['Scene'].render.engine = 'CYCLES' world = bpy.data.worlds['World'] world.use_nodes = True bg = world.node_tree.nodes['Background'] bg.inputs.default_value[:3] = (0.5, .1, 0.6) bg.inputs.default_value = 1.0e here
Even if one of these two methods had worked, I would still be unsure how to program a change in background color. Can I create background animations using keyframes similar to object animation? How do I even create the desired type of background in the first place?
Your help is much appreciated.