Innovative Interfaces with Clutter
Listing 3. Clutter Rotating a Video
import clutter import gst from clutter import cluttergst class HelloWorld: def __init__ (self): self.stage = clutter.Stage() self.stage.set_color(clutter.color_parse('Black')) self.stage.set_size(500, 400) self.stage.set_title('Clutter 3-D Video Player') # Setup video. video_tex = cluttergst.VideoTexture() self.pipeline = gst.Pipeline("mypipe") playbin = video_tex.get_playbin() movfile = "file:///home/user/Videos/Video.mov" playbin.set_property('uri', movfile) self.pipeline.add(playbin) video_tex.set_position(90,80) self.stage.add(video_tex) self.pipeline.set_state(gst.STATE_PLAYING) # Create timeline that lasts for 100 frames # at ten frames per second. timeline = clutter.Timeline(100, 10) # Set timeline to loop forever. timeline.set_loop(True) # Create an alpha. alpha = clutter.Alpha(timeline, clutter.smoothstep_dec_func) # Set up rotation. Rotation = clutter.BehaviourRotate( axis=clutter.Y_AXIS, direction=clutter.ROTATE_CW, angle_start=0, angle_end=360, alpha=alpha) Rotation.set_center(160, 160, 0) Rotation.apply(video_tex) # Start it all up. timeline.start() self.stage.show_all() clutter.main() # Run program. main = HelloWorld()
The Alpha Functions
At first, especially to those who've forgotten their Calculus and Algebra, the alpha functions may seem unpredictable or confusing. There is a large list of the number of available functions: exp_dec_func, exp_inc_func, ramp_dec_func, ramp_func, ramp_inc_func, sine_dec_func, sine_func, sine_half_func, sine_inc_func, smoothstep_dec_func, smoothstep_inc_func and square_func. Here's a brief explanation of each type:
Exponential functions: depending on whether you're using a decaying function or an increasing function, exponential functions make the animation speed up or slow down at an exponential rate.
Ramp functions: ramp functions animate at a constant speed. However, the full ramp function animates at both a negative and a positive constant speed by switching directions.
Sine functions: sine functions make the animation reverse. Like the graph of a sine function, the animation would speed up, slow down, change directions, speed up in the reverse direction, and then slow down again.
Smooth step functions: the smooth step function works logistically. It starts slowly, then quickly increases and finally slows down toward the end of the animation.
Square functions: square functions follow a step pattern, which results in quick changes between two constant animation speeds.
Hopefully, you've learned a good deal about how Clutter works, and you can start developing and programming using the Clutter API. Using just the features you've seen here, you'll be able to create any interface that uses text, buttons, images and video with Clutter. Of course, after learning the basics, the more advanced UI elements will become easier to understand and work with.
In the future, the Clutter developers will continue to improve and update the API, and many new improvements are expected in the Clutter 1.0 release. You can learn more about the Clutter development process from the Web site (see Resources). Clutter is going to power many innovative open-source applications in the future.
Alex Crits-Christoph has been working with Linux for some time now. He enjoys developing and designing open-source graphical user interfaces.
|Nativ Disc||Sep 23, 2016|
|Android Browser Security--What You Haven't Been Told||Sep 22, 2016|
|The Many Paths to a Solution||Sep 21, 2016|
|Synopsys' Coverity||Sep 20, 2016|
|Naztech's Roadstar 5 Car Charger||Sep 16, 2016|
|RPi-Powered pi-topCEED Makes the Case as a Low-Cost Modular Learning Desktop||Sep 15, 2016|
- Android Browser Security--What You Haven't Been Told
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Nativ Disc
- The Many Paths to a Solution
- Naztech's Roadstar 5 Car Charger
- Synopsys' Coverity
- Securing the Programmer
- RPi-Powered pi-topCEED Makes the Case as a Low-Cost Modular Learning Desktop
- Identity: Our Last Stand
- Glass Padding
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide