Haiku Animation

broken image


Animation is one of the main features of Haiku Animator, and the heart of creating animations in Animator is the Timeline. Using a combination of the Timeline and Stage, you can move and transform elements in your component over time, with the result being... animation!


Play as Haiku and dash, slash and grapple your way through a world full of different areas waiting to be explored, each filled with different enemies, bosses and surroundings. The game features beautiful and atmospheric 8-bit pixel art. Everything is drawn by hand and animated frame-by-frame to achieve that retro Metroidvania look. Thanks for dropping by The Haiku Review! Take a look around and grab the RSS feed to stay updated. Tags: 2012, 3D, Animated, Death, Dogs.

  • The Haiku Deck editor is simple. You won't find fancy animations, transitions, or wild text effects. What you find are simple tools for text, layout, and inserting images. What really distinguishes Haiku Deck from other presentation apps is the ability to search its libraries for high-quality images that become the focus of your presentation.
  • Play as Haiku and dash, slash and grapple your way through a world full of different areas waiting to be explored, each filled with different enemies, bosses and surroundings. The game features beautiful and atmospheric 8-bit pixel art. Everything is drawn by hand and animated frame-by-frame to achieve that retro Metroidvania look.
  • In Haiku Core, adapters take care of turning the rendering and layout returned by the engine into an actual visible, animated, and interactive element — inside whatever the host platform is. Out of the box, Haiku Core ships with a DOM adapter (for rendering in web pages), a React DOM adapter (for rendering Animator components inside React DOM.

Think of it like this: While the Stage shows what each element in your project looks like as it animates, the Timeline depicts how the elements' properties change.

The Stage is pretty self-explanatory — especially if you're familiar with a drawing tool like Sketch.

But the Timeline may seem intimidating if you're new to animation. Don't be scared! We'll do our best to make it as accessible and familiar as possible. (If you've used Adobe After Effects, Flash, or even Final Cut, then you're probably already familiar with the idea.)


THINKING LIKE AN ANIMATOR

It's helpful, first of all — especially if you're just starting out — to try to get into the mindset of an animator.

To think like an animator means to think about what elements will look like at various points in time, and then how those elements will transition between one point in time and the next.

In more technical terms, the same idea could be expressed as this question: How does the X position or the Y position of some element change over the span of 1 second?

Using the Timeline, you can precisely control the answer.


TIMELINE - OVERVIEW

The Timeline consists of a few fundamental pieces:

  • A list of all of the elements currently on stage
  • Beneath each element heading, a list of the element's properties
  • Property input fields showing the value for each property
  • Keyframes and transitions, which show how values change over time
  • A ticker, which represents the current point in time being edited


TIMELINE - ANATOMY

Stepping back and taking a wider view, this is the overall anatomy of the Timeline. (These terms are defined visually here for clarity when they're referenced elsewhere in the docs.)


Haiku animation

HOW TIMELINE AND STAGE INTERACT

To understand how the Timeline and Stage interact, let's look at how a simple design (a heart, as shown here) moves around on the stage when animations have already been defined on the timeline.

When the ticker is at frame 0, the heart is shown on the stage at its initial position (150, 168).

If we press the play button and wait until frame 10 is reached, we see that the heart jumps to a new position, (211, 217). That's because frame 10 is marked as a keyframe for a change in the position.x and position.y properties of the element.

Keep playing, and soon the ticker will reach frame 15. The heart's position jumps again, this time to the position (288, 97). As you can see, there are two more keyframes defined at frame 15, which explains the jump to the new position.

The keyframes at frame 15 indicate the beginning of a transition (or tween) for the position.x and position.y properties. Thus, instead of jumping instantly from the baseline position (288, 97), the heart will slide smoothly between until it reaches the destination position (84, 119).

Each transition is associated with an easing curve, which designates what the smooth movement between the two values should look like. There are many easing curves to choose from, but we'll cover those later.


Haiku animation tutorial

HOW TIMELINE AND STAGE INTERACT

To understand how the Timeline and Stage interact, let's look at how a simple design (a heart, as shown here) moves around on the stage when animations have already been defined on the timeline.

When the ticker is at frame 0, the heart is shown on the stage at its initial position (150, 168).

If we press the play button and wait until frame 10 is reached, we see that the heart jumps to a new position, (211, 217). That's because frame 10 is marked as a keyframe for a change in the position.x and position.y properties of the element.

Keep playing, and soon the ticker will reach frame 15. The heart's position jumps again, this time to the position (288, 97). As you can see, there are two more keyframes defined at frame 15, which explains the jump to the new position.

The keyframes at frame 15 indicate the beginning of a transition (or tween) for the position.x and position.y properties. Thus, instead of jumping instantly from the baseline position (288, 97), the heart will slide smoothly between until it reaches the destination position (84, 119).

Each transition is associated with an easing curve, which designates what the smooth movement between the two values should look like. There are many easing curves to choose from, but we'll cover those later.


INTERACTING WITH THE TIMELINE

When you drag the timeline ticker left or right, you're changing the current time.

Any changes you make while the ticker is at a certain position will affect the values (keyframes) specifically at that time.

Once you've affected values at two such points in time (i.e., created keyframes), you can then create a transition to have Animator automatically ease between the values. Experiment with different easing curves to finesse your animations!

Advanced: Animating along curves
While we plan to support custom, visual animation along paths in the future, there's a lot you can do with Animator today. Since you can animate X and Y position separately, try out different easing curves for each of X and Y positions. For example, if you animate linear with X and ease in > quadratic with Y, you can plot half of a parabola (then ease out > quadratic with Y while continuing linearly with X to plot the other half.) You can do the same thing with sin, circ, bounce, and any number of other transitions to create complex parametric path animations.


USING THE STAGE TO CREATE KEYFRAMES

If you drag an element across the stage at a point in time, keyframes will automatically be created at that time. That is, dragging an element on stage is exactly the same as editing the X Position and Y Position properties in the at that point in time!

Both techniques are 'windows' into the same underlying data.

In fact, both of these techniques also have exactly the same outcome as editing the values manually in the code — which you can read more about under Advanced: Editing Animator projects as Code.


USING PROPERTY INPUTS TO CREATE KEYFRAMES

First, move the ticker to frame 10, then double click the 'rotation' value to focus the input:

Then, change the value to the desired rotation value, and press Enter to save the value. Keyframes for the value 1.234 will be created at that point in time:


Writing expressions in property inputs

Property inputs can contain more than just simple values. They can be little snippets of code that we call expressions. A la Microsoft Excel, just begin your property input value with an equals sign, and the input will recognize that you're typing in an expression.

Expressions are a powerful tool and there's a lot you can do with them, so we've covered them in detail in the expressions guide.


CREATING OR EDITING A KEYFRAME

New keyframes are automatically created when you:

  1. advance the ticker to a new point in time and then
  2. change properties on the stage (e.g. by resizing or moving an element) or numerically in the properties panel.

You can also create a keyframe by right-clicking on any property in the timeline and selecting 'Create Keyframe'.


To move a keyframe itself, simply click and drag to the left or right.

To edit the value of a keyframe, simply align the ticker over the keyframe, then edit the property visually on stage (e.g. drag the object), or numerically via the property inputs (e.g. change the value in the input field to the desired value).


CREATING OR EDITING A TRANSITION/TWEEN

Once you've created two keyframes (there's always a keyframe at the first frame) you can create a Transition. Animator will then ease between the values of the two keyframes, along the Easing Curve that you specify.

To create a transition, right-click between two keyframes, then choose 'Create Tween' > and select your desired curve.

After creating a transition, you can always modify it by right-clicking on the transition and choose one of the following two options:

  • 'Change Tween >': lets you select a curve from a set of predefined curves.
  • 'Edit Bezier Curve' >: lets you create a customized Cubic Bezier Curve.


ZOOMING WITH THE TIMELINE

You can zoom in or out with the timeline by dragging either end of the horizontal scroll bar. Notice the white vertical tick in the scrollbar — this shows you where the Ticker is along the timeline, while the width of the scrollbar shows how much of the timeline is currently visible in the viewport.


CHANGING TIMELINE UNITS

You can click the number in the 'Ticker Position (Current Frame)' box on the top of the timeline to toggle between showing units in Seconds vs Frames.


Next: Keyboard shortcuts & Input →

Have you ever painstakingly built an animation using code — JavaScript, or Core Animation, or CSS — and thought there must be a better way? Have you ever dreamed of a tool that lets you design the parts of your app the need designing, and code the parts that need coding?

We've dreamed of this, too! This is why we set out to build Animator, a tool for desiging and building animated, cross-platform UI components. Our mission is to bring design and code closer together — and to do this, we do a lot of integrating.

Animator integrates with Sketch so you can use familiar drawing tools; it integrates with Git and npm so that designers and developers can work with a shared version history; it integrates with Lottie so you can export native animations for Android and iOS; and it integrates with React so that your designed components work seamlessly with any React web app.

Now Animator integrates with Vue, too. This means Animator components are first-class citizens in Vue applications. Pull components in through npm, nest them with other Vue components, pass in live data through props — it's the same Vue you know and love, but a lot more animated.

Here's Evan You's take on it: (the creator of Vue)

Quite impressed with @HaikuForTeams - allows you to design complex animations with GUI and use in an existing Vue app as a component: https://t.co/3WaS37paNS

— Evan You (@youyuxi) February 28, 2018

Let me show you an example. I've crafted a very simple Whac-A-Mole game: all the animation and logic related to the game itself is handled internally by the Animator component while the score tracking is handled by Vue. The component is able to communicate back and forth with the Vue app with ease.

Animator automatically hosts Git repositories for every project you create (private by default). Here's the source for this component.

In this post we'll explore the basics of Haiku Core, the rendering engine that powers Animator for Mac, as well as the new Vue adapter, while showing how we built out the adapter itself.

Haiku Core

Haiku Core itself is a platform-agnostic UI component library. Give it a JavaScript object that fits the specification of an Animator component, and it will give you an object that describes how it should be rendered.

But just describing how to render isn't very interesting or useful. Normally, you want to see something on your screen! That's where the concept of adapters comes in.

In Haiku Core, adapters take care of turning the rendering and layout returned by the engine into an actual visible, animated, and interactive element — inside whatever the host platform is. Out of the box, Haiku Core ships with a DOM adapter (for rendering in web pages), a React DOM adapter (for rendering Animator components inside React DOM components), and the Vue.js adapter. You can also export Animator projects to Lottie, for native animation rendering on iOS, Android, and React.

Before diving into adapter-specific code, let's take a peek into the internals of Haiku Core and its relationship with Animator for Mac in order to discover some of Haiku Core's possibilities and features.

Your design is code

With Animator anyone can build interactive components for any web page or native app.

When you design in Animator, you're writing code (well, Animator does it for you). And when you edit the code, you're updating the design. This bridge between design and code goes both ways. This works because the Animator design format is no more than a JavaScript object, which Animator knows how to read and write.

We informally call this normalized definition of a component the bytecode. This way of representing components enables Animator to provide an amazing set of features such as shared version histories for designers and developers.

From bytecode to live components

Here's an example of a simple component definition, to get a taste of what it looks like:

In order to render this component definition, Core needs a DOM element to attach the component and an optional set of options that allows you interact with your it by providing live data, hooking into its lifecycle events and more.

ADVANCED: Building the wrapper

If you want to use Animator to design and build app components, you've already read far enough. However, if you want to know more about the internals, or would like to integrate Animator with another library (looking at you, Angular!) then read on.

Now that we have a basic understanding of what's behind the covers, let's create a Vue wrapper that can be used for consumers of Core to render idiomatic components.

Inside of this component, we need to tell to Core where and how to attach our animation, and we are going to do this by taking advantage of Vue lifecycle hooks:

  • When the component is mounted, we are going to create an instance of our animation, just like we did in with our sample component definition above.
  • When the component is destroyed, we are going to let know to our animation that is being unmounted by calling the component instance method callUnmount.

Lastly, we are going to define a render function that it's going to render an empty div which we can use to attach our component:

Accepting options

As we saw before, Core is able to receive options, and our component is going to receive them via props.

But, since props can be updated once the component is already rendered, we also need to use the updated lifecycle hook to update the animation instance with the new configuration by taking advantage of the Animator component instance method assignConfig.

Note: in this example, we are only accepting haikuOptions and haikuStates, but Core supports even more configuration options!

Lifecycle events

An Animator component also provides lifecycle hooks that are modeled after React lifecycle hooks.

Since Vue exposes a special syntax to deal with events, we want our wrapper to embrace it by providing an interface that looks like this:

Animator lifecycle hooks are declared in the config object that you pass to Core, so we'll need to update our mounted function with the proper hooks, adding a $emit call every time an event is triggered:

Wrapping it up

And that's it! The real adapter has some subtleties related to rendering and adaptation to the codebase, but that is the gist of it. If you want to see the full code, please take a look — it's all open source.

If you want to build an adapter for your favorite framework, we are open source and very much enjoy pull requests! If you need any help to do so, please ping us in our Slack Community.

DESIGNER PREVIEW

Haiku Animation Gif

Get Animator For Mac



broken image