How to Use SVG to generate a superb page preload sketch animation effect, svg cool

Source: Internet
Author: User

How to Use SVG to generate a superb page preload sketch animation effect, svg cool


Online Demo

Local download

1. Introduction to SVG

A Scalable Vector image is based on a scalable Markup Language (subset of a standard universal Markup Language) and is used to describe a two-dimensional vector image format. It is an open standard developed by the World Wide Web alliance.

2. SVG features

Compared with other image formats (such as JPEG and GIF), the advantages of using SVG are:

SVG images can be created and modified in a text editor

SVG images can be searched, indexed, scripted, or compressed

SVG is scalable

SVG images can be printed with high quality at any resolution

SVG can be amplified without decreasing the image quality

3. browser support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support inline SVG. Internet Explorer 8 or earlier, you can install Adobe SVG Viewer to support SVG.

4. SVG labels

The SVG code starts with <svg> elements, including enable tags <svg> and disable tags </svg>. This is the root element. The width and height attributes can be used to set the width and height of the SVG document. The version attribute defines the SVG version used, and the xmlns attribute defines the SVG namespace.

5. Use SVG to create a sketch line Animation

1) Draw a sketch line first:


<Svg version = "1.1" xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 200 100"> <! -- Whether the fill attribute is filled with stroke for painting, color # AAAAAA stroke-width is the width of the drawing line. d is the specific data. The data here represents the coordinates, line, and so on, you can use the tool to generate --> <path fill = "none" stroke = "# AAA" stroke-width = "2" d = "M62.9 14.9c-25-7.74-56.6 4.8-60.4 24.3-3.73 19.6 21.6 35 39.6 37.6 42.8 6.2-72.9 53.4-116 65-58.9 18.2 191 101 "/> </svg>

You can use tools to generate sketch line parameters,

Introduction to basic SVG labels of related courses

2) SVG implements sketch animation and Its Principle

stroke-dasharray = "100 10"  stroke-dashoffset = "0"

Stroke-dasharray defines the length of the generated line segment, and the gap between the line segment and the line segment. Here there are two parameters

Stroke-dashoffset defines the position where the rendering starts to generate a line segment.

The sketch animation simulation effect and its principle of SVG implementation in related courses

3) Use CSS3 to achieve sketch animation effect

/* Define the keyframe animation * // * Add the animation to the path element */. path {stroke-dasharray: 265.07; stroke-dashoffset: 265.07; animation: dash 3 s linear infinite;/* supports chrome */-webkit-animation: dash 3 s linear infinite ;} @ keyframes dash {from {stroke-dashoffset: 265.07;/* here is the sketch line length in the svg image. You can use js to get */} to {stroke-dashoffset: 0 ;}} /* supports the chrome browser */@-webkit-keyframes dash {from {stroke-dashoffset: 265.07;/* the length of the sketch line in the svg image, you can use js to obtain */} to {stroke-dashoffset: 0 ;}}

Use CSS3 for sketch animation in related courses

4) Adjust the animation effect parameters using Javascript

/* Define related Javascript */var current_frame, // define the total_frames of the current frame, // define the path of all frames, // define the length of the unique path element in svg, // define the sketch length handle generated by path; // define the javascript animation handle path = document. getElementById ('path'), length = path. getTotalLength (); // defines the initialization method var init = function () {current_frame = 0; total_frames = 160; path. style. strokeDasharray = length + ''+ length; // defines the dasharray path. style. strokeDashoffset = length; // defines dashoffset handle = 0;} // defines the actual animation Rendering Method var draw = function () {var progress = current_frame/total_frames; if (progress> 1) {// The animation window is defined here. cancelAnimationFrame (handle);} else {// otherwise, use reqeuestAnimationFrame to generate the animation current_frame ++; path. style. strokeDashoffset = Math. floor (length * (1-progress); handle = window. requestAnimationFrame (draw) ;}// define a re-run method var rerun = function () {init (); draw () ;}// run rerun () upon page loading ();

Here we mainly define the initialization method and animation rendering method, window. requestAnimationFrame (draw );

To generate an animation.

Related courses use Javascript For sketch animation

5) we use the geek label logo as the original image, and use the Inkscape tool to generate the coordinate parameters.


When you run the animation rendering program, you can install and set various lines to draw the program. We can see a very cool pre-loaded animation.

