Sunday, September 21, 2014

How to Animate a Signature Using Adobe After Effects

Hi All,

This tutorial is for anyone who wants to animate a Signature with Adobe After Effects. This tutorial is intended for anyone who is not familiar with AE. I will show you how animate a signature and finally convert that to a GIF image, so that you can use it even in your website.  So let's begin.

1. Create a new project.


2.Import the image of the signature you are going to animate. Here I'm using just an image I Googled.



3. Drag and drop the image to Composition

 




4. Select Pen Tool and start drawing using the pen tool on the image. If you haven't used pen tool before, just don't worry within a few minutes you'll get used to it. So just give a try.



5. Change the mask color if you want. You can do that by clicking on the drop down of the 'Masks' and on the required mask click on the color.



6. When you want to start with a new mask just click on the mask tab and again start drawing using  a new mask. You will see a new mask will be created under the Masks. You can change the color of that if you want.


7. Create a new composition. You can change the settings as you want in this window.

 

8. Right click on the new composition and click on new solid and create a white solid background using the window.



9.Copy all the masks from previous composition. You can do this by clicking on one mask, then shift+Click on the last mask. Then go to Edit-> Copy.


10. Click on the White Solid and Paste the copied Masks there.



11. Now we can select all masks and resize them to fit the window (First select all masks. Then pressing Ctrl+Click will make a free transform selection. Then resize using Ctrl+Alt+Shift and drag to your size)

12. Lock all masks by clicking on the small box in the right side of each mask. As you have selected all masks, clicking one mask will allow you to lock everyone.


13. Then go to Menu---Layer--- Masks---Hide Locked Masks


This will disappear the masks from your composition

14. Then Menu---Effect --- Generate ---- Stroke


15. In the Stroke Tab make the Color to Black and you will see the first mask appear in black. Then Check All masks and Stroke Sequentially. This will make all your masks appear again. 


16. Bring the time line cursor to 0 secs and make the click the small stopwatch in end time and set 0% in end time. Also you can reduce the work area by dragging the Work Area End to left side in the timeline. This will reduce the time that your animation will work. 


17. Bring the time-line cursor to some seconds and make the stopwatch 100% in the end time


18. Make the paint style to On transparent + toggle transparency grid and Click on the Toggle Transparency Grid Button so that your animation will work on a transparent background. 


19. You can also add effects to roughen the edges and changing the settings as you want there. (You can do that by with the white background selected Effect-> Stylize -> Roughen the edges)


20. Now click on Composition --- Add to render queue (Ctrl+Shift+/) You will see a new tab named Render Queue is opened. 


21. Click on the Output Module and give the Format to Quick Time and Channels to RGB+Alpha.(This will help to create your animation in a transparent background)


22. You can give a new name by clicking on Output To and browsing a location and a file name. Then Click on Render.


23. Import your .mov file to Photoshop (File-- Import-- Video Frames to Layers). This will import all the layers to photoshop.

24. Then click on File--- Save for Web and Devices, Change the settings you want and Save it. It will output a .GIF file with animated signature.

So that's it. Hope that was helpful.

Thank You.


Friday, September 19, 2014

Microsoft Silverlight Quick Walkthrough

Hi All,

Here I'm going to give you a quick tutorial on Silverlight for anyone who would like to start developing a Silverlight Application. There are ample resources for learning Silverlight on the internet and of course you should refer MSDN for a good learning. So lets start.

What is Silverlight ? 

It's a cross-browser, cross-platform .Net framework implementation for developing Rich Interactive Applications (RIA) for web. Not only web, this can be used to develop Desktop applications as well as in Windows Phone Application Development.
  • It's a plugin to the browsers.
  • Runs on all major browsers.
  • User needs to download and install Silverlight Player.
  • Allows to create Rich Text Web Applications.
  • Gave ability to create rich web apps with VS environment with good programmability.
  • It’s a subset of .Net Framework.


When you are developing Silverlight Applications, you will see that you cannot use the System.Data namespace in your application. Therefore when you need to create you have to use WCF to provide database support for your application.

Lets go through a small Silverlight Application.

Create a new Demo Application check the option to host the Silverlight Application in a new website. This option will create a web project with a Silverlight Application test page.




App.xaml is like a startup guide. It’s got events, when things to start-up. When you create Silverlight Application it will zip the project into a .xap file.

Don’t just drag and drop the controls, that will just create a web site not like flow layout. That won’t get adjusted when you resize the browser. We will discuss later how we can make them more dynamic.

The markups that will be created in your design window, when you drag and drop a button are the XAML markup. It tells how the button should be : width, height etc.


You can use the StackPanel to stack the items in your application vertically. You can also change that to stack the items in horizontal direction.

Document outline provides you all the parent child relationship of the controls. Everything is usercontrol in Silverlight. Inside that, you’ll have parent and child controls. You can see the relationship in the Document Outline.


Grid is like a html table. It allows you to create rows and columns. 

<Grid x:Name="LayoutRoot" Background="White"></Grid>

You can use the canvas controller to provide an absolute layout. Provides an absolute positioning. It will position the child controls relative to the parent control.


You will see attributes like Canvas.Left="6" Canvas.Top="6" in your XAML code. These are called attached properties. 

To create rows and columns in the Grid, you can easily use the Design View.You can click on that border to create row column definitions. You can move the cross and click to define rows/columns.


You can create a grid like below using the above method. 


Following image will give you the idea about Margin, Padding, Border and Content. You can learn more about alignment from this linkMargins and paddings are just like in CSS. Top-right-bottom-left order is different in XAML. It starts with Left.
Don’t use hard coded row/column sizes. You can make them auto.

<Grid x:Name="LayoutRoot" Background="White">
   <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="2*" />
      <RowDefinition Height="*" />

Make use of auto sizing. That will help you a lot.


Once you are not sure about the sizes and if you want to reset them, you can just right click on the controllers and then Reset Layout-> All and all the styles will be removed. 


If you want to insert columns/rows you can just add them above or below the columns/rows and the XAML will be updated accordingly in the designer.


You can add styles like margins by clicking on the control and updating the Margin property in the property window.


So as this is a demo application this will be fine to add margins by adding them on each one. But imagine a situation where you want a consistent style throughout the application with hundreds of controls. It will be a nightmare to do that. So how can we do it easily?

So first we want to remove margins. You would just select all controls and set the margin to 0. But that won’t remove the style from the markup.


But you can remove the markup by resetting the values.



 This will remove the markup from your XAML.


In like CSS in web, we can define behaviors for controls in XAML. We have to create these resources/ set of styles at many different levels.

So let’s go to Gird and create Grid.Resources Element and inside that we can add a style with a target type. Inside the style, we can set the properties where the styles should be added. 


So the margins will be added to textblocks within the grid. So lets apply this style from the UserControl level.

Remove the Grid.Resources and then lets add new element inside user control named UserControl.Resources

<UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Margin" Value="10"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="Margin" Value="10"/>
        </Style>
</UserControl.Resources>

So if you want to apply the style to the whole application, you can do that by applying the style to App.xaml page. So remove the style from the UserControl.Resources and go to the App.xaml page and add inside the Application.Resources Tag. 

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="DemoApplication.App"
             >
    <Application.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Margin" Value="10"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="Margin" Value="10"/>
        </Style>
    </Application.Resources>
</Application>

So now we have the style in a global scope.

You can even move these styles into a resource dictionary. You can put it into a Silverlight class library and you can reference that throughout the application. That’s great for corporate branding.
There are keyed styles, where you can attach the names into these and specifically reference to them.  

<Style TargetType="TextBlock" x:Key="TextBlock.Normal">
            <Setter Property="Margin" Value="10"/>
</Style>

Now you can apply the styles by editing the style property in the control’s window.



Let’s see how would be the XAML by now. 

<TextBlock Name="textBlock1" Text="First Name" Style="{StaticResource TextBlock.Normal}" />

You can also apply styles on another property called “BasedOn”. So that will add additional styles, based on that style.
However the local Style will always get the priority, so that the lowest one can override the global styles.
You can use many more controls like, sliders, media players, text boxes, password boxes etc.

Binding
Bind a checkbox with two child checkboxes so that if only the main is checked, others will be checked.


Bind text boxe text with a class. Instantiate the class in XAML markup. Add the class reference.

 <UserControl.Resources>
        <data:Customer x:Key="myCustomer" FirstName="Kinath" LastName="Rupasinghe"/>
</UserControl.Resources>


Binding a list of cutomers to a data grid.

Class file.

public class Customer
    {
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string FullName
        {
            get
            {
                return this.FirstName + this.LastName;
            }
        }
    }

    public class Customers : List<Customer>
    {    }

XAML : 

<UserControl.Resources>
        <data:Customers x:Key="customerCollection">
            <data:Customer FirstName="Kinath" LastName="Rupasinghe"/>
            <data:Customer FirstName="Kinath" LastName="Rupasinghe"/>
            <data:Customer FirstName="Kinath" LastName="Rupasinghe"/>
        </data:Customers>       
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">       
        <sdk:DataGrid AutoGenerateColumns="True"
                      Height="189" HorizontalAlignment="Left" Margin="12,99,0,0"
                      Name="dataGrid1" VerticalAlignment="Top" Width="376"
                      ItemsSource="{Binding Source={StaticResource customerCollection}}" />
    </Grid>

This will produce an application like this. 

So this is just a quick tutorial on how we can use Silverlight. Hope this would help. 

Thank You.