Home  >  Article  >  Web Front-end  >  Example of converting jpg image into svg text path animation (with code)

Example of converting jpg image into svg text path animation (with code)

不言
不言Original
2018-08-08 11:20:527289browse

This article brings you an example of converting a jpg image into an svg text path animation (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

I am very interested in svg animation recently. Using svg css can achieve some eye-catching effects. The svg animation appears on the first screen of the Ant Design official website, coding The SVG animation also appears on the homepage of the official website. The effect may seem ordinary to non-front-end developers, but in the eyes of front-end developers, this effect is low-key and flamboyant! This is what you did jq Compare the animate animations and decide the difference! What else do you want to say?

My goal is to create animation effects like Ant Design. I want to create a simpler effect first, such as this text stroke animation effect
Example of converting jpg image into svg text path animation (with code)

How?

Example of converting jpg image into svg text path animation (with code)

This jpg is my avatar, and the final effect is based on this picture.

Example of converting jpg image into svg text path animation (with code)

First, convert the selected area of ​​the image into a path in PS

Example of converting jpg image into svg text path animation (with code)

Example of converting jpg image into svg text path animation (with code)

# #Then export the ps file with the path to Ai

Example of converting jpg image into svg text path animation (with code)

Example of converting jpg image into svg text path animation (with code)##It should be noted that the path of the second letter consists of two parts , a large selection on the outside and a small selection on the inside. Here you need to select "Window" → "Pathfinder" and select "Difference" for the shape mode.

Save it in svg format and get the code:


    
    
    
    
    
    

Modify the css

.st0{fill: none;    
stroke-width:2;    
stroke:#30479B;    
stroke-linejoin:round;    
stroke-linecap:round;    
stroke-dasharray: 250, 250;    
animation: lineMove 5s ease-out infinite;    
}
@keyframes lineMove {
    0%{        
    stroke-dasharray: 0, 250;    
    }
    100%{        
    stroke-dasharray: 250, 250;    
    }
    }

Regarding the combination of svg and css, use this example as a reference:

- fill represents the fill color, and the value of none represents no color

- stroke is the color of the border
- stroke-width defines the thickness of the border
- stroke-dasharray The first parameter of this attribute defines the length of the border dash line, The second parameter is the spacing of the dotted lines. What is a "border dotted line"? You can think that the border is a dotted line instead of a solid line, but the spacing of the dotted lines is 0, which looks like a solid line.
- The @keyframes feature of CSS3 is used here to control the transition animation in the stroke-dasharray style.

The final overall code is as follows


    
    Document
    
    
    
    
    
    
        
        
        
        
        
        
    
    
    
    

Recommended related articles:

How to make icon from symbol in svg

SVG Drawing function: svg realizes drawing a flower (with code)

The above is the detailed content of Example of converting jpg image into svg text path animation (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn