CN109858421B - Android platform handwriting playback method and device based on scalable vector graphics - Google Patents
Android platform handwriting playback method and device based on scalable vector graphics Download PDFInfo
- Publication number
- CN109858421B CN109858421B CN201910069844.4A CN201910069844A CN109858421B CN 109858421 B CN109858421 B CN 109858421B CN 201910069844 A CN201910069844 A CN 201910069844A CN 109858421 B CN109858421 B CN 109858421B
- Authority
- CN
- China
- Prior art keywords
- path
- playback
- handwriting
- animation
- stroke
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Processing Or Creating Images (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
The invention discloses an android platform handwriting playback method based on a scalable vector graph, which comprises the following steps of: s1: identifying the Path of each stroke generated in the drawing process; s2: saving the identified Path of each stroke to a Path set P; s3: handwriting playback of the font is implemented using a listener and a PathMeasure class. The invention saves the handwriting by Path class as a scalable vector graphic file, greatly reduces the storage space, occupies less memory and is convenient for realizing the playback function to directly perform the code-layer operation; the calculated amount in the playback process can be effectively reduced, the playback code is simplified, and a good animation effect is achieved; and the storage is not needed, the real-time performance is met, and the real-time playback writing process can be realized more flexibly. The invention can greatly reduce the storage space, simultaneously greatly simplify the playback code and improve the code legibility.
Description
Technical Field
The invention relates to the field of handwriting display, in particular to an android platform handwriting playback method and device based on a scalable vector graph.
Background
Playback technology on smart mobile device platforms has been spread throughout many Android (Android) software, such as: copybook software, drawing software, etc. On the market, most software adopts playback handwriting technology, and two popular algorithms are currently adopted: firstly, a historical coordinate backtracking method is adopted, according to the historical positioning coordinates of handwriting stored in advance and the set parameters of playback, the track is redrawn on a drawing board after being retrieved from a database, the drawing completion code is tedious and requires a large memory, and the method does not meet the requirement of light application of mobile equipment; secondly, the recording screen is used for generating the media file and replaying the media file, and the problem of large storage capacity is also caused. Android is a self-contained Picture class, the use process of the Android needs to store, record and draw operations, and media files needing to be stored cause useless space occupation and cannot well reflect real-time performance
Disclosure of Invention
The invention provides an android platform handwriting playback method and device based on a scalable vector graph, which aims to overcome at least one defect in the prior art.
The present invention aims to solve the above technical problems at least to some extent.
The primary aim of the invention is to provide a handwriting playback method based on scalable vector graphics, which solves the problems of large storage capacity and complicated codes in the prior art
It is a further object of the invention to provide a handwriting playback device based on scalable vector graphics.
In order to solve the technical problems, the technical scheme of the invention is as follows:
an android platform handwriting playback method based on a scalable vector graph comprises the following steps:
s1: identifying the Path of each stroke generated in the drawing process;
s2: saving the identified Path of each stroke to a Path set P;
s3: realizing handwriting playback of the font by utilizing a monitor and a PathMeasure class;
the method solves the problem in a relatively low cost mode by using each stroke in a set storage Scalable Vector Graphics (SVG) format and combining an animation class value identifier capable of directly changing attribute values, changing the attribute of any object along with time change through attribute animation, and simultaneously tracking the coordinates of Path through PathMessaging to draw and position, and finally realizing the playback function of the writing process, thereby effectively simplifying codes, avoiding storing too many parameters and generating media files to occupy too large memory, and greatly reducing storage space.
Preferably, the Path of each stroke is saved as an SVG file, SVG is a scalable vector graphics (Scalable Vector Graphics), path class is the most powerful one of the basic shapes of SVG, and handwriting in the drawing process is saved as an SVG file by Path class.
Preferably, the step S1 of identifying the Path of each stroke generated in the drawing process, wherein in the specific step of identifying the Path of each stroke, a font set processing module is used to process the Path, specifically:
s1.1: definition L 0 For the current Path length, L t For the previous Path length, L 0 =L t =0;
S1.2: definition P 0 For the current processing Path, each time a Path is generated in the drawing process, the Path is stored into P 0 Measuring one time P 0 Length L, let L 0 =l;
S1.3: if L 0 Greater than L t S1.4 is performed; if L 0 Not greater than L t S1.5 is executed;
s1.4: let L t =L 0 Definition L h For the historical Path length, let T p Indicating the type of operation, T p E (0, 1), where T p =0 represents an alternate mode, T p =1 represents an addition mode;
if L 0 Greater than 0, L h =L 0 ,P 0 Incoming process P 0 Font set processing module, T p =0;
Skipping step S1.5;
s1.5: if L 0 Not equal to 0 or L H Equal to 0, returning to the step S1.2; if L 0 Equal to 0 and L H Not equal to 0, P 0 Incoming intoProcess P 0 Font set processing module, T p =1;
S1.6: judging T in font set processing module p Is the value of (1):
if T p =0, P 0 Replacing the Path with the Path added last in the Path set P;
if T p =1, handle P 0 Join path set P.
The Path class encapsulates a complex (multi-contoured) geometric Path consisting of line segments, conic, and cubic curves. It may be drawn, filled in with Canvas-like drawPath methods, or used to cut or route text. Because a section of continuous line will generate multiple sections of Path in the drawing process of realizing the drawing function by Canvas class, only one complete stroke of each section of continuous line of the word is recognized in the step.
Preferably, the specific steps of step S2 are:
s2.1: judging whether the path set P is created or not, if not, creating a path set P by the line;
s2.2: definition P s For the target Path variable, L s Is P s Length of incoming Path store P s And measure P s Length l s ,L s =l s ;
S2.3: if the path set P is empty, P is calculated s Directly adding P;
if the path set P is not null and T p Let P be =1 s Adding into P;
if the path set P is not null and T p =0 replaces the last added Path in P;
s2.4: steps S2.1 to S2.3 are repeated until the Path of all strokes is stored in P.
Preferably, the specific steps of step S3 are:
s3.1: traversing path set P, defining P i An i-th Path is acquired;
definition S i Is in an animation state S i =Start,S i ∈{Start,None};
Defining a listener A and a listener B, wherein the listener A is a listener of an Animatostaterenter type and the listener B is a listener of an Animatostateistener type;
s3.2: the animation state is changed by the monitor A, specifically:
the method comprises the steps of (1) setting an animation state as Start, and setting a state representing the Start of animation as Start; an overwrite method onAnimationEnd, setting the animation state as None, and indicating that the animation is finished as None;
s3.3: automatically updating the animation attribute value m E [0,1] by the getAnimatedValue method of the monitor B, and when the animation attribute value m is acquired and updated once, then:
forcing the current view to draw, if S i Start, intercept P i Rendering, define L x Is P i Part of the length, L M Is P i And L is the full length of x =L M * m, iterating for multiple times to realize the playback animation effect;
if S i =none, redraw and display the complete stroke on the drawing board;
the animatronistener class of Android may receive notifications from an animation that indicate relevant events for the animation. While another listening class of Android, the AnimatorUpdateListener class, can receive the callback value calculated by the ValueAnimator for each animation frame by calling the getAnimatedValue function.
An android platform handwriting playback device based on scalable vector graphics, comprising:
the recognition module is used for recognizing the Path of each stroke generated in the drawing process and comprises a font set processing module;
the encapsulation module is used for storing the identified Path of each stroke into the Path set P;
and the animation playback module is used for realizing handwriting playback of the fonts by utilizing a monitor and a PathMessaure class.
Compared with the prior art, the technical scheme of the invention has the beneficial effects that:
the invention saves the handwriting with Path class as SVG file, which greatly reduces the storage space, occupies less memory and is convenient for realizing the playback function to directly operate the code layer; based on the attribute value animation principle and the ValueAnimator class, the handwriting is played back, and the animation effect can be realized by only performing some operations on the monitoring of the animation, setting the value to the length attribute of the Path in the monitoring and continuously updating the attribute value. The calculated amount in the playback process can be effectively reduced, the playback code is simplified, and a good animation effect is achieved; and the storage is not needed, the real-time performance is met, and the real-time playback writing process can be realized more flexibly. The invention can greatly reduce the storage space, simultaneously greatly simplify the playback code and improve the code legibility.
Drawings
FIG. 1 is a flow chart of a scalable vector graphics based android platform handwriting playback method;
FIG. 2 is a flow chart identifying the Path of each segment of strokes produced during the drawing process;
FIG. 3 is a flow chart of saving the Path of each identified stroke to Path set P;
FIG. 4 is a flow chart of implementing handwriting playback of the font using a listener and PathMessaure classes;
FIG. 5 is a diagram showing original handwriting;
FIG. 6 is a diagram of a handwriting playback presentation;
FIG. 7 is a schematic diagram of an android platform handwriting playback device based on scalable vector graphics.
Detailed Description
The drawings are for illustrative purposes only and are not to be construed as limiting the present patent;
for the purpose of better illustrating the embodiments, certain elements of the drawings may be omitted, enlarged or reduced and do not represent the actual product dimensions;
it will be appreciated by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The technical scheme of the invention is further described below with reference to the accompanying drawings and examples.
Example 1
The android platform handwriting playback method based on the scalable vector graphics provided by the embodiment, as shown in fig. 1, comprises the following steps:
s1: identifying the Path of each stroke generated in the drawing process;
s2: saving the identified Path of each stroke to a Path set P;
s3: realizing handwriting playback of the font by utilizing a monitor and a PathMeasure class;
the Path of each stroke is saved as an SVG file;
the step S1 of identifying the Path of each stroke generated in the drawing process, wherein in the specific step of identifying the Path of one stroke, a font set processing module is used to process the Path, as shown in FIG. 2, specifically:
s1.1: definition L 0 For the current Path length, L t For the previous Path length, L 0 =L t =0;
S1.2: definition P 0 For the current processing Path, each time a Path is generated in the drawing process, the Path is stored into P 0 Measuring one time P 0 Length L, let L 0 =l;
S1.3: if L 0 Greater than L t S1.4 is performed; if L 0 Not greater than L t S1.5 is executed;
s1.4: let L t =L 0 Definition L h For the historical Path length, let T p Indicating the type of operation, T p E (0, 1), where T p =0 represents an alternate mode, T p =1 represents an addition mode;
if L 0 Greater than 0, L h =L 0 ,P 0 Incoming process P 0 Font set processing module, T p =0;
Skipping step S1.5;
s1.5: if L 0 Not equal to 0 or L H Equal to 0, returning to the step S1.2; if L 0 Equal to 0 and L H Not equal to 0, P 0 Incoming process P 0 Font set processing module, T p =1;
S1.6: judging T in font set processing module p Is the value of (1):
if T p =0, P 0 Replacing the Path with the Path added last in the Path set P;
if T p =1, handle P 0 Join path set P.
The specific steps of step S2 are shown in fig. 3, and specifically are:
s2.1: judging whether the path set P is created or not, if not, creating a path set P by the line;
s2.2: definition P s For the target Path variable, L s Is P s Length of incoming Path store P s And measure P s Length l s ,L s =l s ;
S2.3: if the path set P is empty, P is calculated s Directly adding P;
if the path set P is not null and T p Let P be =1 s Adding into P;
if the path set P is not null and T p =0 replaces the last added Path in P;
s2.4: steps S2.1 to S2.3 are repeated until the Path of all strokes is stored in P.
The specific steps of step S3 are shown in fig. 4, and specifically are:
s3.1: traversing path set P, defining P i An i-th Path is acquired;
definition S i Is in an animation state S i =Start,S i ∈{Start,None};
Defining a listener A and a listener B, wherein the listener A is a listener of an Animatostaterenter type and the listener B is a listener of an Animatostateistener type;
s3.2: the animation state is changed by the monitor A, specifically:
the method comprises the steps of (1) setting an animation state as Start, and setting a state representing the Start of animation as Start; an overwrite method onAnimationEnd, setting the animation state as None, and indicating that the animation is finished as None;
s3.3: automatically updating the animation attribute value m E [0,1] by the getAnimatedValue method of the monitor B, and when the animation attribute value m is acquired and updated once, then:
forcing the current view to draw, if S i Start, intercept P i Rendering, define L x Is P i Part of the length, L M Is P i And L is the full length of x =L M * m, iterating for multiple times to realize the playback animation effect;
if S i And =none, redraw and display the complete stroke on the palette.
In the specific implementation process, as shown in fig. 5 and 6, fig. 5 shows original handwriting, and the method provided by the embodiment of the essential oil performs handwriting reduction, and the specific process is shown in fig. 6, so that handwriting can be well reduced.
Example 2
The embodiment provides an android platform playback device based on scalable vector graphics, as shown in fig. 7, including:
the recognition module is used for recognizing the Path of each stroke generated in the drawing process and comprises a font set processing module;
the encapsulation module is used for storing the identified Path of each stroke into the Path set P;
and the animation playback module is used for realizing handwriting playback of the fonts by utilizing a monitor and a PathMessaure class.
The same or similar reference numerals correspond to the same or similar components;
the terms describing the positional relationship in the drawings are merely illustrative, and are not to be construed as limiting the present patent;
it is to be understood that the above examples of the present invention are provided by way of illustration only and not by way of limitation of the embodiments of the present invention. Other variations or modifications of the above teachings will be apparent to those of ordinary skill in the art. It is not necessary here nor is it exhaustive of all embodiments. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the invention are desired to be protected by the following claims.
Claims (5)
1. An android platform handwriting playback method based on a scalable vector graph is characterized by comprising the following steps of:
s1: identifying the Path of each stroke generated in the drawing process;
s2: saving the identified Path of each stroke to a Path set P;
s3: realizing handwriting playback of the path set P by utilizing a monitor and a PathMessaure class;
the step S1 of identifying the Path of each stroke generated in the drawing process, wherein in the specific step of identifying the Path of one stroke, a font set processing module is used for processing the Path, specifically:
s1.1: definition L 0 For the current Path length, L t For the previous Path length, L 0 =L t =0;
S1.2: definition P 0 For the current processing Path, each time a Path is generated in the drawing process, the Path is stored into P 0 Measuring one time P 0 Length L, let L 0 =l;
S1.3: if L 0 Greater than L t S1.4 is performed; if L 0 Not greater than L t S1.5 is executed;
s1.4: let L t =L 0 Definition L H For the historical Path length, let T p Indicating the type of operation, T p E (0, 1), where T p =0 represents an alternate mode, T p =1 represents an addition mode;
if L 0 Greater than 0, L H =L 0 ,P 0 Incoming process P 0 Font set processing module, T p =0;
Skipping step S1.5;
s1.5: if L 0 Not equal to 0 orL H Equal to 0, returning to the step S1.2; if L 0 Equal to 0 and L H Not equal to 0, P 0 Incoming process P 0 Font set processing module, T p =1;
S1.6: judging T in font set processing module p Is the value of (1):
if T p =0, P 0 Replacing the Path with the Path added last in the Path set P;
if T p =1, handle P 0 Join path set P.
2. The android platform handwriting playback method based on scalable vector graphics of claim 1, wherein Path of each stroke is saved as a scalable vector graphics file.
3. The android platform handwriting playback method based on scalable vector graphics according to claim 2, wherein the specific steps of step S2 are as follows:
s2.1: judging whether the path set P is created or not, if not, creating a path set P by the line;
s2.2: definition P s For the target Path variable, L s Is P s Length of incoming Path store P s And measure P s Length l s ,L s =l s ;
S2.3: if the path set P is empty, P is calculated s Directly adding P;
if the path set P is not null and T p Let P be =1 s Adding into P;
if the path set P is not null and T p =0 replaces the last added Path in P;
s2.4: steps S2.1 to S2.3 are repeated until the Path of all strokes is stored in P.
4. A scalable vector graphics based android platform handwriting playback method in accordance with claim 3, wherein the specific steps of step S3 are:
s3.1: traversing path set P, defining P i An i-th Path is acquired;
definition S i Is in an animation state S i =Start,S i ∈{Start,None};
Defining a listener A and a listener B, wherein the listener A is a listener of an Animatostaterenter type and the listener B is a listener of an Animatostateistener type;
s3.2: the animation state is changed by the monitor A, specifically:
the method comprises the steps of (1) setting an animation state as Start, and setting a state representing the Start of animation as Start; an overwrite method onAnimationEnd, setting the animation state as None, and indicating that the animation is finished as None;
s3.3: automatically updating the animation attribute value m E [0,1] by the getAnimatedValue method of the monitor B, and when the animation attribute value m is acquired and updated once, then:
forcing the current view to draw, if S i Start, intercept P i Rendering, define L x Is P i Part of the length, L M Is P i And L is the full length of x =L M * m, iterating for multiple times to realize the playback animation effect;
if S i And =none, redraw and display the complete stroke on the palette.
5. An android platform handwriting playback device based on scalable vector graphics, wherein the device applies the android platform handwriting playback method based on scalable vector graphics as claimed in claim 1, and the device comprises:
the recognition module is used for recognizing the Path of each stroke generated in the drawing process and comprises a font set processing module;
the encapsulation module is used for storing the identified Path of each stroke into the Path set P;
and the animation playback module is used for realizing handwriting playback of the fonts by utilizing a monitor and a PathMessaure class.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910069844.4A CN109858421B (en) | 2019-01-24 | 2019-01-24 | Android platform handwriting playback method and device based on scalable vector graphics |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910069844.4A CN109858421B (en) | 2019-01-24 | 2019-01-24 | Android platform handwriting playback method and device based on scalable vector graphics |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109858421A CN109858421A (en) | 2019-06-07 |
CN109858421B true CN109858421B (en) | 2023-06-06 |
Family
ID=66896022
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910069844.4A Active CN109858421B (en) | 2019-01-24 | 2019-01-24 | Android platform handwriting playback method and device based on scalable vector graphics |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109858421B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111625171B (en) * | 2020-07-28 | 2020-11-03 | 深圳市千分一智能技术有限公司 | Stroke display method, device and equipment and readable storage medium |
CN115280265A (en) * | 2020-10-29 | 2022-11-01 | 京东方科技集团股份有限公司 | Handwriting display method and device based on android system and storage medium |
CN113760432A (en) * | 2021-08-30 | 2021-12-07 | 浙江万朋教育科技股份有限公司 | Graffiti method for restoring handwriting based on H5Canvas |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104750413A (en) * | 2015-03-06 | 2015-07-01 | 北京华夏翰科科技有限公司 | Method and system for playing back handwriting |
CN107180443A (en) * | 2017-04-28 | 2017-09-19 | 深圳市前海手绘科技文化有限公司 | A kind of Freehandhand-drawing animation producing method and its device |
CN108829480A (en) * | 2018-06-11 | 2018-11-16 | 深圳市德安里科技有限公司 | Painting and calligraphy process record method, apparatus, equipment and the storage medium of electronic handwritten plate |
CN109242936A (en) * | 2018-08-29 | 2019-01-18 | 广州优视网络科技有限公司 | Draw method, apparatus, storage medium and the electronic equipment of object content data |
-
2019
- 2019-01-24 CN CN201910069844.4A patent/CN109858421B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104750413A (en) * | 2015-03-06 | 2015-07-01 | 北京华夏翰科科技有限公司 | Method and system for playing back handwriting |
CN107180443A (en) * | 2017-04-28 | 2017-09-19 | 深圳市前海手绘科技文化有限公司 | A kind of Freehandhand-drawing animation producing method and its device |
CN108829480A (en) * | 2018-06-11 | 2018-11-16 | 深圳市德安里科技有限公司 | Painting and calligraphy process record method, apparatus, equipment and the storage medium of electronic handwritten plate |
CN109242936A (en) * | 2018-08-29 | 2019-01-18 | 广州优视网络科技有限公司 | Draw method, apparatus, storage medium and the electronic equipment of object content data |
Non-Patent Citations (1)
Title |
---|
PathMeasure类轨迹动画;按劳分配;《CSDN》;20170525;1页 * |
Also Published As
Publication number | Publication date |
---|---|
CN109858421A (en) | 2019-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109858421B (en) | Android platform handwriting playback method and device based on scalable vector graphics | |
US8248420B2 (en) | Method and system for displaying animation with an embedded system graphics API | |
US20220139352A1 (en) | Method and Device for Image Composition, Electronic Device and Storage Medium | |
CN108010112A (en) | Animation processing method, device and storage medium | |
CN105069104B (en) | A kind of generation method and system of dynamic caricature | |
CN102208180B (en) | Method for rapidly displaying vector font by set top box (STB) | |
CN108205960B (en) | Method and device for rendering characters, electronic map making system and navigation system | |
CN110415319B (en) | Animation production method and device based on PPT, electronic equipment and storage medium | |
JP2013089199A (en) | Electronic comic editing device, method and program | |
US8643674B2 (en) | Rendering changed portions of composited images | |
CN115349136A (en) | Graphic processing system and method based on bitmap graphic elements and GPU | |
CN102932607B (en) | Caption graphics and text information generation method and device | |
CN112135073B (en) | Image character superposition method based on FPGA | |
US20140258921A1 (en) | System and method for ergonomic placement of an object or cursor on a computer display | |
CN101800043A (en) | Method and terminal for displaying vector font | |
CN111161127A (en) | Picture resource rendering optimization method | |
JP6409429B2 (en) | Direct video correction system and program for text, strokes and images | |
CN110727386A (en) | Method, system and storage medium for operating graphic elements of electronic whiteboard | |
CN110737372A (en) | newly-added primitive operation method and system for electronic whiteboard and electronic whiteboard | |
US20210289266A1 (en) | Video playing method and apparatus | |
US20080127062A1 (en) | Method and computer readable medium storing instructions for creating open vector graphic contents | |
CN103544931B (en) | Character generating method and device and application terminal | |
CN111552410A (en) | Writing trace processing method, device, equipment and computer readable storage medium | |
JP2000148126A (en) | Image display device and method | |
CN108897537A (en) | Document display method, computer-readable medium and a kind of computer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |