Go Back

QuoteFloat: Animating TextBlock PlaneProjections for a spiraling effect in Silverlight

QuoteFloat

 

[silverlight: http://members.chello.nl/s.dol/QuoteFloat.html]

 

QuoteFloat is an animation for TextBlock elements, inspired by the way the HTC Touch HD shows SMS Text messages. It moves the text up and rotates it at the same time resulting in a spiraling effect. It is done by giving the TextBlock elements a PlaneProjection each and animating the RotationY and GlobalOffsetY properties.

The TextBlock elements are positioned below the bottom of the Canvas. The Canvas has a Clipping Mask so no one will see them until the animation starts. The XAML looks like this:

 

<Canvas x:Name="cvsBg" Width="500" Height="155"
            Clip="M0.5,0.5 L499.5,0.5 L499.5,154.5 L0.5,154.5 z">
            <TextBlock x:Name="txt1" Text="Txt1" Canvas.Top="192"
                        Style="{StaticResource TextBlockStyle1}">
                        <TextBlock.Projection><PlaneProjection/></TextBlock.Projection>
            </TextBlock>
            <TextBlock x:Name="txt2" Text="Txt2" Canvas.Top="228"
                        Style="{StaticResource TextBlockStyle1}">
                        <TextBlock.Projection><PlaneProjection/></TextBlock.Projection>
            </TextBlock>
            <TextBlock x:Name="txt3" Text="Txt3" Canvas.Top="265"
                        Style="{StaticResource TextBlockStyle2}">
                        <TextBlock.Projection><PlaneProjection/></TextBlock.Projection>
            </TextBlock>
</Canvas>

 

I use two Styles for the two TextBlocks. Notice the second style is BasedOn, so it needs only to define the properties that are different from the first style. The Canvas.Top property is different for all the TextBlocks and defined inline in the XAML above.

 

<Style x:Key="TextBlockStyle1" TargetType="TextBlock">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Width" Value="400"/>
    <Setter Property="Height" Value="25"/>
    <Setter Property="FontSize" Value="21.333"/>
    <Setter Property="FontFamily" Value="Trebuchet MS"/>
    <Setter Property="TextAlignment" Value="Center"/>
    <Setter Property="Canvas.Left" Value="50"/>
</Style>
<Style x:Key="TextBlockStyle2" TargetType="TextBlock"
    BasedOn="{StaticResource TextBlockStyle1}">
    <Setter Property="FontSize" Value="14"/>
    <Setter Property="Canvas.Left" Value="200"/>
</Style>

 

The actual animations are quite repetative, being almost the same for all TextBlock elements. The crucial word here is almost: the animations differ for .2 seconds. Stopping the text is the natural result from easing out and the easing in the animation.

 

QuoteFloatStoryboard

 

<Storyboard x:Name="QuoteFloat" RepeatBehavior="Forever">
    <DoubleAnimationUsingKeyFrames
        BeginTime="00:00:00"
        Storyboard.TargetName="txt1"
        Storyboard.TargetProperty=
            "(UIElement.Projection).(PlaneProjection.RotationY)">
        <EasingDoubleKeyFrame KeyTime="00:00:00" Value="90"/>
        <EasingDoubleKeyFrame KeyTime="00:00:01.5" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
                <CubicEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="00:00:03" Value="-90">
            <EasingDoubleKeyFrame.EasingFunction>
                <CubicEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
… more animations

    <DoubleAnimationUsingKeyFrames
        BeginTime="00:00:00"
        Storyboard.TargetName="txt2"
        Storyboard.TargetProperty=
            "(UIElement.Projection).(PlaneProjection.RotationY)">
        <EasingDoubleKeyFrame KeyTime="00:00:00.2" Value="90"/>
        <EasingDoubleKeyFrame KeyTime="00:00:01.7" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
                <CubicEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="00:00:03.2" Value="-90">
            <EasingDoubleKeyFrame.EasingFunction>
                <CubicEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
… more animations

 

The text was not set using code, but in Blend. It then uses a DiscreteObjectKeyFrame for the TextBlock Text property and uses the given String Value.

 

<ObjectAnimationUsingKeyFrames
    BeginTime="00:00:00"
    Storyboard.TargetName="txt1"
    Storyboard.TargetProperty="(TextBlock.Text)">
    <DiscreteObjectKeyFrame KeyTime="00:00:00"
        Value="Technology requires design"/>
    <DiscreteObjectKeyFrame KeyTime="00:00:03"
        Value="Imagine users as very intelligent"/>
    <DiscreteObjectKeyFrame KeyTime="00:00:06"
        Value="No matter how cool you interface is,"/>
    <DiscreteObjectKeyFrame KeyTime="00:00:09" Value="Significant change"/>
</ObjectAnimationUsingKeyFrames>

 

The Loaded event of the UserControl is used to start the animation in the MainPage CodeBehind file:

 

<UserControl x:Class="QuoteFloat.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    Width="500" Height="155" Loaded="StartAnim">

private void StartAnim(object sender, System.Windows.RoutedEventArgs e)
{
    QuoteFloat.Begin();
}

Complete Blend project is on my SkyDrive…

 

Njoy!

Facebook Twitter DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Add diigo bookmark

Comments  8

  • Jordans 7 11 mei

    What a great blog! It's a pity that i can't find your rrs address. If you can offer rrs subscription service, i can track your blog easier!
    By <a href="http://www.airjordans.cc/air-jordan-7-7/"> Jordans 7 </a>
  • rolex daytona 19 okt

    When you are looking for that perfect gift to get for the special man in your life, you can never go wrong with designer <a href="http://www.watches-mens.com" title="mens watches">mens watches</a>. The <a href="http://www.watches-mens.com/rolex-daytona" title="rolex daytona">rolex daytona</a> and the <a href="http://www.watches-mens.com/rolex-submariner" title="rolex submariner">rolex submariner</a> fall into the professional line of watches. As one of the most prestigious watch brands in the world, <a href="http://www.watches-mens.com/hublot" title="hublot watches">hublot watches</a> is specialized in splendid timepieces. <a href="http://www.watches-mens.com/panerai" title="panerai watches">panerai watches</a> aren't the most well known of men's watches but this esoteric brand is becoming highly desirable among men. <a href="http://www.watches-mens.com/breitling" title="breitling watches">breitling watches</a> have made an excellent name for themselves. If there are any watches that should be known for all the watch collectors, <a href="http://www.watches-mens.com/breitling-navitimer" title="breitling navitimer">breitling navitimer</a> should be among one of them. So far as we know, <a href="http://www.watches-mens.com/iwc" title="iwc watches">iwc watches</a> are one of the most famous brand watches in the world. Also, <a href="http://www.watches-mens.com/tag-heuer" title="tag heuer watches">tag heuer watches</a> and <a href="http://www.watches-mens.com/chopard" title="chopard watches">chopard watches</a> maybe your choice. <a href="http://www.watches-mens.com/omega-seamaster" title="omega seamaster">omega seamaster</a> watch and its tryst as an eternal timepiece began in the year 1948. 
  • rolex daytona 19 okt

    When you are looking for that perfect gift to get for the special man in your life, you can never go wrong with designer mens watches. The rolex daytona and the rolex submariner fall into the professional line of watches. As one of the most prestigious watch brands in the world, hublot watches is specialized in splendid timepieces. panerai watches aren't the most well known of men's watches but this esoteric brand is becoming highly desirable among men. breitling watches have made an excellent name for themselves. If there are any watches that should be known for all the watch collectors, breitling navitimer should be among one of them. So far as we know, iwc watches are one of the most famous brand watches in the world. Also, tag heuer watches and chopard watches maybe your choice. omega seamaster watch and its tryst as an eternal timepiece began in the year 1948.
  • rolex daytona 19 okt

    Everyone knows that swiss replica watches are the finest quality timepieces in the world. panerai watches’ great popularity is based on its high-end timepieces with high quality and top craftsmanship. One prominent feature of Hublot watches that makes the brand different from other luxury watch brands lies in the materials used in manufacturing. Also, tag heuer watches and Chopard watches are people’s choice. If there are any watches that should be known for all the watch collectors, breitling Navitimer should be among one of them. The srolex DateJust, rolex Daytona and the rolex Submariner fall into the professional line of watches. As a world known leading luxury brand, burberry watches are considered as a symbol of classic style and elegance. breguet watches have a history of more than 230 years through the arrangement of spare parts. As one of the most sought after watches in the world, patek philippe watcheshas literally stood the test of time. And Audemars Piguet watches are some of the world's best built timepieces. U Boat watches are characterized as bold, aggressive and oversized and Franck Muller watches are complex, innovative. If you are looking for a watch of high quality and superior elegance, I think B R M watches will be your choice. A Lange Sohne watches and Ferrari watches are two famous brands in the world, too.
  • rolex daytona 19 okt

    Nowadays replica watches are becoming more and more popular in the market. rolex watches are known for both their precision and elegance such as rolex air king watches, rolex submariner watches and rolex datejust watches. breguet watches are among the extremely unique and sophisticated timepieces. blancpain watches are works of excellence and decadence. bell ross watches may be well characterized by the squared military-style instrument face. With excellent craftsmanship and elegant style, Baume Mercier watches have get great value in Swiss watchmaking. bvlgari watches are noted for their fashion and precision, which make them well received in the world luxury industry. If you want to accentuate your beauty and style with good-looking accessories, chopard watches are no doubt your ideal options. dewitt watches and montblanc watches are well known brands of watches all over the world, too. oris watches are greatly sought after in the realm of luxury watches. panerai watchess are very beautiful. Their large, chunky lines are subdued by their understated styling. patek philippe watches are admired for their intricate craftsmanship and super technical advance. piaget watches are a status symbol for wealth, fortune, and prestige. If you intend to give something very special this season to people who are close to you then choose to buy rado watches. As one of the most popular timepieces in the world, tudor watches are well received by their splendid design and great durability. u boat watches is a highly elite watch brand that was founded by Italian watch maker Italo Fontana. ebel watches share the same properties with the world's most spectacular architecture in innovation, melodious and the most talented craftsmanship. ferrari watches and franck muller watches are famous for its high quality and elegant appearance. Self-producing movement is the representative of glashutte watches. gucci watches have been around since 1920 and have been leading the time peace market for many decades now. hermes watches were well received since they were first launched into the market. As one of the most prestigious watch brands in the world, hublot watches are specialized in splendid timepieces. louis vuitton watches and maurice lacroix watches maybe your best choice.
  • rolex daytona 19 okt

    As everybody known, rolex watches are some of the famous watches in the world. But they are very expensive. rolex replica watches are more and more popular now. rolex mens watches have the best selling point. The rolex Submariner and the rolex Deepsea are two of the truly exceptional sport models Rolex makes. rolex Perpetual and rolex Daytona are also the two types have special appearance and manufacture. Released in the year 1945, to mark the 40-year anniversary of the inception of Rolex, the rolex Datejust is the best selling watch of Rolex. rolex Air king is famous for its high quality and elegant appearance.
  • rolex daytona 19 okt

    As we all know, uggs Boots Shoes from Australia are made from merino lambskin in double layers.Its function in repelling moisture and coldness is even incredible.If you want to buy it,you can find ugg online through the internet.This quick guide will get you set up and on your way to finding cheap Uggs at ugg outlet prices! Because there are so many ugg website online.You can also check for prices at the more popular auction websites such as Ebay,there must be a name of ugg ebay or ugg.com.You can find many kind of ugg Boots Shoes,such as ugg nightfall bootsugg tall bootsugg butte bootugg suede boots and ugg ultra and so on.
  • EFX bracelet 21 okt

    Here are 2010 top sellers. First, Power Balance silicone Bracelets. They are are sweeping the whole world.
    <a href="http://www.toptoys2trade.com/power-balance-wholesale-2-c-40/ "> power balance</a> bracelets were first released in January of 2007 and now they become the most popular health bracelets

    among people of all ages and all walks of life, including some of the super athletes. Second, Silly bandz. A very famous brand of silicon rubber bands.
    <a href="http://www.toptoys2trade.com/a-silly-bandz-c-57/ "> silly bandz</a> come in different shapes like objects, animals and letters and this is why these are

    loved by kids of all ages. The bands are very popular because they come in many colors, shapes and themes. There is no doubt that you will fall in love with

    them the minute you see them. These bands can wither be used as bracelets or as regular rubber bands. The choice is entirely of the user. Third, Far away on

    the mysterious Isle of Zooble reside hundreds of adorable, little creatures with a magnificent ability, they can magically transform into tiny balls hiding from the

    unknown, rolling to colorful destinations, sleeping after a long day But beware, you never know when these mischievous
    <A href="http://www.toptoys2trade.com/zoobles-c-60/"> Zoobles</A> are going to pop open and surprise you. Fourth, EFX’s holographic technology contains

    algorithms and frequencies that interact positively with this energy field in both humans and animals at the cellular level. When placed near the body, especially

    at key energy centers such as the hands and feet, <a href="http://www.toptoys2trade.com/efx-balance-c-59/ ">EFX bracelet</a>’s products will harmonize

    with the body’s naturally occurring bioelectric frequencies. Fifth, Every child wants a
    <a href="http://www.toptoys2trade.com/zhu-zhu-pets-c-52/ ">zhu zhu pets</a>hamster and we have all of them in stock as well as all the Zhu Zhu accesories for this most wished for of toys. They are also know as Go Go Pets or

    Go Go Hamsters in the UK and Europe. Enjoy your zhu zhu pets everyone. Sixth, <a href="http://www.toptoys2trade.com/pillow-pets-c-55/ ">Pillow Pets</a>

    is durability, machine washable, no batteries, friends for life and most important children like them.
    <a href="http://www.toptoys2trade.com/silicone-watch-c-54/ "> Silicone Watch</a> is not only a fashional, but also healthy product, it is suitable to all people to wear.The designs are fashional and it can be worn

    whenever,whether you are sit or run. Wearing it, you will feel mental and muscle relax, besides.
    <a href="http://www.toptoys2trade.com/doll-barbie-girls-c-2_23/ ">barbie girls</a>.

Post a comment!
  1. Formatting options