A component displacement method, system, device and medium based on Bezier curve
Through the component displacement method combined with Bezier curve and drag gesture, the problem of single animation effects in iOS client development is solved, diversification of animation paths and manual adjustments are achieved, and the user experience and animation flexibility is improved.
Patent Information
- Application Number
- CN202411258956.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-10
AI Technical Summary
In iOS client development, component bit movement can only be performed independently and cannot be manually intervened, resulting in a single animation effect and cannot meet diversified needs in some application scenarios.
Through the component displacement method based on Bezier curve, combining drag gestures and timed frame animation, diversification and manual adjustment of animation paths are achieved, and the fixed-point array and the timer system of iOS system can achieve seamless switching between automatic and manual animations. .
It realizes the diversification of the Bizel curve animation trajectory effects, avoids the single limit of bit-moving art in iOS system, improves the user experience, and allows developers to customize the animation process.
Smart Images

Figure CN118781231B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of component displacement, and in particular to a component displacement method, system, device and medium based on Bezier curve. Background Art
[0002] At present, the common component displacement animation method in iOS client development has a relatively simple motion trajectory, which often exists in the form of straight lines, circles, etc. limited by the iOS system itself. In the face of the current client development pursuing increasingly diverse animation effects, it is becoming more and more monotonous.
[0003] Although the existing implementation scheme can achieve animation effects by importing Bezier curves through keyframe animation, this kind of animation is completely automatic and only completes the displacement animation effect within a limited time. It is impossible to affect the animation movement process through manual intervention, which is very limited in some application scenarios. Therefore, there is still a lack of a component displacement implementation strategy that can achieve the Bezier curve animation trajectory effect, realize the diversification of animation paths, circumvent the limitation of the single displacement animation implementation effect of the iOS system itself, and can also achieve manual adjustment of the animation process effect based on the Bezier curve animation path. Summary of the invention
[0004] The present invention provides a component displacement method, system, device and medium based on Bezier curve, which are used to solve the technical problem that component displacement can only be automatically animated and cannot be manually intervened during iOS client development.
[0005] The purpose of the present invention is to propose a solution that allows users to achieve the Bezier curve animation trajectory effect, realize the diversification of animation paths, and avoid the limitation of the single displacement animation effect of the iOS system itself; based on the Bezier curve animation path, the animation process effect can be manually adjusted, which is convenient for users to manually manage on the basis of automatic displacement of components; and by dragging the start and end states of the gesture UIPanGestureRecognizer, the start and end timing of the automatic running of the animation can be determined, so as to achieve seamless connection between manual and automatic switching. The specific content of the present invention is described in detail below.
[0006] On the one hand, the present invention provides a component displacement method based on Bezier curves, the method comprising the following steps: step S1: creating a Bezier curve path and a target component to be animated, and converting the object corresponding to the Bezier curve path into a fixed-point array; step S2: creating a drag gesture and a timed frame animation for the target component, so that the target component is autonomously animated along the Bezier curve path; step S3: upon receiving a drag gesture instruction, stopping the autonomous animation and starting to execute the drag gesture operation; step S4: monitoring whether the drag gesture continues, and if so, obtaining the landing point coordinates of the target component and the minimum value of each coordinate in the fixed-point array, and obtaining the corresponding fixed-point coordinate A, and correcting the target component to the fixed-point coordinate A.
[0007] In one implementation of the present invention, the method also includes: placing the center point of the target component at the starting position of the Bezier curve path; using the built-in timer system of the iOS system to add a timed frame animation to the target component, and adjusting the center position of the target component to the next data of the fixed-point array in each frame to achieve automatic playback of the animation.
[0008] In one implementation of the present invention, the step S3 is specifically as follows: determining that the drag gesture operation is in a start state; using the clear attribute of the timer system to stop the frame animation of the target component and set the frame animation to zero; executing the drag gesture operation to change the animation process of the target component.
[0009] In one implementation of the present invention, in step S4, the process of obtaining the corresponding fixed-point coordinate A is specifically as follows: obtaining the first distance difference between the first fixed-point coordinate in the fixed-point array and the landing point coordinate, defaulting the current fixed-point coordinate to the target fixed-point coordinate, and the current first distance difference to the minimum distance; determining whether there is any data in the fixed-point array, if not, determining that the current target fixed-point coordinate is the fixed-point coordinate A and remains unchanged; if so, calculating the second distance difference between the next fixed-point coordinate and the landing point coordinate through the hypot function; determining whether the second distance difference is less than the minimum distance, if so, setting the current fixed-point coordinate to the fixed-point coordinate A.
[0010] In an implementation of the present invention, the method further includes: if the second distance difference is greater than the minimum distance, repeating the step of determining whether there is any data in the fixed-point array.
[0011] In an implementation of the present invention, the method further includes: after setting the current fixed-point coordinates as fixed-point coordinates A, replacing the second distance difference with the minimum distance.
[0012] In one implementation of the present invention, the method also includes: after correcting the target component to the fixed-point coordinate A, using the built-in timer system of the iOS system to add a timed frame animation; adjusting the center position of the target component to the next data of the fixed-point array to achieve the animation switching from the drag gesture operation to automatic operation.
[0013] Secondly, the present invention also provides a component displacement system based on Bezier curves, the system comprising: a first creation module, used to create a Bezier curve path and a target component to be animated, and convert the object corresponding to the Bezier curve path into a fixed-point array; a second creation module, used to create a drag gesture and a timed frame animation for the target component, so that the target component can autonomously animate along the Bezier curve path; a stop module, used to stop the autonomous animation and start executing the drag gesture operation when a drag gesture instruction is received; a drag execution module, used to monitor whether the drag gesture continues, and if so, obtain the landing point coordinates of the target component and the minimum value of each coordinate in the fixed-point array, and obtain the corresponding fixed-point coordinate A, and correct the target component to the fixed-point coordinate A.
[0014] Secondly, the present invention also provides a component displacement device based on Bezier curves, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can complete the aforementioned component displacement method based on Bezier curves.
[0015] Finally, the present invention also provides a non-volatile computer storage medium for component displacement based on Bezier curves, which stores computer executable instructions. The computer executable instructions are executed by a processor to implement the aforementioned component displacement method based on Bezier curves.
[0016] The component displacement method based on Bezier curve provided by the present invention has the following beneficial effects:
[0017] (1) It can achieve seamless connection between automatic animation and manual dragging, which not only effectively avoids the disadvantage of the relatively single displacement animation behavior mode of traditional iOS client components, but also meets the needs of manual control of the animation process, thus improving the user experience;
[0018] (2) More solutions can be developed for the interactivity of Bezier curves. Developers can customize the development of Bezier curve operations based on this solution.
[0019] (3) By polling the absolute distance difference between each fixed point in the fixed point array and the landing point, the corresponding position of the target component on the Bezier curve trajectory is located to complete the automatic correction of the coordinate point. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0021] Figure 1 A flow chart of a component displacement method based on Bezier curve provided in an embodiment of the present invention;
[0022] Figure 2 A flow chart for obtaining fixed point coordinates A provided in an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of automatic animation operation provided by an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of manual dragging operation provided by an embodiment of the present invention;
[0025] Figure 5 A component displacement system composition diagram based on Bezier curves provided by an embodiment of the present invention;
[0026] Figure 6 A schematic diagram of a component displacement device based on a Bezier curve provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0028] The embodiment of the present invention provides a component displacement method, system, device and medium based on Bezier curve, adopts a solution of obtaining fixed points along the Bezier curve path, converts the entire displacement path into a set of fixed points, and completes the automatic processing of the component and the manual intervention effect through the fixed point array. The detailed flow chart is shown in Figure 1 The following is a detailed description of the technical solution proposed in the embodiment of the present invention through the accompanying drawings. The method mainly includes the following steps:
[0029] Step S1: Create a Bezier curve path and a target component to be animated, and convert the object corresponding to the Bezier curve path into a fixed-point array.
[0030] In an embodiment of the present invention, during the production process, developers will often encounter a requirement to display a set of interactive components to users. In order to attract the user's attention, the target component will usually exist in the form of additional animation, and the animation effect is relatively complex; and in order to facilitate the user's independent viewing, a drag gesture operation will be added to the target component, and manual operation can be seamlessly connected with automatic animation.
[0031] To achieve the above requirements, add a Bezier curve path. This path is different from ordinary straight lines, circles and other trajectories. You can control the curve path by adding starting points and passing nodes to generate a complex path that meets expectations and generate the corresponding Bezier curve path object.
[0032] Furthermore, the Bezier curve path object is converted into a fixed-point array, including the starting point, node part, line segment part, etc., all in fixed-point form, and extracted into a data array. The larger the array data volume, the denser the fixed points, and the higher the accuracy of the animation realized later.
[0033] Step S2: creating a drag gesture and a timed frame animation for the target component, so that the target component is autonomously animated along the Bezier curve path.
[0034] In the embodiment of the present invention, taking a terminal device supporting the iOS system as an example, the horizontal resolution of the screen is 375. Due to its ultra-high-definition screen characteristics, 1 pixel occupies two points, that is, the number of horizontal points on the screen of the terminal device of the iOS system is 700. To ensure the smoothness of the animation transition, a fixed-point array generated by a Bezier curve path spanning the full screen should contain at least 700 data. If the amount of data is too small, each displacement will span multiple points, resulting in an unsmooth animation.
[0035] Create the target component to which you want to add animation, add a drag gesture, and place the center point of the target component at the starting position of the Bezier curve. Use the built-in timer system of the iOS system to add a timed frame animation to the target component. Each frame adjusts the center position of the target component to the next data of the fixed-point array to achieve automatic animation playback. It should be noted that this timer system is synchronized with the screen refresh frequency and has high accuracy, and is often used to achieve frame animation effects.
[0036] Step S3: When receiving the drag gesture instruction, stop the autonomous animation and start executing the drag gesture operation.
[0037] In an embodiment of the present invention, when manual operation needs to be performed, the user can directly operate the target component in the form of dragging. When it is determined that the state of the drag gesture is in the start state of the drag gesture operation, the invalidate clear attribute of the CADisplayLink object of the iOS timer system is used (the invalidate attribute is the attribute of the CADisplayLink object itself, which is used to clear the CADisplayLink timer), stop the frame animation, and set the frame animation to an empty state. The current target component is no longer controlled by the frame animation, and the manual change of the animation process operation is started.
[0038] Step S4: monitor whether the drag gesture continues, if so, obtain the minimum value of the landing point coordinates of the target component and each coordinate in the fixed-point array, obtain the corresponding fixed-point coordinate A, and correct the target component to the fixed-point coordinate A.
[0039] In the embodiment of the present invention, the process of obtaining the fixed point coordinate A is as follows: Figure 2 As shown, the displacement data after each drag is obtained through the drag gesture, and the specific coordinate point of the landing point on the current page is calculated through the displacement.
[0040] The first fixed-point coordinate of the array, which is the target fixed-point coordinate A by default, and the current landing point are passed through the hypot function. The function formula is: d= , calculate the Euclidean distance between two points in the plane coordinate system, and perform absolute value processing through the abs function to obtain the current first distance difference, which is the minimum distance by default. It should be noted that the current default minimum distance is used as the minimum distance identifier during data polling to obtain the corresponding minimum distance in the array.
[0041] Further, determine whether there is a next fixed-point coordinate in the array. If so, continue to calculate the absolute distance difference to obtain the second distance difference between the current fixed point and the landing point. It should be noted that during the array polling process, the absolute distance difference between each fixed point and the landing point is obtained. The purpose is to compare it with the minimum distance data below to obtain the corresponding minimum value in the array; determine whether the second distance difference is less than the minimum distance. If so, set the current fixed-point coordinate to the target fixed-point coordinate A, and set the second distance difference to the minimum distance. If not, continue to repeat the above steps until there is no next fixed-point coordinate data in the array.
[0042] In the embodiment of the present invention, taking the fixed-point array [(0, 0), (0, 1), (1, 1)] and the current landing point position (0, 0) as an example, the fixed-point array is traversed, and the distance difference between the landing point position coordinates and the fixed-point coordinates is calculated one by one. The calculation results are 0, 1, , the minimum absolute distance difference between the current landing point coordinates and the fixed point coordinates can be obtained to be 0, and the corresponding fixed point coordinate A is (0, 0). The fixed point coordinate A obtained in the above process is the coordinate A closest to the landing point on the Bezier curve path, and the center position of the target component is adjusted to the corresponding fixed point coordinate A to implement the manual drag process operation. In this way, the target component will automatically correct its position along the created Bezier curve path during a drag gesture.
[0043] Furthermore, after all the data in the fixed-point array are traversed, the minimum value of the absolute distance difference between the landing point coordinates and the fixed-point coordinates can be obtained through comparative calculation, and the fixed-point coordinate A can be located.
[0044] After the drag gesture is completed, the iOS timer system CADisplayLink is used again to add a timed frame animation, and the center position of the target component is adjusted to the next data of the fixed-point array, so that the animation can be seamlessly switched from manual operation to automatic operation.
[0045] In the embodiment of the present invention, Figure 3 As shown, during the automatic animation stage, the target component will be extracted into a data array along the Bezier curve for fixed-point movement. In the first frame, it will move from point P1 to point P2, and in the second frame, it will move from point P2 to point P3, and so on, until it finally reaches point Pn, completing the entire Bezier curve path.
[0046] like Figure 4 As shown, when manually dragging, each drag will leave a drop point coordinate C1 on the page, and then traverse the array [P1, P2...Pn] to obtain the fixed point coordinate A that is closest to the drop point coordinate C1, which is P6 in the current figure. Set the center of the target component to the P6 position to realize the manual dragging process operation of the target component along the Bezier curve path.
[0047] In another embodiment of the present invention, a new behavior mode can be tried. Instead of converting the Bezier curve path into a fixed-point array, a new calculation method is designed. At each frame animation node or manually dragged node, it is determined whether the landing point is on the Bezier curve. If it is, it means that the target component is still running on the Bezier curve path. If not, the landing point is diverged to the adjacent coordinate position in a polling manner until a certain divergent point is on the Bezier curve. The center point of the target component is placed at the current divergent point, that is, the target component position is corrected to the Bezier curve path. If this solution is adopted, the displacement of the target component along the predetermined trajectory and autonomous animation can still be achieved.
[0048] The above is a component displacement method based on a Bezier curve provided by an embodiment of the present invention. Based on the same inventive concept, an embodiment of the present invention also provides a component displacement system based on a Bezier curve. Figure 5 A component displacement system composition diagram based on a Bezier curve provided by an embodiment of the present invention, such as Figure 5 As shown, the system mainly includes: a first creation module 501, which is used to create a Bezier curve path and a target component to be animated, and convert the object corresponding to the Bezier curve path into a fixed-point array; a second creation module 502, which is used to create a drag gesture and a timed frame animation for the target component, so that the target component can be autonomously animated along the Bezier curve path; a stop module 503, which is used to stop the autonomous animation and start the drag gesture operation when a drag gesture instruction is received; a drag execution module 504, which is used to monitor whether the drag gesture continues, and if so, obtain the landing point coordinates of the target component and the minimum value of each coordinate in the fixed-point array, and obtain the corresponding fixed-point coordinate A, and correct the target component to the fixed-point coordinate A.
[0049] The above is a component displacement system based on a Bezier curve provided by an embodiment of the present invention. Based on the same inventive concept, an embodiment of the present invention also provides a component displacement device based on a Bezier curve. Figure 6 A schematic diagram of a component displacement device based on a Bezier curve provided in an embodiment of the present invention, such as Figure 6 As shown, the device mainly includes: at least one processor 601; and a memory 602 that is communicatively connected to the at least one processor; wherein the memory 602 stores instructions that can be executed by the at least one processor 601, and the instructions are executed by the at least one processor 601 so that the at least one processor 601 can complete the aforementioned component displacement method based on Bezier curve.
[0050] In addition, an embodiment of the present invention further provides a non-volatile computer storage medium for component displacement based on Bezier curves, which stores computer executable instructions. The computer executable instructions are executed by a processor to implement the aforementioned component displacement method based on Bezier curves.
[0051] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0052] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0053] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0054] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0055] The various embodiments of the present invention are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0056] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0057] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A component displacement method based on Bezier curve, characterized in that: The method comprises the following steps: Step S1: Create a Bezier curve path and a target component to be animated, and convert the object corresponding to the Bezier curve path into a fixed-point array; Step S2: creating a drag gesture and a timed frame animation for the target component, so that the target component is autonomously animated along the Bezier curve path; Step S3: upon receiving the drag gesture instruction, stop the autonomous animation and start executing the drag gesture operation; Step S4: monitor whether the drag gesture continues, if so, obtain the minimum value of the landing point coordinates of the target component and each coordinate in the fixed-point array, and obtain the corresponding fixed-point coordinate A, and correct the target component to the fixed-point coordinate A; the process of obtaining the corresponding fixed-point coordinate A is specifically as follows: obtain the first distance difference between the first fixed-point coordinate and the landing point coordinate in the fixed-point array, and default the current fixed-point coordinate to the target fixed-point coordinate, and the current first distance difference is the minimum distance; determine whether there is any data in the fixed-point array, if not, determine that the current target fixed-point coordinate is fixed-point coordinate A and remains unchanged; if so, calculate the second distance difference between the next fixed-point coordinate and the landing point coordinate through the hypot function; determine whether the second distance difference is less than the minimum distance, if so, set the current fixed-point coordinate to fixed-point coordinate A.
2. A component displacement method based on Bezier curve according to claim 1, characterized in that: The method further comprises: Placing the center point of the target component at the starting position of the Bezier curve path; The built-in timer system of the iOS system is used to add a time frame animation to the target component. The center position of the target component is adjusted to the next data of the fixed-point array in each frame to realize automatic playback of the animation.
3. A component displacement method based on Bezier curve according to claim 2, characterized in that: The step S3 is specifically: Determine whether the drag gesture operation is in the start state; Use the clear property of the timer system to stop the frame animation of the target component and set the frame animation to zero; Execute a drag gesture operation to change the animation process of the target component.
4. The component displacement method based on Bezier curve according to claim 1, characterized in that: The method further comprises: If the second distance difference is greater than the minimum distance, the step of determining whether there is any data in the fixed-point array is repeated.
5. The component displacement method based on Bezier curve according to claim 1, characterized in that: The method further comprises: After setting the current fixed point coordinates as fixed point coordinates A, the second distance difference is replaced by the minimum distance.
6. A component displacement method based on Bezier curve according to any one of claims 1 or 2, characterized in that: The method further comprises: After the target component is corrected to the fixed point coordinate A, a time frame animation is added using the built-in timer system of the iOS system; The center position of the target component is adjusted to the next data of the fixed-point array, so that the animation is switched from the drag gesture operation to the automatic operation.
7. A component displacement system based on Bezier curve, characterized in that: The system comprises: A first creation module is used to create a Bezier curve path and a target component to be animated, and convert an object corresponding to the Bezier curve path into a fixed-point array; A second creation module is used to create a drag gesture and a timed frame animation for the target component, so that the target component is autonomously animated along the Bezier curve path; The stop module is used to stop the autonomous animation and start the drag gesture operation when receiving the drag gesture instruction; The drag execution module is used to monitor whether the drag gesture continues. If so, the minimum value of the landing point coordinates of the target component and each coordinate in the fixed-point array is obtained, and the corresponding fixed-point coordinate A is obtained, and the target component is corrected to the fixed-point coordinate A. The process of obtaining the corresponding fixed-point coordinate A is specifically as follows: obtaining the first distance difference between the first fixed-point coordinate and the landing point coordinate in the fixed-point array, and the current fixed-point coordinate is the target fixed-point coordinate by default, and the current first distance difference is the minimum distance; judging whether there is still data in the fixed-point array, if not, determining that the current target fixed-point coordinate is the fixed-point coordinate A and remains unchanged; if so, calculating the second distance difference between the next fixed-point coordinate and the landing point coordinate through the hypot function; judging whether the second distance difference is less than the minimum distance, if so, setting the current fixed-point coordinate to the fixed-point coordinate A.
8. A component displacement device based on Bezier curve, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can complete the component displacement method based on Bezier curve as described in any one of claims 1-6.
9. A non-volatile computer storage medium for component displacement based on Bezier curves, storing computer executable instructions, characterized in that: The computer executable instructions are executed by a processor to implement a component displacement method based on a Bezier curve as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Small program dragging element automatic alignment method and device, equipment and medium
CN110489041A
Radar-based curve drawing method and device, electronic equipment and storage medium
CN111986286A
