ebook img

JavaFX™ Special Effects: Taking Java™ RIA to the Extreme with Animation, Multimedia, and Game Elements PDF

263 Pages·2009·4.401 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview JavaFX™ Special Effects: Taking Java™ RIA to the Extreme with Animation, Multimedia, and Game Elements

JavaFX Special Effects ™ Taking Java™ RIA to the Extreme with Animation, Multimedia, and Game Elements ■ ■ ■ Lucas L. Jordan JavaFX™ Special Effects: Taking Java™ RIA to the Extreme with Animation, Multimedia, and Game Elements Copyright © 2009 by Lucas L. Jordan All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2623-9 ISBN-13 (electronic): 978-1-4302-2624-6 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. President and Publisher: Paul Manning Lead Editor: Tom Welsh Technical Reviewer: Sten Anderson Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Debra Kelly Copy Editors: Sharon Terdeman and Vanessa Porter Compositor: LaurelTech Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Kurt Krames Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please e-mail [email protected], or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales– eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. Dedicated to my wife, Debra. I love you, and I love our future together. ■ CONTENTS Contents at a Glance ■ Chapter 1: JavaFX Design Considerations..................................................................1 ■ Chapter 2: Effect: Particle Systems..........................................................................23 ■ Chapter 3: Effect: Visual Transitions........................................................................49 ■ Chapter 4: Effect: Animated Lighting........................................................................71 ■ Chapter 5: Effect: Advanced Interpolators...............................................................87 ■ Chapter 6: Effect: Physics......................................................................................113 ■ Chapter 7: Effect: Animated Image Sequences .....................................................137 ■ Chapter 8: Effect: Animated Gradients...................................................................153 ■ Chapter 9: Effect: Audio Visualizer.........................................................................177 ■ Chapter 10: Effects: Physics and Particles............................................................201 ■ Chapter 11: Pulling It All Together: Clown Cannon................................................215 ■ Index.......................................................................................................................241 v ■ CONTENTS Contents Contents at a Glance.......................................................................................................v Contents........................................................................................................................vi Foreword......................................................................................................................xii About the Author.........................................................................................................xiii About the Technical Reviewer.....................................................................................xiv Acknowledgments........................................................................................................xv Introduction.................................................................................................................xvi ■ Chapter 1: JavaFX Design Considerations..................................................................1 Graphics and Animations in Applications..........................................................................1 Controls and Layout....................................................................................................1 Graphics......................................................................................................................5 Animations..................................................................................................................8 Designers and Developers.................................................................................................9 Workflow.....................................................................................................................9 Showing off the Platform..........................................................................................12 Setting Realistic Expectations...................................................................................12 JavaFX.............................................................................................................................13 Scene Graph..............................................................................................................13 vi ■ CONTENTS Designer Tools..........................................................................................................14 Deployment...............................................................................................................18 NetBeans...................................................................................................................18 Open Source Tools...........................................................................................................20 GIMP..........................................................................................................................20 ImageMagick............................................................................................................21 Blender......................................................................................................................21 Inkscape....................................................................................................................21 Audacity....................................................................................................................21 Summary.........................................................................................................................21 ■ Chapter 2: Effect: Particle Systems..........................................................................23 Basic Principles...............................................................................................................23 Visual Density............................................................................................................25 Particle Appearance and Behavior............................................................................25 Animation Implementation........................................................................................25 Example 1: Core Classes..................................................................................................25 Example 2: Adding Some Controls...................................................................................29 Example 3: Transparency................................................................................................35 Example 4: Blend Mode...................................................................................................38 Example 5: Nonuniform Nodes........................................................................................40 Example 6: Direction........................................................................................................44 Example 7: Nonlinear Paths.............................................................................................46 Further Considerations....................................................................................................47 Summary.........................................................................................................................48 ■ Chapter 3: Effect: Visual Transitions........................................................................49 Getting Started.................................................................................................................49 vii ■ CONTENTS Example 1: Fade Replace.................................................................................................53 Example 2: Slide Replace................................................................................................56 Example 3: Flip Replace...................................................................................................58 Example 4: Wipe Replace................................................................................................63 Example 5: Burn Replace.................................................................................................66 Further Considerations....................................................................................................69 Summary.........................................................................................................................69 ■ Chapter 4: Effect: Animated Lighting........................................................................71 Lighting Basics................................................................................................................71 Animating Light................................................................................................................73 Distant Light Example...............................................................................................75 Point Light Example..................................................................................................77 Spot Light Example...................................................................................................80 Light and Shadow Example.......................................................................................83 Further Considerations..............................................................................................86 Summary.........................................................................................................................86 ■ Chapter 5: Effect: Advanced Interpolators...............................................................87 The Basics.......................................................................................................................87 Visualizing Interpolators............................................................................................88 Built-In Interpolators.................................................................................................91 Custom Interpolators.......................................................................................................94 Extending Interpolator...............................................................................................95 Quadratic Interpolator...............................................................................................96 Cubic Interpolator......................................................................................................97 Polynomial Interpolator.............................................................................................99 Windup-Overshoot Interpolator...............................................................................101 viii ■ CONTENTS Step Interpolator.....................................................................................................103 Transition Example........................................................................................................108 Fade Transition.......................................................................................................110 Slide Transition.......................................................................................................110 Flip Transition.........................................................................................................111 Further Considerations............................................................................................111 Summary.......................................................................................................................112 ■ Chapter 6: Effect: Physics......................................................................................113 Simulation......................................................................................................................113 Third-Party Implementation...........................................................................................114 Simple Example......................................................................................................115 Pendulum Example.................................................................................................122 Teeter Totter Example.............................................................................................126 Transition Example........................................................................................................128 Further Considerations..................................................................................................135 Summary.......................................................................................................................135 ■ Chapter 7: Effect: Animated Image Sequences .....................................................137 Creating Images.............................................................................................................137 Implementation..............................................................................................................143 Further Considerations..................................................................................................151 Summary.......................................................................................................................152 ■ Chapter 8: Effect: Animated Gradients...................................................................153 The Basics.....................................................................................................................153 Paint Types.............................................................................................................153 Proportional.............................................................................................................155 Animations.....................................................................................................................159 ix ■ CONTENTS Simple Color Example.............................................................................................159 Simple Linear Gradient............................................................................................160 Simple Radial..........................................................................................................163 Multi-Colored Linear...............................................................................................165 Animated Stops.......................................................................................................166 Animate Opacity and Stops.....................................................................................169 Progress Bar...........................................................................................................172 Summary.......................................................................................................................175 ■ Chapter 9: Effect: Audio Visualizer.........................................................................177 What Is an Audio Visualizer?..........................................................................................177 Audio and the JVM.........................................................................................................179 Audio and JavaFX....................................................................................................179 Java Sound.............................................................................................................180 JavaFX and Java.....................................................................................................186 Audio Visualizations.......................................................................................................188 Controlling the Audio...............................................................................................190 Bars.........................................................................................................................192 Disco.......................................................................................................................194 Wave.......................................................................................................................198 Summary.......................................................................................................................200 ■ Chapter 10: Effects: Physics and Particles............................................................201 Particles as Bodies........................................................................................................201 Emitters as Bodies.........................................................................................................209 Summary.......................................................................................................................214 ■ Chapter 11: Pulling It All Together: Clown Cannon................................................215 Design Phase.................................................................................................................215 x

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.