Pattern generation method, device, electronic device and storage medium
By building the target polygon and generating stripe patterns based on its path search, the problem of high efficiency and inefficient construction cost of decorative stripe effects in game development is solved, and efficient pattern production and development costs are achieved.
Patent Information
- Application Number
- CN202411835865.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-04
AI Technical Summary
In game development projects, drawing decorative stripe effects takes a lot of time and labor, resulting in inefficient cost.
By building the target polygon, extracting its center point and edge points, performing path search, obtaining the target path, and constructing a stripe pattern based on this path.
This method greatly accelerates the production process of stripe patterns, reduces game development costs, and improves the interactive experience of the game, allowing players to create corresponding stripe effects through simple adjustments.
Smart Images

Figure CN119762621A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graphics processing technology, and in particular to a pattern generating method, a pattern generating device, an electronic device and a computer-readable storage medium. Background Art
[0002] In games, decorative stripe effects can add visual appeal to game interfaces, characters, props, or environments. These stripes can be simple geometric patterns or complex textures that are used to enhance the art style and atmosphere of the game. In game development projects, drawing such patterns takes a lot of time and manpower, which can result in a lot of cost waste when such effects need to be generated in large quantities. Summary of the invention
[0003] The embodiments of the present invention provide a method, device, electronic device and computer-readable storage medium for generating a pattern, so as to solve or partially solve the problem of high construction cost and low efficiency of decorative stripe effects.
[0004] The embodiment of the present invention discloses a method for generating a pattern, comprising:
[0005] Constructing a target polygon, and extracting corresponding target center points and target edge points from the target polygon;
[0006] Performing a path search in the target polygon according to the target center point and the target edge point to obtain a target path corresponding to the target polygon;
[0007] A stripe pattern corresponding to the target polygon is constructed based on the target path.
[0008] The embodiment of the present invention further discloses a pattern generating device, comprising:
[0009] A graphics construction module, used to construct a target polygon and extract corresponding target center points and target edge points from the target polygon;
[0010] A path search module, used to perform path search in the target polygon according to the target center point and the target edge point, and obtain a target path corresponding to the target polygon;
[0011] A pattern generation module is used to construct a stripe pattern corresponding to the target polygon based on the target path.
[0012] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0013] The memory is used to store computer programs;
[0014] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0015] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0016] The embodiments of the present invention include the following advantages:
[0017] In an embodiment of the present invention, when drawing a corresponding stripe pattern, a target polygon is constructed, and the corresponding target center point and target edge point are extracted from the target polygon. Then, a path search is performed in the target polygon according to the target center point and the target edge point to obtain a target path corresponding to the target polygon. Then, a stripe pattern corresponding to the target polygon is constructed based on the target path. After the target polygon is constructed, a path search can be performed based on the target center point and the target edge point in the target polygon, and a corresponding stripe pattern can be constructed based on the search result. Through the programmed pattern construction process, the production process of the stripe pattern is greatly accelerated, and the game development cost is reduced. At the same time, based on the programmed processing process, players can create corresponding stripe effects through simple adjustments, thereby increasing the interactive experience of the game. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a flow chart of steps of a method for generating a pattern provided in an embodiment of the present invention;
[0019] Figure 2 is a schematic diagram of a graphic drawing provided in an embodiment of the present invention;
[0020] Figure 3 is a schematic diagram of a graphic drawing provided in an embodiment of the present invention;
[0021] Figure 4 is a schematic diagram of a graphic drawing provided in an embodiment of the present invention;
[0022] Figure 5 is a diagram showing changes in the planing process provided in an embodiment of the present invention;
[0023] Figure 6 is a schematic diagram of the planing effect provided in an embodiment of the present invention;
[0024] Figure 7 is a schematic diagram of a subdivision effect provided in an embodiment of the present invention;
[0025] Figure 8is a schematic diagram of a pattern provided in an embodiment of the present invention;
[0026] Fig. 9 is a schematic diagram of a smoothing process provided in an embodiment of the present invention;
[0027] Fig.10 is a schematic diagram of a mirror image pattern provided in an embodiment of the present invention;
[0028] Fig.11 is a rendering of a stripe pattern provided in an embodiment of the present invention;
[0029] Fig.12 is a structural block diagram of a pattern generating device provided in an embodiment of the present invention;
[0030] Fig.13 It is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] As an example, in game development projects, it is usually necessary to produce some special decorative stripe effects. However, it often takes a lot of time and effort to produce such patterns. When a large number of such patterns need to be produced, a lot of costs will be wasted, affecting the development efficiency of the game project.
[0033] In this regard, in the present invention, when drawing the corresponding stripe pattern, a target polygon is constructed, and the corresponding target center point and target edge point are extracted from the target polygon. Then, a path search is performed in the target polygon according to the target center point and the target edge point to obtain the target path corresponding to the target polygon. Then, the stripe pattern corresponding to the target polygon is constructed based on the target path. After the target polygon is constructed, a path search can be performed based on the target center point and the target edge point in the target polygon, and a corresponding stripe pattern can be constructed based on the search result. Through the programmed pattern construction process, the production process of the stripe pattern is greatly accelerated, and the game development cost is reduced. At the same time, based on the programmed processing process, players can create the corresponding stripe effect through simple adjustments, thereby increasing the interactive experience of the game.
[0034] Reference Figure 1 , shows a flow chart of the steps of a method for generating a pattern provided in an embodiment of the present invention, which may specifically include the following steps:
[0035] Step 101, constructing a target polygon, and extracting corresponding target center points and target edge points from the target polygon;
[0036] Optionally, the present invention can be applied to image processing software. Game developers can draw corresponding stripe patterns in the image processing software to apply the drawn stripe patterns to the game. For example, the stripe patterns can include geometric stripes, gradient stripes, texture stripes, dynamic stripes, retro stripes, metal stripes, water wave stripes, flame stripes, etc. The drawn stripe patterns can be applied to the costumes, weapons, props and corresponding interactive elements of the characters in the game, and can also be applied to the environment, buildings, ground, etc., so that the artistic style and atmosphere of the game can be enhanced through the corresponding stripe patterns.
[0037] In the process of making striped patterns, corresponding graphics construction instructions are input to construct corresponding target polygons in the coordinate system provided by the image processing software. After the corresponding target polygons are constructed, the corresponding target center points and target edge points are extracted from the target polygons, so as to perform subsequent programmatic decorative stripe generation based on the shortest path query based on the target center points and target edge points.
[0038] In some feasible implementations, graphics construction instructions may include at least polygon construction instructions, slicing instructions and subdivision instructions. Polygon construction instructions can be used to construct an initial polygon, slicing instructions can be used to slicing the initial polygon to obtain sub-polygons located in the initial polygon, and subdivision instructions can be used to further subdivide the sub-polygons to obtain the target polygon.
[0039] In a specific implementation, the terminal may first respond to a polygon construction instruction input by a user to construct an initial polygon corresponding to the polygon construction instruction, then respond to a planing instruction input by a user for the initial polygon to obtain planing parameters for the initial polygon, and divide the initial polygon according to the planing parameters to obtain a number of sub-polygons corresponding to the initial polygon, and finally respond to a subdivision instruction input by a user for the sub-polygon to subdivide each sub-polygon to obtain a target polygon corresponding to the initial polygon, thereby effectively constructing a basic graphic for making a striped pattern through the construction of a corresponding polygon and through the planing, subdivision and other processes, providing a basic data basis for the production of a striped pattern, and the user only needs to implement the entire graphic production process through simple interactive operations, which greatly reduces the operating burden and the difficulty of production, and can effectively improve the production efficiency of the striped pattern.
[0040] Furthermore, the polygon construction instruction may also include a line segment creation instruction and a line segment processing instruction. The line segment creation instruction may be used to create corresponding basic line segments, and the line segment processing instruction may be used to process the basic line segments to obtain corresponding initial polygons. Specifically, the terminal may respond to the polygon construction instruction input by the user to create a first line segment corresponding to the polygon construction instruction. After drawing the corresponding first line segment, the terminal may further respond to the line segment processing instruction to obtain a line segment rotation angle for the first line segment, copy the first line segment to obtain a second line segment, and then rotate the second line segment according to the line segment rotation angle, and connect the first end point of the first line segment and the second end point of the rotated second line segment to construct the corresponding initial polygon.
[0041] For example, refer to Figure 2 , Figure 3 as well as Figure 4 , the user can draw a first line segment of any length in the image making software, and the orientation of the first line segment can be (0, 1, 0), that is, the orientation of the first line segment is perpendicular to the horizontal plane, and then the last point of the first line segment can be added to the group "PointGroup1", and then the first line segment is copied, and the copied second line segment is rotated according to the line segment rotation parameters {0, 0, 360 / inputA / 2} set by the user. During the rotation process, the starting point of the first line segment can be used as the rotation center to obtain the rotated second line segment, and finally the corresponding end points of the two line segments are connected to construct the corresponding triangle, that is, to obtain the initial polygon. It should be noted that for inputA, it can be a floating point type parameter input by the user. In the process of processing the line segment, the inputA can be the angle between the two line segments, and the angle between the first line segment and the second line segment can be controlled by the angle.
[0042] After the user draws the corresponding initial polygon, the user can input the partitioning parameters for the initial polygon, and divide the initial polygon by the partitioning parameters to obtain a plurality of sub-polygons located in the initial polygon. The partitioning parameters include at least a weight value, and the weight value is used to determine the relative position of the newly generated vertex and the original vertex in the initial polygon. In the partitioning process, the first vertex position of the original vertex in the initial polygon can be obtained first, and then the first vertex positions corresponding to the two original vertices on the target edge of the initial polygon can be interpolated according to the weight value to obtain the first vertex located on the target edge, and then the various first vertices are connected to divide the initial polygon to obtain a plurality of sub-polygons corresponding to the initial polygon.
[0043] Among them, the weight value can be a value calculated according to the corresponding iteration number, and the relative position of the currently generated new vertex and the original polygon vertex can be determined by the weight value. For example, when the initial polygon is a triangle, the number of iterations is initially assumed to be 6, the number of loop iterations, i is the current number of loops, then the number of loops i / total number of iterations 6 is used to obtain the weight value t1=i / 6, and the positions of the original triangle vertices P1 and P2 are obtained, and the linear interpolation algorithm lerp(P1, P2, t1) is used to calculate the new vertex position pt1 on this edge, thereby calculating the new vertex position pt1 on this edge, and similarly interpolating the vertices p1 and p3 in the original triangle to generate a new vertex pt2, and then creating a new vertex between pt1 and pt2, looping the current value of i, for(int j=0;j<=i;j++), calculate the weight between pt1 and pt2 through t2=j / I, and use lerp to calculate the position of the new point pt3, and finally connect pt1 with pt2 and pt3 to form the final effect, and obtain several sub-polygons in the initial polygon, that is, obtain several sub-triangles in the original triangle, such as Figure 5 The change diagram of the planing process shown in the figure, Figure 6 The final effect diagram is shown.
[0044] After the initial polygon is divided, the user can further input a corresponding subdivision instruction, and the sub-polygon is subdivided by the subdivision instruction, so as to obtain a target polygon corresponding to the initial polygon based on the subdivision result. Specifically, the terminal can respond to the subdivision instruction for the sub-polygon, create a corresponding second vertex at the midpoint position of each edge in the sub-polygon, and create a corresponding third vertex at the center position of the sub-polygon, and then connect the second vertex and the third vertex to subdivide the sub-polygon to obtain a target polygon corresponding to the initial polygon.
[0045] It should be noted that in the process of subdivision, the user can use the OpenSubdivBilinear algorithm to subdivide the sub-polygons in the initial polygon. The algorithm can divide a plane area or curve into multiple triangles. Assuming that the initial polygon is a triangle and the corresponding sub-polygon is also a triangle, in the process of subdivision, for each triangle, a new vertex can be inserted at the midpoint of each edge and a new vertex can be inserted at the center of the triangle. At the same time, for the original vertices of the triangle, their positions are adjusted to smooth the curve. For the newly inserted vertices, their positions can be kept unchanged. Finally, the newly inserted vertices and the adjusted old vertices are connected to construct a new triangle network, thereby obtaining the corresponding target polygon, such as Figure 7 As shown, the effect diagram after subdivision is shown.
[0046] After the target polygon is constructed through the above process, the corresponding vertices can be extracted from the target polygon for path search. In some feasible implementations, the edge points located on the side of the target polygon and the center point located inside the target polygon can be extracted, and then the first random number corresponding to each center point and the second random number corresponding to each edge point can be calculated respectively, and the center point whose first random number is greater than or equal to the preset threshold is used as the target center point, and the initial edge point whose second random number is greater than or equal to the preset threshold is used as the target edge point. Optionally, for the random number generation process, the user can input the corresponding parameter "threshold_input2", which controls the size of the threshold. If the random value calculated by the vertex is less than the "threshold_input2" input by the user, the point is removed, thereby obtaining the first array "StarGroup" corresponding to the target center point and the second array "endGroup" corresponding to the target edge point, so as to perform path search based on the first array and the second array.
[0047] It should be noted that, for the center point, it can be a vertex located inside the target polygon, and the number of neighboring points of the vertex is greater than or equal to the preset threshold. For example, assuming the preset threshold is 6, for vertices ① and vertices ② that are also located in the target polygon, the number of neighboring points of vertex ① is 3, and the number of neighboring points of vertex ② is 6, then vertex ② can be used as the center point, and vertex ① can be directly discarded, so as to extract the corresponding center point from the target polygon.
[0048] Step 102, performing a path search in the target polygon according to the target center point and the target edge point to obtain a target path corresponding to the target polygon;
[0049] In an embodiment of the present invention, noise information corresponding to a target center point and a target edge point can be calculated, and then a target array corresponding to the target center point and the target edge point is created, the target array at least including a processing array, a distance array and a predecessor array, and then the current point is extracted from the processing array, and the adjacent points of the current point are queried, and the first distance value between each adjacent point and the current point is calculated, and the first distance value is processed using the noise information to obtain the corresponding second distance value. If the second distance value is less than the first distance value, the distance value corresponding to the current point in the distance array and the points in the predecessor array are updated, and all target edge points are traversed by looping until the target path corresponding to the target polygon is determined.
[0050] Among them, the processing array can be an array for placing the currently processed points in the path finding process; the distance array can be an array for storing distance values, corresponding one to one with each point (target center point and target edge point); the predecessor array can be an array for recording the source of each point, so that in the path finding process, the target center point is used as the starting point, and each edge point adjacent to it is traversed to search for the shortest path. During the search process, corresponding noise information is introduced to affect the path search, and then each array is continuously updated based on the calculated distance value. After the shortest path is finally found, the corresponding target path can be constructed based on the points recorded in the predecessor array, so as to construct the corresponding pattern based on the target path.
[0051] In one example, the shortest path can be found from the points in StarGroup to the points in endGroup, and the search path can be affected by the generated one-dimensional noise. Specifically, a distance array (each point corresponds to the array one-to-one) and a predecessor array (recording the source of each point) can be created first, and then an array can be created to store the points to be processed. The default value is the starting point, and then the corresponding shortest path search process is performed. For the path-finding process, the following steps can be repeated: ① Take a point from the point group to be processed; ② Query the neighboring points of the current point; ③ Calculate the distance for each neighboring point, and use the distance + the generated noise value to affect the search path; ④ If the new distance after the impact is smaller than the previous distance, update the distance and the predecessor point, and put the neighboring point into the array to be processed. By looping all the points in the endGroup, query whether the distance value in the distance value is the default value. If not, it means that the shortest path has been queried. Finally, the final path can be calculated using the predecessor array, and the final result is as follows. Figure 8 The effect shown.
[0052] Specifically, by creating two arrays: distance array: used to record the shortest distance from the starting point to each point. Initially, the distance of all points is set to a very large value (indicates infinity), and only the distance of the starting point is set to 0; predecessor array: used to record the predecessor point of each point, that is, the previous point of the point in the path. Initially, the predecessor points of all points are set to empty (indicates that there is no predecessor point). Next, create an array to store the points to be processed. Initially, this array only contains the starting point. Find the shortest path by repeating the following steps:
[0053] a. Take out the point to be processed: take out a point from the array of points to be processed, which is the point with the shortest current distance.
[0054] b. Query neighboring points: Find all neighboring points of the current point (i.e. points directly connected to the current point).
[0055] c. Calculate distance and consider noise: For each neighboring point, calculate the distance from the starting point to the neighboring point and add the one-dimensional noise value generated by S9. This noise value will affect the choice of path, making the path more random and diverse.
[0056] d. Update distance and predecessor point: If the calculated new distance is smaller than the previously recorded distance, update the distance value and predecessor point of the neighboring point, and put the neighboring point into the array to be processed for subsequent processing.
[0057] Loop through all the points in the endGroup and check whether their distance values in the distance array are the default value (infinity). If not, it means that the shortest path from the starting point to the point has been found. Finally, use the predecessor array to backtrack from the end point and gradually find the predecessor point of each point until you return to the starting point. In this way, you can build a complete path from the starting point to the end point.
[0058] Step 103: construct a stripe pattern corresponding to the target polygon based on the target path.
[0059] After obtaining the corresponding target path through the above process, the corresponding stripe pattern can be constructed based on the obtained target path. After constructing the target polygon, a path search can be performed based on the target center point and the target edge point in the target polygon, and the corresponding stripe pattern can be constructed based on the search result. Through the programmed pattern construction process, the production process of the stripe pattern is greatly accelerated, and the cost of game development is reduced. At the same time, based on the programmed processing process, players can create corresponding stripe effects through simple adjustments, which increases the interactive experience of the game.
[0060] In some feasible implementations, the smoothing parameters for the target path can be obtained first, and then the target path is smoothed according to the smoothing parameters to obtain the basic pattern corresponding to the target polygon, and then the adjustment parameters for the basic pattern are obtained, and the basic pattern is adjusted according to the adjustment parameters to obtain the stripe pattern corresponding to the basic pattern. Wherein, the adjustment parameters at least include the mirror direction, the pattern rotation angle, and the number of replications. The basic pattern can be mirrored according to the mirror direction to obtain the corresponding mirror pattern, and then the vertex of the mirror pattern is used as the rotation center, and the mirror pattern is replicated according to the number of replications in response to the rotation according to the pattern rotation angle. Based on the replicated multiple mirror patterns, the stripe pattern corresponding to the basic pattern is constructed, so that by drawing the corresponding basic pattern and then processing it with the corresponding adjustment parameters, the drawing process of the stripe pattern can be simplified and the generation efficiency of the stripe pattern can be improved. On the other hand, the basic pattern can be expanded and adjusted as needed, which improves the flexibility and scalability of pattern construction.
[0061] For example, refer to Fig. 9 , by smoothing the target path accordingly, the stripe pattern can be made more rounded, and then based on the smoothed group, it can be mirrored along the x-axis to obtain Fig.10 The mirror image pattern shown can then be rotated and copied n times, with each copy rotating 360 / n, to finally obtain Fig.11 The effect diagram shown.
[0062] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention is not limited to this.
[0063] In an embodiment of the present invention, when drawing a corresponding stripe pattern, a target polygon is constructed, and the corresponding target center point and target edge point are extracted from the target polygon. Then, a path search is performed in the target polygon according to the target center point and the target edge point to obtain a target path corresponding to the target polygon. Then, a stripe pattern corresponding to the target polygon is constructed based on the target path. After the target polygon is constructed, a path search can be performed based on the target center point and the target edge point in the target polygon, and a corresponding stripe pattern can be constructed based on the search result. Through the programmed pattern construction process, the production process of the stripe pattern is greatly accelerated, and the game development cost is reduced. At the same time, based on the programmed processing process, players can create corresponding stripe effects through simple adjustments, thereby increasing the interactive experience of the game.
[0064] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0065] Reference Fig.12 , shows a structural block diagram of a pattern generating device provided in an embodiment of the present invention, which may specifically include the following modules:
[0066] A graphics construction module 1201 is used to construct a target polygon and extract corresponding target center points and target edge points from the target polygon;
[0067] A path search module 1202, configured to perform a path search in the target polygon according to the target center point and the target edge point, and obtain a target path corresponding to the target polygon;
[0068] The pattern generating module 1203 is used to construct a stripe pattern corresponding to the target polygon based on the target path.
[0069] In some feasible implementations, the graph construction module 1201 is specifically used for:
[0070] Construct the initial polygon;
[0071] Acquire a partitioning parameter for the initial polygon, and divide the initial polygon according to the partitioning parameter to obtain a plurality of sub-polygons corresponding to the initial polygon;
[0072] Each of the sub-polygons is subdivided to obtain a target polygon corresponding to the initial polygon.
[0073] In some feasible implementations, the graph construction module 1201 is specifically used for:
[0074] Creating a first line segment corresponding to the polygon construction instruction;
[0075] Acquire a line segment rotation angle for the first line segment;
[0076] Copying the first line segment to obtain a second line segment;
[0077] The second line segment is rotated according to the line segment rotation angle, and the first end point of the first line segment is connected with the second end point of the rotated second line segment to construct a corresponding initial polygon.
[0078] In some feasible implementations, the slicing parameters include at least a weight value, and the weight value is used to determine the relative position of the newly generated vertex and the original vertex in the initial polygon. The graphics construction module 1201 is specifically used to:
[0079] Obtaining the first vertex position of the original vertex in the initial polygon;
[0080] Performing interpolation processing on first vertex positions corresponding to two original vertices on the target edge in the initial polygon according to the weight value to obtain a first vertex located on the target edge;
[0081] The first vertices are connected to split the initial polygon to obtain a plurality of sub-polygons corresponding to the initial polygon.
[0082] In some feasible implementations, the graph construction module 1201 is specifically used for:
[0083] Creating a corresponding second vertex at the midpoint of each edge in the sub-polygon, and creating a corresponding third vertex at the center of the sub-polygon;
[0084] The second vertex and the third vertex are connected, and the sub-polygon is subdivided to obtain a target polygon corresponding to the initial polygon.
[0085] In some feasible implementations, the graph construction module 1201 is specifically used for:
[0086] Extracting edge points located on the sides of the target polygon and center points located inside the target polygon;
[0087] Calculate the first random number corresponding to each of the center points;
[0088] Calculate a second random number corresponding to each edge point;
[0089] The center point whose first random number is greater than or equal to the preset threshold is taken as the target center point, and the initial edge point whose second random number is greater than or equal to the preset threshold is taken as the target edge point.
[0090] In some feasible implementations, the path search module 1202 is specifically used to:
[0091] Calculating noise information corresponding to the target center point and the target edge point;
[0092] Creating a target array corresponding to the target center point and the target edge point, the target array at least comprising a processing array, a distance array, and a predecessor array;
[0093] Extracting a current point from the processing array, and querying adjacent points of the current point;
[0094] Calculate a first distance value between each of the adjacent points and the current point;
[0095] Processing the first distance value using the noise information to obtain a corresponding second distance value;
[0096] If the second distance value is less than the first distance value, updating the distance value corresponding to the current point in the distance array and the point in the predecessor array;
[0097] All the target edge points are traversed in a loop until the target path corresponding to the target polygon is determined.
[0098] In some feasible implementations, the pattern generating module 1203 is specifically used to:
[0099] Obtaining a smoothing parameter for the target path;
[0100] Smoothing the target path according to the smoothing parameter to obtain a basic pattern corresponding to the target polygon;
[0101] An adjustment parameter for the basic pattern is obtained, and pattern adjustment is performed on the basic pattern according to the adjustment parameter to obtain a stripe pattern corresponding to the basic pattern.
[0102] In some feasible implementations, the adjustment parameters include at least a mirroring direction, a pattern rotation angle, and a number of replications, and the pattern generation module 1203 is specifically configured to:
[0103] Mirroring the basic pattern according to the mirroring direction to obtain a corresponding mirrored pattern;
[0104] Taking the vertex of the mirror pattern as the rotation center, in response to rotating according to the pattern rotation angle, the mirror pattern is replicated according to the replication number, and based on the replicated multiple mirror patterns, a stripe pattern corresponding to the basic pattern is constructed.
[0105] As 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.
[0106] In addition, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned pattern generation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0107] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned pattern generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0108] Fig.13 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0109] The electronic device 1300 includes but is not limited to: a radio frequency unit 1301, a network module 1302, an audio output unit 1303, an input unit 1304, a sensor 1305, a display unit 1306, a user input unit 1307, an interface unit 1308, a memory 1309, a processor 1310, and a power supply 1311. Those skilled in the art can understand that the electronic device structure involved in the embodiment of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or less components than shown in the figure, or combine certain components, or arrange components differently. In the embodiment of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0110] It should be understood that in the embodiment of the present invention, the radio frequency unit 1301 can be used for receiving and sending signals during information transmission or call. Specifically, after receiving the downlink data from the base station, it is sent to the processor 1310 for processing; in addition, the uplink data is sent to the base station. Generally, the radio frequency unit 1301 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 1301 can also communicate with the network and other devices through a wireless communication system.
[0111] The electronic device provides users with wireless broadband Internet access through the network module 1302, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0112] The audio output unit 1303 can convert the audio data received by the RF unit 1301 or the network module 1302 or stored in the memory 1309 into an audio signal and output it as sound. Moreover, the audio output unit 1303 can also provide audio output related to a specific function performed by the electronic device 1300 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 1303 includes a speaker, a buzzer, a receiver, etc.
[0113] The input unit 1304 is used to receive audio or video signals. The input unit 1304 may include a graphics processor (GPU) 13041 and a microphone 13042. The graphics processor 13041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 1306. The image frame processed by the graphics processor 13041 can be stored in the memory 1309 (or other storage medium) or sent via the radio frequency unit 1301 or the network module 1302. The microphone 13042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 1301 in the case of a telephone call mode.
[0114] The electronic device 1300 also includes at least one sensor 1305, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 13061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 13061 and / or the backlight when the electronic device 1300 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 1305 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0115] The display unit 1306 is used to display information input by the user or information provided to the user. The display unit 1306 may include a display panel 13061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0116] The user input unit 1307 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 1307 includes a touch panel 13071 and other input devices 13072. The touch panel 13071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 13071 or near the touch panel 13071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 13071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 1310, receives the command sent by the processor 1310 and executes it. In addition, the touch panel 13071 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 13071, the user input unit 1307 may also include other input devices 13072. Specifically, other input devices 13072 may include but are not limited to physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be repeated here.
[0117] Further, the touch panel 13071 may be covered on the display panel 13061. When the touch panel 13071 detects a touch operation on or near it, it is transmitted to the processor 1310 to determine the type of the touch event, and then the processor 1310 provides a corresponding visual output on the display panel 13061 according to the type of the touch event. It can be understood that in one embodiment, the touch panel 13071 and the display panel 13061 are used as two independent components to implement the input and output functions of the electronic device, but in some embodiments, the touch panel 13071 and the display panel 13061 can be integrated to implement the input and output functions of the electronic device, which is not limited here.
[0118] The interface unit 1308 is an interface for connecting an external device to the electronic device 1300. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 1308 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 1300 or may be used to transmit data between the electronic device 1300 and an external device.
[0119] The memory 1309 can be used to store software programs and various data. The memory 1309 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1309 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0120] The processor 1310 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1309 and calling data stored in the memory 1309, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1310 may include one or more processing units; preferably, the processor 1310 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1310.
[0121] The electronic device 1300 may also include a power supply 1311 (such as a battery) for supplying power to each component. Preferably, the power supply 1311 may be logically connected to the processor 1310 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system.
[0122] In addition, the electronic device 1300 includes some functional modules not shown, which will not be described in detail here.
[0123] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0125] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0126] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0128] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0129] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0130] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0131] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the 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, including several instructions for 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: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0132] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for generating a pattern, characterized in that: include: Constructing a target polygon, and extracting a target center point and a target edge point from the target polygon; Performing a path search in the target polygon according to the target center point and the target edge point to obtain a target path corresponding to the target polygon; A stripe pattern corresponding to the target polygon is constructed based on the target path.
2. The method according to claim 1, characterized in that The constructing of the target polygon comprises: Construct the initial polygon; Acquire a partitioning parameter for the initial polygon, and divide the initial polygon according to the partitioning parameter to obtain a plurality of sub-polygons corresponding to the initial polygon; Each of the sub-polygons is subdivided to obtain a target polygon corresponding to the initial polygon.
3. The method according to claim 2, characterized in that The constructing of the initial polygon comprises: Create the first line segment; Acquire a line segment rotation angle for the first line segment; Copying the first line segment to obtain a second line segment; The second line segment is rotated according to the line segment rotation angle, and the first end point of the first line segment is connected with the second end point of the rotated second line segment to construct a corresponding initial polygon.
4. The method according to claim 2 or 3, characterized in that: The segmentation parameters at least include weight values, and the weight values are used to determine the relative positions of the newly generated vertices and the original vertices in the initial polygon. The initial polygon is segmented according to the segmentation parameters to obtain a plurality of sub-polygons corresponding to the initial polygon, including: Obtaining the first vertex position of the original vertex in the initial polygon; Performing interpolation processing on first vertex positions corresponding to two original vertices on the target edge in the initial polygon according to the weight value to obtain a first vertex located on the target edge; The first vertices are connected to split the initial polygon to obtain a plurality of sub-polygons corresponding to the initial polygon.
5. The method according to claim 2 or 3, characterized in that: The step of subdividing each of the sub-polygons to obtain a target polygon corresponding to the initial polygon includes: Creating a corresponding second vertex at the midpoint of each edge in the sub-polygon, and creating a corresponding third vertex at the center of the sub-polygon; The second vertex and the third vertex are connected, and the sub-polygon is subdivided to obtain a target polygon corresponding to the initial polygon.
6. The method according to claim 1, 2 or 3, characterized in that: The extracting the corresponding target center point and target edge point from the target polygon comprises: Extracting edge points located on the sides of the target polygon and center points located inside the target polygon; Calculate the first random number corresponding to each of the center points; Calculate a second random number corresponding to each edge point; The center point whose first random number is greater than or equal to the preset threshold is taken as the target center point, and the initial edge point whose second random number is greater than or equal to the preset threshold is taken as the target edge point.
7. The method according to claim 1, 2 or 3, characterized in that: The performing path search in the target polygon according to the target center point and the target edge point to obtain the target path corresponding to the target polygon comprises: Calculating noise information corresponding to the target center point and the target edge point; Creating a target array corresponding to the target center point and the target edge point, the target array at least comprising a processing array, a distance array, and a predecessor array; Extracting a current point from the processing array, and querying adjacent points of the current point; Calculate a first distance value between each of the adjacent points and the current point; Processing the first distance value using the noise information to obtain a corresponding second distance value; If the second distance value is less than the first distance value, updating the distance value corresponding to the current point in the distance array and the point in the predecessor array; All the target edge points are traversed in a loop until the target path corresponding to the target polygon is determined.
8. The method according to claim 1, characterized in that The step of constructing a stripe pattern corresponding to the target polygon based on the target path includes: Obtaining a smoothing parameter for the target path; Smoothing the target path according to the smoothing parameter to obtain a basic pattern corresponding to the target polygon; An adjustment parameter for the basic pattern is obtained, and pattern adjustment is performed on the basic pattern according to the adjustment parameter to obtain a stripe pattern corresponding to the basic pattern.
9. The method according to claim 8, characterized in that The adjustment parameters at least include a mirroring direction, a pattern rotation angle, and a number of replications, and the step of adjusting the basic pattern according to the adjustment parameters to obtain a stripe pattern corresponding to the basic pattern includes: Mirroring the basic pattern according to the mirroring direction to obtain a corresponding mirrored pattern; Taking the vertex of the mirror pattern as the rotation center, in response to rotating according to the pattern rotation angle, the mirror pattern is replicated according to the replication number, and based on the replicated multiple mirror patterns, a stripe pattern corresponding to the basic pattern is constructed.
10. A pattern generating device, characterized in that: include: A graphics construction module, used to construct a target polygon and extract corresponding target center points and target edge points from the target polygon; A path search module, used to perform path search in the target polygon according to the target center point and the target edge point, and obtain a target path corresponding to the target polygon; A pattern generation module is used to construct a stripe pattern corresponding to the target polygon based on the target path.
11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 9 when executing the program stored in the memory.
12. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 9.