For the complete effect, visit the light Video Course: use javascript to generate a sketch animation of the geek tag Logo


Learn to make animations

Your understanding is correct, and you cannot do well without 2D basic 3D. It is wrong to stick to it quickly, because it is only hard work and hard work that requires a quick brain, the above is just a joke. Let's simply put it down. Any software can be used for animation. Because the software is just a tool, this is an additional item, and the main item is animation knowledge. Here we will divide it into two points, whether you want to work for one person or multiple people. If you want to work for one person, you 'd better start with the division of labor in animation production, plan yourself as a whole, and then learn about animation production. If you want to work for multiple people, the first thing you need to know is the camera, then the screen, and so on until the end. If you have the basis of Fine Arts, and then hone your movements every day, you should be able to make animations two years later. If you have a good idea and creative ability on this basis, in five years, you can create animations. When chatting, someone said that I met 1000 animators. None of them have the creative ability. You are eager to create an animation.

How can I learn printing and typographical technology by myself?

First Structural Sketch, light and shade sketch, sketch, design sketch, outdoor sketch
Color Principle, color scheme, design color, training of small draft tones, long-term color assignment
Part 2 Photoshop CS2: Photoshop operation basics, image optimization and processing, analysis and production of classic instances
Illustrator CS2: advertisement sign making, lightbox advertisement, clothing advertisement design, enterprise logo design, business card design
IndesignCS2: Professional typographical tools, printing knowledge, and advanced typographical skills
Acrobat7.0: professional electronic document tools that enable mutual conversion between any documents, PDF document generation and conversion
Coreldraw13: Packaging Box Design, leaflets, posters and business cards, product and Commercial Advertisement Design, and business card design
Part 3: Photoshop advanced: explains the application of poster design, packaging box design, cidesign, product advertisement design, and post-processing.
Advanced Illustrator: Ad illustration production, vector tracing, role Paster production, AD creative draft, pre-press production skills, etc.
Part 4: Dreamweaver8.0: webpage layout, production; Html & Css introduction; website management and maintenance, upload and download; Case Analysis
Flash8.0: artist design, webpage color matching, CI, LOGO, Banner production, common webpage animation production, webpage Layout
Fireworks8.0: Design and Analysis of Typical webpage animations, advertisements, titles, and greeting cards; Introduction to MTV production and interactive websites
Part 5 Plane Composition, three-dimensional composition, color composition, color design, font design, layout design, graphic creativity, Poster Design
Part 6 Advertisement Design (CI planning), VI design, printing design, packaging design, book assembly design, visual orientation design, TV advertisement script design, software integration

To engage in graphic design, photoshop, Coreldraw, and straor should be mastered. You can learn the three software by yourself. In the next tutorial, you can learn it by yourself. The basic graphic design is Photoshop and Coreldraw. To Test designers, you must learn four software: Photoshop, Illustrator, and Indesign Acrobat. Design Software commonly used by advertising companies, such as Photoshop, Illustrator, PageMaker, Freehand, and CorelDraw.
1. logo Design (logo design, trademark design)
2. CIS design and VI design (Enterprise Image Recognition System Design)
3. Ad Design and creative Ad Design
4. Poster Design and DM design (Leaflet design)
5. sample design, brochure design, and album Design
6. Design of Building books and Annual Report
7. Packaging Design
8. book illustration, greeting card design, and invitation design
9. Layout Design of newspapers and magazines
10. Various print designs.

Common graphic design software
Graphic design software has always been a hot field of application. We can divide it into two parts: Image Rendering and image processing, for example, modeling and drawing software, rendering software, image processing software, and pre-printing group software. The following describes some common software:

1. AutoCAD

AutoCAD is a famous graphic design software, which was first unveiled at the Comdex conference in 1982. Due to its excellent performance, it is known as the Universal computer aided design software, it is widely used in many graphic and three-dimensional design fields such as architecture, electronics, machinery, advertising, decoration, and clothing. It has become the de facto CAD software with the highest standards and shares in the field of engineering drawing, it can also be seen everywhere in the Chinese market. Currently, AutoCAD can be used on multiple platforms, such as DOS 12.0, Windows 14/2000, 2002/2004, and 2005, and UNIX for workstation running.
AutoCAD is highly open and scalable. The software provides powerful secondary development methods, such as Visual lisp, C ++, ARX, Microsoft Visual Basic for Appli ...... remaining full text>

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.