Particle animation implementation method, device, equipment and storage medium
By constructing particle matrix and scaling, the problem of complex and unsmooth particle animation generation is solved, and the regular particle operation within a limited range is achieved, which simplifies the generation process and improves the smoothness of the animation screen.
Patent Information
- Application Number
- CN202110566388.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-24
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2041-05-24
AI Technical Summary
The existing particle animation generation technology has complex implementation processes and the animation screen is not smooth, especially in irregular pictures, the particle coordinate trajectory is irregular, resulting in high development difficulty and reduced effect.
By obtaining particle pixel information in irregular canvas, building a coordinate system, identifying and scaling particle matrix, generating animation screens, and simplifying the particle animation generation process using matrix transformation and scaling algorithms to achieve regular operation of particles within a limited range.
The technical process of particle animation generation is simplified, the fluency of the animation screen is improved, and the random operation of particles with regularity within a limited range is realized.
Smart Images

Figure CN113284218B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a particle animation implementation method, device, equipment and storage medium. Background Art
[0002] Particle animation is a type of computer animation, also known as particle effects. Common particle effects include rain, clouds, starlight, etc. Especially in commercial promotions, particle animation can enhance user engagement.
[0003] Current particle animation development requires first writing a complete set of logic and performing different controls on each part of the animation. This is especially true for irregular screens, where the running and playback trajectories formed by the particle coordinates are irregular, which will affect the original control logic, making development more difficult and the resulting effect less effective. Summary of the Invention
[0004] The main purpose of the present invention is to solve the technical problems that the existing particle animation generation technology has a complicated implementation process and the implemented animation screen is not smooth.
[0005] A first aspect of the present invention provides a particle animation implementation method, characterized in that the particle animation implementation method includes: obtaining pixel information of all particles in the current irregular canvas, wherein the pixel information includes pixel values and colors; determining the vertical coordinate axis and the horizontal coordinate axis based on the outline of the irregular canvas, and screening out the minimum and maximum pixel values from all particles, determining the distribution values of the vertical coordinate axis and the horizontal coordinate axis based on the minimum and maximum pixel values, and obtaining a coordinate system; calculating the coordinate value of each particle in the coordinate system according to the coordinate system and the pixel information of each particle, and obtaining the coordinate information of each particle; constructing a particle matrix based on the coordinate information of each particle and the color of each particle; identifying particles with adjacent coordinate information and the same color in the particle matrix, and scaling the identified particles to obtain a scaling matrix; converting the particles in the scaling matrix to display trajectories, and generating animation pictures corresponding to all particles.
[0006] Optionally, in a first implementation method of the first aspect of the present invention, obtaining pixel information of all particles in the current irregular canvas includes: extracting a video frame in the current irregular canvas using a video cropping algorithm; identifying the configuration information of the particles in the video frame, and extracting pixels in the configuration information to generate a particle set and a pixel data set; extracting the three primary color data values of each pixel in the pixel data set, and calculating the transparency of the particles based on the three primary color values; adding the transparency to the pixel to generate pixel information corresponding to each particle.
[0007] Optionally, in a second implementation of the first aspect of the present invention, constructing a particle matrix based on the coordinate information of each particle and the color of each particle includes: constructing a particle display map outline according to the irregular canvas; punctuating all particles in the display map outline in turn according to the coordinate information to form a particle map prototype; rendering the punctuation points in the particle map prototype in color according to the three primary color values and transparency of each particle, and setting the corresponding transparency to form a complete particle map; using a binary conversion algorithm, converting the punctuation points in the complete particle map whose transparency is greater than a preset value into non-null values, and converting the punctuation points in the complete particle map whose transparency is less than the preset value into null values to obtain a particle matrix.
[0008] Optionally, in a third implementation of the first aspect of the present invention, after the punctuation points in the particle map prototype are color rendered according to the three primary color values and transparency of each particle, and before the corresponding transparency is set to form a complete particle map, it also includes: color marking the rendered punctuation points, and adjusting the punctuation points with the same mark to adjacent displays; and establishing a color association relationship between the punctuation points with the same mark.
[0009] Optionally, in a fourth implementation method of the first aspect of the present invention, the scaling processing of the identified particles to obtain a scaling matrix includes: setting matrix coordinates for each non-null value in the particle matrix to obtain a coordinate matrix; calculating the scaled coordinate value of each matrix coordinate in the coordinate matrix according to a preset scaling ratio; rounding the scaled coordinate values to obtain integer scaled coordinate values; and merging the coordinate values with the same vertical and horizontal coordinates in the integer scaled coordinate values to obtain a scaling matrix.
[0010] Optionally, in a fifth implementation of the first aspect of the present invention, the particles in the scaling matrix are converted into display trajectories to generate animation pictures corresponding to all particles, including: performing a single-point call on each particle in the scaling matrix, and using optical principles to collect the position of the particle in the irregular canvas after the call and display and the flashing light sensitivity; after all the particles in the scaling matrix are called, generating a dynamic trajectory of the particle based on the recorded position and light sensitivity; analyzing the available easing animation function in the dynamic trajectory; setting the pixel points outside the dynamic trajectory in the irregular canvas to a black background, and animating the dynamic trajectory based on the easing animation function to obtain an animation picture of the particle.
[0011] Optionally, in a sixth implementation of the first aspect of the present invention, the animation rendering of the dynamic trajectory based on the easing animation function to obtain the animation picture of the particle includes: extracting the starting point, end point and duration length of the dynamic trajectory; using the easing animation function in the Tween algorithm to formulate the starting point, end point and duration length of the particle to form an animation picture of the particle.
[0012] The second aspect of the present invention provides a particle animation realization device, comprising: an acquisition module for acquiring pixel information of all particles in the current irregular canvas, wherein the pixel information includes pixel values and colors; a coordinate construction module for determining the vertical coordinate axis and the horizontal coordinate axis based on the outline of the irregular canvas, and screening out the minimum and maximum pixel values from all particles, and determining the distribution values of the vertical coordinate axis and the horizontal coordinate axis based on the minimum and maximum pixel values to obtain a coordinate system; a calculation module for calculating the coordinate value of each particle in the coordinate system according to the coordinate system and the pixel information of each particle to obtain the coordinate information of each particle; a matrix construction module for constructing a particle matrix based on the coordinate information of each particle and the color of each particle; a scaling module for identifying particles with adjacent coordinate information and the same color in the particle matrix, and scaling the identified particles to obtain a scaling matrix; a generation module for converting the particles in the scaling matrix to display trajectories to generate animation pictures corresponding to all particles.
[0013] Optionally, in a first implementation method of the second aspect of the present invention, the acquisition module is specifically used to extract video frames in the current irregular canvas using a video cropping algorithm; identify the configuration information of particles in the video frame, and extract pixels in the configuration information to generate a particle set and a pixel data set; extract the three primary color data values of each pixel in the pixel data set, and calculate the transparency of the particles based on the three primary color values; add the transparency to the pixels to generate pixel information corresponding to each particle.
[0014] Optionally, in a second implementation of the second aspect of the present invention, the matrix construction module includes: an outline construction unit, which is used to construct a particle display map outline based on the irregular canvas; a marking unit, which is used to punctuate all particles in the display map outline in turn according to the coordinate information to form a particle map prototype; a map generation unit, which is used to color the punctuation points in the particle map prototype according to the three primary color values and transparency of each particle, and set the corresponding transparency to form a complete particle map; a matrix construction unit, which is used to use a binary conversion algorithm to convert the punctuation points in the complete particle map whose transparency is greater than a preset value into non-null values, and convert the punctuation points in the complete particle map whose transparency is less than the preset value into null values, to obtain a particle matrix.
[0015] Optionally, in a third implementation of the second aspect of the present invention, the matrix construction unit is further used to: color-mark the rendered punctuation marks, and adjust the punctuation marks with the same marks to adjacent displays; and establish color association relationships between punctuation marks with the same marks.
[0016] Optionally, in a fourth implementation of the second aspect of the present invention, the scaling module includes: a setting unit for setting matrix coordinates for each non-empty value in the particle matrix to obtain a coordinate matrix; a scaling unit for calculating the scaled coordinate value of each matrix coordinate in the coordinate matrix according to a preset scaling ratio; a rounding unit for rounding the scaled coordinate value to obtain an integer scaled coordinate value; and a merging unit for merging coordinate values with the same vertical and horizontal coordinates in the integer scaled coordinate values to obtain a scaling matrix.
[0017] Optionally, in a fifth implementation of the second aspect of the present invention, the generation module includes: a display unit for performing a single-point call on each particle in the scaling matrix, and using optical principles to collect the position of the particle in the irregular canvas after the call and display and the flickering light sensitivity; a recording unit for generating a dynamic trajectory of the particle according to the recorded position and light sensitivity after all the particles in the scaling matrix have been called; an analysis unit for analyzing the available easing animation function in the dynamic trajectory; a rendering unit for setting the pixel points outside the dynamic trajectory in the irregular canvas to a black background, and animating the dynamic trajectory based on the easing animation function to obtain an animated picture of the particle.
[0018] Optionally, in a sixth implementation of the second aspect of the present invention, the generation module includes: an extraction unit for extracting the starting point, the end point and the duration of the dynamic trajectory; and a picture generation unit for using the easing animation function in the Tween algorithm to formulate the starting point, the end point and the duration of the particle to form an animated picture of the particle.
[0019] The third aspect of the present invention provides a particle animation implementation device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory to enable the particle animation implementation device to execute the above-mentioned particle animation implementation method.
[0020] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned particle animation implementation method.
[0021] In the technical solution of the present invention, scattered particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain a scaling matrix. Based on the scaling matrix, a single-point call of the particle is made and the display trajectory is captured to generate an animated picture. This method realizes the simplified classification of the matrix, avoids the phenomenon of overly complex particle coordinates in an irregular canvas, thereby avoiding the influence of coordinate factors when making particle animations, and realizes the production of regular random movement of particles within a range of a few times the length and width, simplifies the complex implementation process of the existing particle animation generation technology, and improves the smoothness of the animation picture. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a schematic diagram of a first embodiment of a particle animation implementation method according to an embodiment of the present invention;
[0023] Figure 2 Schematic diagram of a second embodiment of a particle animation implementation method according to an embodiment of the present invention;
[0024] Figure 3 Schematic diagram of a third embodiment of a particle animation implementation method according to an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of a first matrix in an embodiment of the present invention;
[0026] Figure 5 Schematic diagram of matrix 2 according to an embodiment of the present invention;
[0027] Figure 6 Schematic diagram of matrix three in an embodiment of the present invention;
[0028] Figure 7 Schematic diagram of matrix 4 according to an embodiment of the present invention;
[0029] Figure 8 Schematic diagram of a coordinate matrix in an embodiment of the present invention;
[0030] Figure 9 A schematic diagram of an embodiment of a device for realizing particle animation according to an embodiment of the present invention;
[0031] Figure 10 A schematic diagram of another embodiment of a particle animation implementation device according to an embodiment of the present invention;
[0032] Figure 11 Schematic diagram of an embodiment of a particle animation implementation device in an embodiment of the present invention. DETAILED DESCRIPTION
[0033] An embodiment of the present invention provides a particle animation implementation method, device, equipment and storage medium. The method mainly uses a combination of computer graphics and algorithms to improve the problem that particle animation cannot be applied in specific scenarios. Scattered particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain a scaling matrix. After a single point call of the particle is made based on the scaling matrix, the display trajectory is captured to generate an animation picture. In this way, regular random movement of particles can be produced within a limited range, simplifying the complex implementation process of existing particle animation generation technology.
[0034] The terms "first," "second," "third," "fourth," and the like (if any) in the description and claims of the present invention and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or apparatus.
[0035] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the particle animation implementation method in the embodiment of the present invention has the following implementation steps:
[0036] 101. Get the pixel information of all particles in the current irregular canvas;
[0037] In this step, the irregular canvas is the outline of the picture circled by the user in the current picture to be displayed, or it can be the outline of each area to be displayed in the current picture to be displayed. Of course, the area to be displayed is an irregularly shaped area.
[0038] In this embodiment, the pixel information specifically refers to the pixel size and display color information of the particles in the picture, and this information is obtained through image recognition technology. Of course, in this step, the position range of the particles in the display picture can also be calculated, and the display color information of the particles and the percentage of the picture to be displayed can be obtained by matching the position range with the color allocation area in the picture to be displayed, thereby obtaining the pixel size of the particles.
[0039] In practical applications, the pixel information may also be obtained through an initialization operation, which is specifically implemented in the following manner:
[0040] This includes creating a new canvas and obtaining its context and drawing environment to prepare for subsequent graphics drawing.
[0041] Draw the current canvas: Use drawImage to draw an image object or an image of a specified position and size on the canvas, or each frame of the video object onto the current canvas.
[0042] Use the getImageData interface to obtain the data of all pixels at a specified position on the canvas, and set the sorting rules for the obtained array to save the pixel information.
[0043] The ordering rule for storing pixel information is the RGBA value of the first pixel, the RGBA value of the second pixel, ..., the RGBA value of the Nth pixel.
[0044] When obtaining pixel information, the record information generated when the new canvas is created is read, and the configuration parameters of each pixel point are parsed based on the record information, thereby obtaining the pixel information of the corresponding particle.
[0045] 102. Determine the ordinate axis and the abscissa axis based on the outline of the irregular canvas, select the minimum and maximum pixel values from all particles, determine the distribution values of the ordinate axis and the abscissa axis based on the minimum and maximum pixel values, and obtain a coordinate system;
[0046] 103. Calculate the coordinate value of each particle in the coordinate system based on the coordinate system and the pixel information of each particle to obtain the coordinate information of each particle;
[0047] In this step, the coordinate system is specifically constructed based on the picture to be displayed where the irregular canvas is located, specifically using two adjacent sides of the picture to be displayed as vertical and horizontal coordinates, and then the specific values of the vertical and horizontal coordinates are calculated according to the resolution and total size of the picture to be displayed. Based on this coordinate system, after determining the pixel information of the particles, the pixel information is converted into coordinate values in the coordinate system, thereby obtaining the coordinate information of each particle.
[0048] 104. Construct a particle matrix based on the coordinate information of each particle and the color of each particle;
[0049] In this step, when constructing the particle matrix, all particles are specifically sorted according to the coordinate information of the particles. Preferably, the particles are first sorted by the horizontal coordinate, and the particles with the same horizontal coordinate are classified into one row, thereby forming multiple row elements of the matrix. Then, each row element is sorted for a second time. The second sorting is performed based on the coordinate value of the vertical coordinate, thereby obtaining row elements in a complete order. Finally, the multiple row elements are sorted in the order of increasing horizontal and vertical scales from top to bottom to obtain the particle matrix.
[0050] 105. Identify particles with adjacent coordinate information and the same color in the particle matrix, and perform scaling processing on the identified particles to obtain a scaling matrix;
[0051] In this step, after forming the particle matrix, the particles in each row element are marked with display colors to obtain the color association relationship, and then adjustments are made according to the display colors, and row elements with the same display colors are adjusted to be arranged adjacently, thereby obtaining the particle matrix.
[0052] In this embodiment, the matrix scaling algorithm refers to the scaling rule of coordinates. Specifically, taking compression by 2 as an example, the vertical and horizontal coordinates of the elements in each row are divided by 2, and the final compressed coordinate value is obtained by rounding up. The particles with the same compressed coordinate value are merged to obtain the scaling matrix.
[0053] 106. Perform a display trajectory conversion process on the particles in the scaling matrix to generate animation images corresponding to all particles.
[0054] In this embodiment, the single-point playback configuration parameters for the particles in the scaling matrix are obtained, and a single-point call is made to the particles. The trajectory capture program is started, the trajectory of the single-point called particles is captured, the coordinate information of the captured particles in the display screen is calculated, and the coordinate information is compared with the particle coordinate information in the scaling matrix. The calls are sorted according to the comparison results, and then an animation screen is generated based on the sorting.
[0055] In practical applications, the generation of animated images can be specifically generated by the shader in the image processor. The specific shader performs three-dimensional modeling based on the sorted particle sequence to obtain a display model containing the call trajectory of all particles, and then renders it according to the display color of each particle to generate a dynamic particle flashing image.
[0056] By implementing the above method, the scattered particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain a scaling matrix. Based on the scaling matrix, a single point call of the particle is made and the display trajectory is captured to generate an animation picture. This method realizes the simplified classification of the matrix, avoids the phenomenon of overly complex particle coordinates in an irregular canvas, and thus avoids the influence of coordinate factors when making particle animations. It realizes the regular random movement of particles within a range of a few times the length and width, simplifies the complex implementation process of the existing particle animation generation technology, and improves the smoothness of the animation picture.
[0057] See also Figure 2 The second embodiment of the particle animation implementation method in the embodiment of the present invention includes:
[0058] 201. Extracting video frames from the current irregular canvas using a video cropping algorithm;
[0059] In practical applications, the irregular painting can be a static area or a dynamic video, with a complete display area consisting of multiple video frames. When it is a video, the step of extracting pixel information of all particles in the irregular canvas is specifically achieved through a video cropping algorithm. The video cropping algorithm extracts video frames from the video according to the playback time frame to obtain a frame set, and then records the particles displayed in each video frame in the frame set.
[0060] 202. Identify configuration information of particles in a video frame, extract pixels in the configuration information, and generate a particle set and a pixel data set;
[0061] In this step, the presence of particles in the video frame is identified by recording the particles in the video frame. If so, the video frame is parsed to obtain the configuration information of the particle call. The configuration information is compiled and combined with the pre-built irregular canvas coordinate system to calculate the pixels corresponding to the configuration information, and an association relationship between the pixel and the corresponding particle is established. Finally, all the identified particles are formed into a particle set, and the pixels corresponding to each particle are formed into a pixel data set.
[0062] 203. Extracting the three primary color data values of each pixel in the pixel data set, and calculating the transparency of the particle according to the three primary color values;
[0063] In this embodiment, the pixels in the pixel data set include resolution information and the values of the three primary colors, which are red, green, and blue. The specific display color of the pixel point is adjusted by the specific values of the three primary colors, that is, the display color of the particle. The transparency of the particle is calculated based on the display configuration of the particle set according to the values of the three primary colors.
[0064] 204. Add transparency to the pixel to generate pixel information corresponding to each particle;
[0065] In this embodiment, transparency is added to the pixel and forms an element set with the values of the three primary colors in the pixel. The element set is represented by (R, G, B, A), where RGB represents the values of the three primary colors and A represents the value of transparency.
[0066] 205. Calculate the coordinate information of each particle based on the pixel information and the coordinate system constructed based on the irregular canvas;
[0067] In this step, the first step is to construct the vertical and horizontal axes in the coordinate system based on the irregular canvas. Specifically, the tangent of the irregular canvas outline is determined, and two mutually perpendicular tangents are selected as the vertical and horizontal axes respectively. Then, the minimum and maximum pixel values are selected from the pixel information of all particles to calculate the difference. The difference is divided into equal parts and the spacing values of the coordinate axes are obtained, thus forming a coordinate system.
[0068] 206. Constructing a particle matrix based on the coordinate information of each particle and the color of each particle;
[0069] In this step, specifically, the particle display map outline is constructed according to the irregular canvas;
[0070] According to the coordinate information, all particles are marked in the display map outline in turn to form a particle map prototype;
[0071] According to the three primary color values and transparency of each particle, the punctuation points in the particle map prototype are rendered in color and the corresponding transparency is set to form a complete particle map;
[0072] By using a binary conversion algorithm, the punctuation points in the complete particle map with a transparency greater than a preset value are converted into non-null values, and the punctuation points in the complete particle map with a transparency less than a preset value are converted into null values, thereby obtaining a particle matrix.
[0073] Furthermore, after color rendering of the punctuation points in the particle map prototype, the method further includes:
[0074] Mark the rendered punctuation marks with colors, and adjust the punctuation marks with the same marks to be displayed adjacently;
[0075] Establish color associations between punctuation marks with the same mark;
[0076] Then, set the transparency of the adjusted punctuation.
[0077] 207. Identify particles with adjacent coordinate information and the same color in the particle matrix, and perform scaling processing on the identified particles to obtain a scaling matrix;
[0078] 208. Perform a display trajectory conversion process on the particles in the scaling matrix to generate animation images corresponding to all particles.
[0079] Through the implementation of the above method, the particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain the scaling matrix. Based on the scaling matrix, a single point call of the particle is made and the display trajectory is captured to generate an animated picture. The graphics are converted into a two-dimensional array and run in a non-transparent area. This achieves the goal of making regular particles run randomly only within the effective range, simplifies the complex implementation process of the existing particle animation generation technology, and improves the smoothness of the animation picture.
[0080] See also Figure 3 The third embodiment of the particle animation implementation method in the embodiment of the present invention includes:
[0081] 301. Get pixel information of all particles in the current irregular canvas;
[0082] 302. Calculate the coordinate information of each particle based on the pixel information and the coordinate system constructed based on the irregular canvas;
[0083] In this step, the vertical and horizontal axes are determined based on the outline of the irregular canvas, and the minimum and maximum pixel values are screened out from all particles. The distribution values of the vertical and horizontal axes are determined based on the minimum and maximum pixel values to obtain a coordinate system. According to the coordinate system and the pixel information of each particle, the coordinate value of each particle in the coordinate system is calculated to obtain the coordinate information of each particle.
[0084] 303. Constructing a particle matrix based on coordinate information;
[0085] In this embodiment, a virtual model construction algorithm is used to identify the boundary lines in the irregular canvas, and an identical outline is constructed based on the boundary lines through model construction. Based on the outline, a display map outline is obtained, and then particles are added to the display map outline. Specifically, points are marked in the display map outline according to the coordinate information of each particle to obtain a prototype of the particle map.
[0086] Furthermore, according to the three colors and transparency calculated in the above steps, the display parameters of the particles in the particle map prototype are set to obtain a complete particle map. In practical applications, the complete particle map can actually be understood as an irregular matrix with punctuation points, and the irregular matrix is a matrix with unequal numbers of elements in each row.
[0087] Then, by setting a recognizable threshold of transparency, the particles in the complete particle map are converted into digital signals using a digital signal conversion method. Preferably, the digital signal is a binary value. In practical applications, when the transparency of the identified particle is greater than the recognizable threshold, the binary value of the particle is determined to be 1, otherwise it is 0. After all identifications are completed, a particle matrix is formed.
[0088] 304. Set matrix coordinates for each non-null value in the particle matrix to obtain a coordinate matrix;
[0089] In this step, when setting the matrix coordinates, the total number of rows and columns in the matrix is used as the maximum coordinate value of the element, and the vertical and horizontal coordinate values of the row and column where each element is located are used respectively to obtain the coordinate information of the element.
[0090] 305. Calculate the scaled coordinate value of each matrix coordinate in the coordinate matrix according to a preset scale ratio;
[0091] Specifically, the scaled coordinate value is obtained by dividing the vertical and horizontal coordinate values in the coordinate by the scaling ratio.
[0092] 306. Rounding the scaled coordinate value to obtain an integer scaled coordinate value;
[0093] 307. Merge the coordinate values with the same vertical and horizontal coordinates in the integer scaling coordinate values to obtain a scaling matrix;
[0094] In practical applications, the rounding process specifically involves removing the decimal point in the scaled coordinate value to obtain the integer of the coordinate, and then merging the same coordinates in the coordinates after the integer to obtain a new coordinate value, thereby forming a scaling matrix.
[0095] 308. Perform a single-point call on each particle in the scaling matrix, and use optical principles to collect the position of the particle in the irregularly positioned canvas after the call is displayed and the flickering light sensitivity;
[0096] 309. After all particles in the scaling matrix are called, the dynamic trajectory of the particles is generated according to the recorded positions and light sensitivities;
[0097] 310. Analyze the available easing animation functions in dynamic tracks;
[0098] 311. Set the pixel points outside the dynamic track in the irregular canvas to a black background, and render the dynamic track based on the easing animation function to obtain the animation picture of the particles.
[0099] In this embodiment, the animation rendering of the dynamic trajectory based on the easing animation function to obtain the animation picture of the particle includes:
[0100] Extracting the starting point, the ending point and the duration of the dynamic trajectory;
[0101] The starting point, end point and duration of the particle are determined by using the easing animation function in the Tween algorithm to form an animation picture of the particle.
[0102] The following is a detailed explanation of the above method with the help of specific examples:
[0103] First, the first matrix is generated based on the particles to be displayed in the irregular canvas, which is the complete particle map mentioned above;
[0104] The complete particle map is then converted into a particle matrix;
[0105] In practical applications, the specific construction method of converting the first matrix into a particle matrix is to use the characteristics of A in PNG's RGBA to make the conversion. A=0 (i.e. transparent color) is 0, and A>0 is 1. In this way, "matrix two" can be converted. Specifically, Figure 4 and 5 As shown, Note: RGBA represents the three primary colors and transparency, where A is a decimal with a transparency range of [0, 1].
[0106] Furthermore, the above matrix 2 is adjusted and scaled by a scaling algorithm to obtain a matrix 3, as shown in Figure 6 shown.
[0107] Furthermore, when the animation is executed, the zoom is performed by the actual point. The corresponding relationship is shown in Figure 7 and 8 , please refer to the color markings in the figure for details. The same colors in the figure represent corresponding relationships, and * in the figure represents pixel points.
[0108] Depend on Figure 7 and 8 The winning bid is P(4,0)=P`(8,0),P`(9,0),P`(8,1),P`(9,1)
[0109] Note: P stands for "Matrix Four" and P` stands for coordinate matrix, where the numbers in brackets represent the matrix subscript and image coordinates respectively.
[0110] Therefore we need a scaling algorithm, which is as follows:
[0111] 1) Get the scaling factor: Take s as an example:
[0112] s = (P width + P height) / (P width + P height) = 0.5
[0113] 2) The scaling algorithm is as follows
[0114] P(x, y) = P`(<x*s> ,<y*s> )
[0115] Note: <> means discarding the decimal point
[0116] Figure 8 The coordinate transformation "Matrix Four" subscript verification algorithm is as follows:
[0117] Red point comparison formula:
[0118] P`(<8*s>,<0*s>)=>P( <4> ,0)=>P(4,0)
[0119] P`(<9*s>,<0*s>)=>P(<4.5>,0)=>P(4,0)
[0120] P`(<8*s>,<1*s>)=>P(4,0)=>P(4,0)
[0121] P`(<9*s>,<1*s>)=>P(<4.5>,0)=>P(4,0)
[0122] Purple point comparison formula:
[0123] P`(<10*s>,<0*s>)=>P(5,0)=>P(5,0)
[0124] P`(<11*s>,<0*s>)=>P(<5.5>,0)=>P(5,0)
[0125] P`(<10*s>,<1*s>)=>P(5,0)=>P(5,0)
[0126] P`(<11*s>,<1*s>)=>P(<5.5>,0)=>P(5,0)
[0127] Yellow point comparison formula:
[0128] P`(<6*s>,<2*s>)=>P(3,1)=>P(3,1)
[0129] P`(<7*s>,<2*s>)=>P(<3.5>,1)=>P(3,1)
[0130] P`(<6*s>,<3*s>)=>P(3,<1.5>)=>P(3,1)
[0131] P`(<7*s>,<3*s>)=>P(<3.5>,<1.5>)=>P(3,1)
[0132] Green point comparison formula:
[0133] P`(<8*s>,<2*s>)=>P(4,1)=>P(4,1)
[0134] P`(<9*s>,<2*s>)=>P(<4.5>,1)=>P(4,1)
[0135] P`(<8*s>,<3*s>)=>P(4,<1.5>)=>P(4,1)
[0136] P`(<9*s>,<3*s>)=>P(<4.5>,<1.5>)=>P(4,1)
[0137] Blue point comparison formula:
[0138] P`(<8*s>,<4*s>)=>P(4,2)=>P(4,2)
[0139] P`(<9*s>,<4*s>)=>P(<4.5>,2)=>P(4,2)
[0140] P`(<8*s>,<5*s>)=>P(4,<2.5>)=>P(4,2)
[0141] P`(<9*s>,<5*s>)=>P(<4.5>,<2.5>)=>P(4,2)
[0142] As can be seen above, the compressed matrix subscript is completely hit.
[0143] Finally: After hijacking the coordinates of the flashing points randomly calculated by the particle animation, convert the coordinates into matrix subscripts and judge the coordinate values. If it is 1, the flashing animation will be executed, and if it is 0, it will not be executed and the coordinates will be retrieved.
[0144] Through the particle animation implementation solution provided above, the scattered particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain a scaling matrix. Based on the scaling matrix, a single point call of the particle is made and the display trajectory is captured to generate an animated picture. The improvement greatly saves working time. The unified algorithm processing method used for all provincial and municipal maps achieves standardization, easy implementation and low cost.
[0145] The particle animation implementation method in the embodiment of the present invention is described above. The particle animation implementation device in the embodiment of the present invention is described below. Please refer to Figure 9 An embodiment of the particle animation implementation device in the embodiment of the present invention includes:
[0146] An acquisition module 901 is used to acquire pixel information of all particles in the current irregular canvas;
[0147] A coordinate construction module 902 is configured to determine the ordinate and abscissa axes based on the outline of the irregular canvas, select the minimum and maximum pixel values from all particles, and determine the distribution values of the ordinate and abscissa axes based on the minimum and maximum pixel values to obtain a coordinate system;
[0148] A calculation module 903 is used to calculate the coordinate information of each particle based on the pixel information and the coordinate system constructed based on the irregular canvas;
[0149] A matrix construction module 904 is used to construct a particle matrix based on the coordinate information;
[0150] A scaling module 905 is used to identify particles in the particle matrix that have the same pixel parameters and a correlation between their serial numbers, and scale the identified particle matrix using a matrix scaling algorithm to obtain a scaling matrix;
[0151] The generating module 906 is used to generate an animation picture of the particles according to the scaling matrix by calculating the captured display trajectory.
[0152] In an embodiment of the present invention, particles are classified and integrated through matrix conversion, and then the matrix is scaled to obtain a scaling matrix. Based on the scaling matrix, a single-point call of the particle is performed to capture the display trajectory to generate an animation screen, and the graphics are converted into a two-dimensional array and run in a non-transparent area. This realizes the production of regular random running of particles only within the effective range, simplifies the complex implementation process of the existing particle animation generation technology, and also improves the smoothness of the animation screen.
[0153] See also Figure 10 Another embodiment of the particle animation implementation device in the embodiment of the present invention includes:
[0154] 901 is an acquisition module, configured to acquire pixel information of all particles in the current irregular canvas, wherein the pixel information includes pixel value and color;
[0155] 902 coordinate construction module, for determining a vertical axis and a horizontal axis based on the outline of the irregular canvas, screening out minimum and maximum pixel values from all particles, and determining distribution values of the vertical axis and the horizontal axis based on the minimum and maximum pixel values to obtain a coordinate system;
[0156] 903 calculation module, used to calculate the coordinate value of each particle in the coordinate system according to the coordinate system and the pixel information of each particle, and obtain the coordinate information of each particle;
[0157] 904 matrix construction module, used to construct a particle matrix based on the coordinate information of each particle and the color of each particle;
[0158] 905 scaling module, used to identify particles with adjacent coordinate information and the same color in the particle matrix, and perform scaling processing on the identified particles to obtain a scaling matrix;
[0159] 906 is a generation module, which is used to convert the particles in the scaling matrix into display trajectories and generate animation images corresponding to all particles.
[0160] In this embodiment, the acquisition module 901 is specifically configured to:
[0161] Extract the video frames in the current irregular canvas using a video cropping algorithm;
[0162] Identifying configuration information of particles in the video frame, and extracting pixels in the configuration information to generate a particle set and a pixel data set;
[0163] Extracting three primary color data values of each pixel in the pixel data set, and calculating the transparency of the particle according to the three primary color values;
[0164] The transparency is added to the pixels to generate pixel information corresponding to each particle.
[0165] In this embodiment, the matrix construction module 904 includes:
[0166] An outline construction unit 9041 is used to construct a particle display map outline based on the irregular canvas;
[0167] The marking unit 9042 is used to mark all particles in the displayed map outline in sequence according to the coordinate information to form a particle map prototype;
[0168] The map generation unit 9043 is used to color the punctuation points in the particle map prototype according to the three primary color values and transparency of each particle, and set the corresponding transparency to form a complete particle map;
[0169] The matrix construction unit 9044 is used to convert the punctuation points in the complete particle map whose transparency is greater than the preset value into non-null values, and convert the punctuation points in the complete particle map whose transparency is less than the preset value into null values using a binary conversion algorithm to obtain a particle matrix.
[0170] In this embodiment, the matrix construction unit 9044 is further configured to: color-mark the rendered punctuation marks, and adjust punctuation marks with the same mark to be displayed adjacently; and establish color association relationships between punctuation marks with the same mark.
[0171] In this embodiment, the scaling module 905 includes:
[0172] A setting unit 9051 is used to set matrix coordinates for each non-null value in the particle matrix to obtain a coordinate matrix;
[0173] a scaling unit 9052, configured to calculate a scaled coordinate value of each matrix coordinate in the coordinate matrix according to a preset scaling ratio;
[0174] a rounding unit 9053, configured to round the scaled coordinate value to an integer to obtain a scaled coordinate value;
[0175] The merging unit 9054 is configured to merge coordinate values with the same vertical and horizontal coordinates in the integer scaling coordinate values to obtain a scaling matrix.
[0176] In this embodiment, the generating module 906 includes:
[0177] The display unit 9061 is used to perform a single-point call on each particle in the scaling matrix, and to collect the position of the particle in the irregular canvas and the flickering light sensitivity after the call is displayed using optical principles;
[0178] A recording unit 9062 is configured to generate dynamic trajectories of particles according to the recorded positions and light sensitivities after all particles in the scaling matrix have been called;
[0179] An analysis unit 9063 is used to analyze available easing animation functions in the dynamic trajectory;
[0180] The rendering unit 9064 is configured to set the pixel points outside the dynamic track in the irregular canvas to a black background, and perform animation rendering on the dynamic track based on the slow-motion animation function to obtain an animation picture of the particles.
[0181] In this embodiment, the generating module 906 includes:
[0182] An extraction unit 9065 is configured to extract a starting point, an end point, and a duration of the dynamic trajectory;
[0183] The picture generating unit 9066 is used to use the slow-motion animation function in the Tween algorithm to determine the starting point, end point and duration of the particle to form an animation picture of the particle.
[0184] See also Figure 11 , the following describes in detail an embodiment of the particle animation implementation device in an embodiment of the present invention from the perspective of hardware processing.
[0185] Figure 11FIG1 is a schematic diagram of the structure of a particle animation implementation device provided by an embodiment of the present invention. The particle animation implementation device 1100 may vary significantly depending on configuration or performance. It may include one or more central processing units (CPUs) 1110 (e.g., one or more processors), memory 1120, and one or more storage media 1130 (e.g., one or more mass storage devices) storing application programs 1133 or data 1132. The memory 1120 and storage medium 1130 may be either transient or persistent storage. The program stored in the storage medium 1130 may include one or more modules (not shown), each of which may include a series of instruction operations for the routing-based user demand prediction device 1100. Furthermore, the processor 1110 may be configured to communicate with the storage medium 1130 to execute the series of instruction operations stored in the storage medium 1130 on the particle animation implementation device 1100.
[0186] The particle animation implementation device 1100 may further include one or more power supplies 1140, one or more wired or wireless network interfaces 1150, one or more input and output interfaces 1160, and / or one or more operating systems 1131, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be understood by those skilled in the art that Figure 11 The structure of the particle animation implementation device shown does not constitute a limitation on the particle animation implementation device, and the device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0187] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains a batch of information used to verify its validity (for anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0188] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions, which, when executed on a computer, cause the computer to execute the steps of the particle animation implementation method.
[0189] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0190] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc., various media that can store program code.
[0191] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A particle animation implementation method, characterized in that: The particle animation implementation method includes: Obtain pixel information of all particles in the current irregular canvas, wherein the pixel information includes pixel value and color; Determining a vertical axis and a horizontal axis based on the outline of the irregular canvas, screening out minimum and maximum pixel values from all particles, and determining distribution values of the vertical axis and the horizontal axis based on the minimum and maximum pixel values to obtain a coordinate system; Calculating the coordinate value of each particle in the coordinate system according to the coordinate system and the pixel information of each particle to obtain the coordinate information of each particle; constructing a particle matrix based on the coordinate information of each particle and the color of each particle; Identifying particles with adjacent coordinate information and the same color in the particle matrix, and performing scaling processing on the identified particles to obtain a scaling matrix; Performing a display trajectory conversion process on the particles in the scaling matrix to generate animation images corresponding to all particles; The method of obtaining pixel information of all particles in the current irregular canvas includes: Extract the video frames in the current irregular canvas using a video cropping algorithm; By recording particles in a video frame, it is identified whether there are particles in the video frame. If so, the video frame is parsed to obtain configuration information for the particle call. The configuration information is compiled and combined with a pre-built irregular canvas coordinate system to calculate the pixels corresponding to the configuration information, and an association relationship between the pixels and the corresponding particles is established. Finally, all identified particles are formed into a particle set, and the pixels corresponding to each particle are formed into a pixel data set. The three primary color values of each pixel in the pixel data set are extracted, and the transparency of the particle is calculated based on the three primary color values. Adding the transparency to the pixels to generate pixel information corresponding to each particle; The step of converting the display trajectories of the particles in the scaling matrix to generate animation images corresponding to all particles includes: Performing a single-point call on each particle in the scaling matrix, and using optical principles to collect the position of the particle in the irregular canvas and the flickering light sensitivity after the call is displayed; after all particles in the scaling matrix are called, generating a dynamic trajectory of the particle based on the recorded position and light sensitivity; Analyzing available easing animation functions in the dynamic trajectory; The pixel points outside the dynamic track in the irregular canvas are set to a black background, and the dynamic track is animated based on the slow-motion animation function to obtain an animated picture of the particle.
2. The particle animation implementation method according to claim 1, characterized in that: The step of constructing a particle matrix based on the coordinate information of each particle and the color of each particle includes: constructing a particle display map outline according to the irregular canvas; According to the coordinate information, all particles are marked in the display map outline in turn to form a particle map prototype; According to the three primary color values and transparency of each particle, the punctuation points in the particle map prototype are rendered in color and the corresponding transparency is set to form a complete particle map; By using a binary conversion algorithm, the punctuation points in the complete particle map with a transparency greater than a preset value are converted into non-null values, and the punctuation points in the complete particle map with a transparency less than a preset value are converted into null values, thereby obtaining a particle matrix.
3. The particle animation implementation method according to claim 2, characterized in that: After color rendering the punctuation points in the particle map prototype according to the three primary color values and transparency of each particle, and before setting the corresponding transparency to form a complete particle map, the method further includes: The rendered punctuation marks are color-coded, and the punctuation marks with the same mark are adjusted to be displayed adjacently; and a color association relationship is established between the punctuation marks with the same mark.
4. The particle animation implementation method according to claim 2, characterized in that: The scaling process of the identified particles to obtain a scaling matrix includes: Setting matrix coordinates for each non-null value in the particle matrix to obtain a coordinate matrix; Calculating the scaled coordinate value of each matrix coordinate in the coordinate matrix according to a preset scale ratio; Rounding the scaled coordinate value to obtain an integer scaled coordinate value; The coordinate values with the same vertical and horizontal coordinates in the integer scaling coordinate values are merged to obtain a scaling matrix.
5. The particle animation implementation method according to claim 1, characterized in that: The step of rendering the dynamic trajectory based on the slow-motion animation function to obtain an animation picture of the particle includes: Extracting the starting point, the end point and the duration of the dynamic trajectory; and using the easing animation function in the Tween algorithm to formulate the starting point, the end point and the duration of the particle to form an animation picture of the particle.
6. A particle animation realization device, characterized in that: The particle animation implementation device comprises: An acquisition module, configured to acquire pixel information of all particles in the current irregular canvas, wherein the pixel information includes pixel value and color; a coordinate construction module for determining a vertical axis and a horizontal axis based on the outline of the irregular canvas, screening out minimum and maximum pixel values from all particles, and determining distribution values of the vertical axis and the horizontal axis based on the minimum and maximum pixel values to obtain a coordinate system; a calculation module for calculating the coordinate value of each particle in the coordinate system based on the coordinate system and the pixel information of each particle to obtain the coordinate information of each particle; A matrix construction module, configured to construct a particle matrix based on the coordinate information of each particle and the color of each particle; a scaling module, configured to identify particles with adjacent coordinate information and the same color in the particle matrix, and to perform scaling processing on the identified particles to obtain a scaling matrix; A generation module, configured to convert the particles in the scaling matrix into display trajectories and generate animation images corresponding to all particles; The acquisition module is specifically configured to extract a video frame from the current irregular canvas using a video cropping algorithm; identify whether there are particles in the video frame by recording particles in the video frame; if so, parse the video frame to obtain configuration information for the particle call; compile the configuration information, calculate pixels corresponding to the configuration information in combination with a pre-built coordinate system of the irregular canvas, and establish an association relationship between the pixels and the corresponding particles; finally, form a particle set with all identified particles, and form a pixel data set with the pixels corresponding to each particle; extract the three primary color values of each pixel in the pixel data set, and calculate the transparency of the particle based on the three primary color values; add the transparency to the pixel to generate pixel information corresponding to each particle; The generation module includes: a display unit, which is used to perform a single-point call on each particle in the scaling matrix, and use optical principles to collect the position of the particle in the irregular canvas and the flickering light sensitivity after the call is displayed; a recording unit, which is used to generate a dynamic trajectory of the particle according to the recorded position and light sensitivity after all particles in the scaling matrix are called; an analysis unit, which is used to analyze the available slow-motion animation function in the dynamic trajectory; and a rendering unit, which is used to set the pixel points outside the dynamic trajectory in the irregular canvas to a black background, and to render the dynamic trajectory based on the slow-motion animation function to obtain an animated picture of the particle.
7. A particle animation implementation device, characterized in that: The particle animation implementation device includes: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the particle animation implementation device to execute the particle animation implementation method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the particle animation implementation method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Image compression method, image compression device and mobile terminal
CN102497489A
Particle animation implementation method
CN112184860A