Kineticjs Tutorials (7)

Source: Internet
Author: User

Kineticjs Tutorials (7)Author: ysm 7. Graphics Transformations 7.1. Linear change

KineticProvides a graphical object for theTransitionto (config)The method realizes the linear transformation of the graph, that is, from the original state linear transformation to the new state, where the state refers to the parameters on the scale. Method ofConfigParameters are some parameters about the graph scale, such asX,Y,Rotation widthheight strokewidth, alpha centeroffset ET. In addition to these scale parameters, a duration parameter , the unit is the second, which specifies how long the linear transformation is done.

For example, the following code allows the graph to move from its original position to the horizontal axis within two seconds and gradually become transparent:

<script>

Shape.transitionto ({

x:100,

alpha:0,

Duration:2

});

</script>

7.2. Speed in the transformation

Kinetic'sTransitionto (config)Method in theConfigParameters include aEasingproperty, refers to whether the transformation is at a more uniform speed to the transformation destination point or in the transformation process at different speeds at different velocities of the transformation.EasingThe values you can set includeEase-in、Ease-out、Ease-in-out、Back-ease-in、Back-ease-out、Back-ease-in-out、Elastic-ease-in, elastic-ease-out, elastic-ease-in-outbounce-ease-in

In the article it is difficult to describe the differences between these values, or specifically written code, in the browser to see the effect bar.

<script>

Shape.transitionto ({

x:100,

Duration:1,

easing: ' ease-out '

});

</script>

7.3. Callback method after transformation is completed

The config parameter in the kinetic Transitionto (config) method also includes a callback method property, which is executed after the transformation is complete.

<script>

Shape.transitionto ({

x:100,

Duration:1,

easing: "Bounce-ease-out",

callback: function() {

Alert ("Transition complete!" );

}

});

</script>

7.4. Start and end of transformation

When executing The Transitionto method, you can return an object variable and use the start (), Stop (), and resume () Methods of the object to start, stop, and resume the execution of the transformation.

<script>

var trans = Shape.transitionto (config);

Start Conversion

Trans.start ();

Stop Conversion

trans.stop ();

Restore Conversion

Trans.resume ();

</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.