A Graphics Processing Method, Apparatus, Device, and Medium
By determining the surrounding circle of the target icon and processing the sampling point, combining the interpolation algorithm and pre-calculation of the ray intersection point, the problem of slow speed and low accuracy of the intersection point prediction of the target line segment and the target icon in the graph visualization is solved, and the graph drawing speed and dynamic interaction effect are improved.
Patent Information
- Application Number
- CN202210329964.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-03-31
AI Technical Summary
In the prior art In the graph visualization, the prediction of intersection points between the target line segment and the target icon has problems such as large calculation amount, slow speed and low accuracy, resulting in poor connection effect.
By determining the surrounding circle of the target icon, sampling preset sampling points, obtaining the intersection point between the target line segment and the surrounding circle, and using the interpolation algorithm to predict the intersection point between the target line segment and the target icon, combining the pre-calculation of the ray intersection point and data table recording, the connection path is optimized.
It achieves fast and accurate prediction of the intersection points of the target line segment and the target icon, and improves the drawing speed and dynamic interactive experience of graph visualization.
Smart Images

Figure CN114708356B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph visualization technology, and in particular to a graph processing method, device, equipment and medium. Background Art
[0002] Graph visualization is a subfield of information visualization. It helps users gain insights into data by displaying elements and relationships. It has been widely used in the presentation of relational data such as flowcharts and topology diagrams. In graph visualization scenarios, that is, when drawing relationship diagrams, topology diagrams, flowcharts, and other diagrams that rely on nodes and lines to describe processes, relationships, and layouts, it is often necessary to connect from one node to another. These nodes are often various icons, and the nodes often use icons with transparent backgrounds. In applications, they are often connected with lines to represent relationships. However, in addition to pixel information, the image itself only has width and height information. Therefore, the low-cost connection is to treat the icon as a rectangular or circular connection through the idea of minimum enclosing. As a result, in many cases, the connection is not actually connected to the icon, but floats around the icon. When the icon content is large, it is easy to have difficulty in judging whether the connection is connected to the icon. For example, Figure 1 As shown, Figure 1 The line between the two icons is not directly connected to the icons, but to the outer border, which reduces the visualization effect of the graph.
[0003] In addition, since modern screens are made up of pixels, the above technical problem can also be solved by treating the line segment between the two icons as a collection of pixels. Starting from the starting point selected in one icon, it is determined one by one whether the pixels on the line segment fall in the other icon. If so and it is the first time in the other icon, it means that the line segment has intersected with the other icon. This method can indeed find an exact solution, but the huge amount of calculation in real-time calculation will cause jamming, which seriously reduces the graphics drawing speed and dynamic interactive experience.
[0004] In summary, how to predict the intersection point between the target line segment and the target icon more quickly and accurately is a problem that needs to be solved. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a graphics processing method, device, equipment and medium, which can more quickly and accurately predict the intersection between the target line segment and the target icon. The specific scheme is as follows:
[0006] In a first aspect, the present application discloses a graphics processing method, comprising:
[0007] Determine the circumcircle corresponding to the target icon on the electronic drawing board, and sample the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points;
[0008] Determine the target line segment by determining the line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle, and determine the first target intersection point of the target line segment and the circumcircle;
[0009] Obtain two sampling points adjacent to the first target intersection point from all the sampling points;
[0010] Predict the second target intersection point between the target line segment and the target icon based on the two sampling points, and draw and display the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point on the electronic drawing board.
[0011] Optionally, the determining the circumcircle corresponding to the target icon on the electronic drawing board includes:
[0012] Determine the minimum circumscribed rectangle corresponding to the target icon on the electronic drawing board, and obtain the position parameter information of the minimum circumscribed rectangle; wherein, the position parameter information includes the position coordinates of the upper left vertex of the minimum circumscribed rectangle, the width information and the height information;
[0013] Determine the position coordinate of the center of the circumcircle and the radius size based on the position parameter information, and determine the circumcircle according to the position coordinate of the center of the circumcircle and the radius size.
[0014] Optionally, in the process of determining the target line segment by determining the line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle, it further includes:
[0015] Obtain the angular size of the target line segment in the local coordinate system based on the position coordinate of the preset coordinate point and the position coordinate of the center of the circle.
[0016] Optionally, after sampling the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points, it further includes:
[0017] Emit rays around each sampling point at a preset angle, and then screen out the target rays that intersect with the target icon to obtain a set of target rays;
[0018] Obtain the angular value of each target ray in the set of target rays in the local coordinate system, and then record the intersection position information of each target ray and the target icon in the predefined data table in ascending order of the angular value for each set of target rays.
[0019] Optionally, predicting the second target intersection point between the target line segment and the target icon based on the two sampling points includes:
[0020] Filter out a first set of target rays and a second set of target rays corresponding to the two sampling points from the data table, and respectively determine two target rays corresponding to two angle values similar to the angle size from the first set of target rays and the second set of target rays;
[0021] Obtain the first intersection point position information between the two target rays in the first set of target rays and the target icon from the data table, and obtain the second intersection point position information between the two target rays in the second set of target rays and the target icon;
[0022] Based on the first intersection point position information and the second intersection point position information respectively, and using the interpolation algorithm to predict the corresponding third target intersection point and fourth target intersection point, and then use the interpolation algorithm to interpolate the third target intersection point and the fourth target intersection point to obtain the prediction result of the second target intersection point between the target line segment and the target icon.
[0023] Optionally, determining the minimum bounding rectangle corresponding to the target icon on the electronic drawing board includes:
[0024] Determine the starting positions of the boundary lines in the horizontal and vertical directions on the electronic drawing board, and use the unit pixel interval as the current moving interval. Move the boundary lines from the starting positions towards the target icon to obtain the current positions of the boundary lines, and determine whether the current positions intersect with the target icon;
[0025] If so, determine the boundary line as the boundary of the minimum bounding rectangle corresponding to the target icon, and obtain the minimum bounding rectangle; if not, expand the current moving interval by a preset multiple to update the current moving interval, and move the boundary line from the current position towards the target icon according to the updated current moving interval to obtain the next position of the boundary line, and then determine whether the next position intersects with the target icon;
[0026] If not, jump back to the step of expanding the current moving interval by a preset multiple to update the current moving interval until the position where the boundary line is located intersects with the target icon to obtain the minimum bounding rectangle corresponding to the target icon.
[0027] Optionally, after determining whether the next position intersects with the target icon, it further includes:
[0028] If the next position intersects with the target icon, determine whether the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is a unit pixel interval; if so, determine the boundary line as the boundary of the minimum bounding rectangle corresponding to the target icon, and obtain the minimum bounding rectangle;
[0029] If not, control the boundary line to return to the previous position, reduce the current movement interval by the preset multiple to update the current movement interval, then move the boundary line from the previous position towards the target icon according to the updated current movement interval to obtain the new next position of the boundary line, and then determine whether the new next position intersects with the target icon;
[0030] If not, jump back to the step of reducing the current movement interval by the preset multiple to update the current movement interval until the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is a unit pixel interval, so as to obtain the minimum bounding rectangle corresponding to the target icon.
[0031] In a second aspect, the present application discloses a graphics processing device, including:
[0032] A sampling module, configured to determine a circumscribed circle corresponding to a target icon on an electronic drawing board, and sample the circumscribed circle according to a preset number of sampling points to obtain a corresponding number of sampling points;
[0033] A parameter determination module, configured to determine a target line segment by determining a line segment between a preset coordinate point on the electronic drawing board and the center of the circumscribed circle, and determine a first target intersection point between the target line segment and the circumscribed circle;
[0034] A sampling point acquisition module, configured to acquire two sampling points adjacent to the first target intersection point from all the sampling points;
[0035] A prediction module, configured to predict a second target intersection point between the target line segment and the target icon based on the two sampling points;
[0036] A drawing module, configured to draw and display a line segment between the preset coordinate point and the first target intersection point and a line segment between the first target intersection point and the second target intersection point on the electronic drawing board.
[0037] In a third aspect, the present application discloses an electronic device, including:
[0038] A memory, configured to store a computer program;
[0039] A processor for executing the computer program to implement the steps of the aforementioned disclosed graphic processing method.
[0040] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed graphic processing method.
[0041] It can be seen that the present application first determines the circumscribed circle corresponding to the target icon on the electronic drawing board, and samples the circumscribed circle according to the preset number of sampling points to obtain a corresponding number of sampling points; then determines the line segment between the preset coordinate point on the electronic drawing board and the center of the circumscribed circle to obtain the target line segment, and determines the first target intersection point of the target line segment and the circumscribed circle; then obtains two sampling points adjacent to the first target intersection point from all the sampling points; finally, predicts the second target intersection point between the target line segment and the target icon based on the two sampling points, and draws and displays the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point on the electronic drawing board. Thus, it can be seen that the present application first determines the circumscribed circle corresponding to the target icon on the electronic drawing board, and determines the target line segment based on the preset coordinate point, and determines the first target intersection point of the target line segment and the circumscribed circle, and then obtains two sampling points adjacent to the first target intersection point from the sampling points obtained by previously sampling the circumscribed circle, so as to predict the second target intersection point between the target line segment and the target icon based on the above two sampling points. Through the above technical solution, the intersection point between the target line segment and the target icon can be predicted more accurately, so as to draw and display the connection line between the preset coordinate point outside the circumscribed circle and the target icon based on the intersection point. Description of the Drawings
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0043] Figure 1 A schematic diagram of the connection line between existing icons disclosed in the present application;
[0044] Figure 2 A flowchart of a graphic processing method disclosed in the present application;
[0045] Figure 3 A schematic diagram of sampling points disclosed in the present application;
[0046] Figure 4Schematic diagram of obtaining the minimum bounding rectangle disclosed in this application;
[0047] Figure 5 Connection diagram between a preset coordinate point and a target icon disclosed in this application;
[0048] Figure 6 Flowchart of a specific graphic processing method disclosed in this application;
[0049] Figure 7 Schematic diagram of rays around a specific sampling point disclosed in this application;
[0050] Figure 8 Schematic diagram of predicting an intersection point through pre-computed data disclosed in this application;
[0051] Figure 9 Connection diagram between icons disclosed in this application;
[0052] Figure 10 Schematic diagram of the structure of a graphic processing device disclosed in this application;
[0053] Figure 11 Structural diagram of an electronic device disclosed in this application. Specific implementation manners
[0054] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0055] In the graph visualization scenario, it is often necessary to connect from one node to another node. These nodes are usually icons with a transparent background. Taking one of the icons as an example, essentially, it can be considered as predicting the intersection point of a target line segment outside the icon and the icon. Currently, the intersection point position is mainly determined by simplifying the icon into a regular graph such as a rectangle or a circle or by solving pixel by pixel. However, the current technical solutions have disadvantages such as inaccurate connection lines and slow drawing speed, reducing the graph visualization effect and having a poor dynamic interaction experience. The embodiments of the present application disclose a graphic processing method, device, equipment, and medium, which can more quickly and accurately predict the intersection point between the target line segment and the target icon.
[0056] See Figure 2 As shown, the embodiments of the present application disclose a graphic processing method, which includes:
[0057] Step S11: Determine the circumcircle corresponding to the target icon on the electronic drawing board, and sample the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points.
[0058] In this embodiment, it is necessary to determine the circumcircle corresponding to the target icon on the electronic drawing board, then set the first precision value α, which represents the density of taking points on the circumcircle, that is, the preset number of sampling points, and sample equidistantly on the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points. Figure 3 Shows the schematic diagrams of sampling points when the preset number of sampling points α takes 4, 8, and 16 respectively.
[0059] Further, the above determination of the circumcircle corresponding to the target icon on the electronic drawing board includes: determining the minimum bounding rectangle corresponding to the target icon on the electronic drawing board, and obtaining the position parameter information of the minimum bounding rectangle; wherein, the position parameter information includes the position coordinates of the upper left corner vertex of the minimum bounding rectangle, the width information, and the height information; based on the position parameter information, determine the center position coordinates and radius size of the circumcircle, and determine the circumcircle according to the center position coordinates and radius size. It can be understood that when determining the circumcircle corresponding to the target icon, first, it is necessary to determine the minimum bounding rectangle corresponding to the target icon and obtain the position parameter information of the minimum bounding rectangle. Among them, the above position parameter information may include, but is not limited to, the position coordinates of the upper left corner vertex of the minimum bounding rectangle, the width information, and the height information, denoted as (x, y, width, height), where x and y are the abscissa and ordinate of the position of the upper left corner vertex of the minimum bounding rectangle, and width and height are the width and height of the minimum bounding rectangle respectively. Then, according to the above position parameter information, the center position of the circumcircle can be obtained as (x + width * 0.5, y + height * 0.5); the radius size R = Math.hypot(width * 0.5, height * 0.5), and Math.hypot is used to find the square root of the sum of the squares of the two input values. After obtaining the center position and radius size of the circumcircle, the circumcircle can be obtained.
[0060] It should be noted that the determination of the minimum bounding rectangle corresponding to the target icon on the electronic drawing board includes: determining the starting positions of the boundary lines in the horizontal and vertical directions on the electronic drawing board, using the unit pixel interval as the current moving interval, moving the boundary lines from the starting positions towards the target icon to obtain the current positions of the boundary lines, and determining whether the current positions intersect with the target icon; if so, determining the boundary lines as the boundaries of the minimum bounding rectangle corresponding to the target icon and obtaining the minimum bounding rectangle; if not, expanding the current moving interval by a preset multiple to update the current moving interval, moving the boundary lines from the current positions towards the target icon according to the updated current moving interval to obtain the next positions of the boundary lines, and then determining whether the next positions intersect with the target icon; if they do not intersect, re-jumping to the step of expanding the current moving interval by a preset multiple to update the current moving interval until the position where the boundary lines are located intersects with the target icon to obtain the minimum bounding rectangle corresponding to the target icon. It can be understood that in order to determine the minimum bounding rectangle corresponding to the target icon, one can start from any side in the horizontal and vertical directions on the electronic drawing board, approaching the target icon pixel by pixel from the starting position of the boundary line until there are pixels of the target icon on this boundary line. At this time, this boundary line can be used as the boundary of the target icon in this direction. However, trying pixel by pixel will result in a slow calculation speed. Therefore, it is optimized by using the method of hierarchical tracing in graphics. The algorithm idea is as follows. Assume that a boundary line starts from the left, the initial moving interval is the unit pixel interval 1, and then it is determined whether the moved boundary line intersects with the target icon. If it intersects, this boundary line is used as the boundary of the target icon in this direction; if it does not intersect, the unit pixel interval is doubled to obtain the pixel interval 2, and then it continues to move to the right. Then it is determined whether the boundary line after moving to the right intersects with the target icon. If it still does not intersect, the pixel interval 2 is doubled again to obtain the pixel interval 4. That is, as long as the position where the current boundary line is located does not intersect with the target icon, the pixel interval is doubled, and the above operations are repeated until the boundary line intersects with the target icon.
[0061] It should also be noted that after determining whether the next position intersects the target icon as described above, the following steps are further included: If the next position intersects the target icon, it is necessary to determine whether the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is a unit pixel interval; if so, the boundary line is determined as the boundary of the minimum bounding rectangle corresponding to the target icon, and the minimum bounding rectangle is obtained; if not, the boundary line is controlled to return to the previous position, and the current movement interval is reduced by the preset multiple to update the current movement interval, and then the boundary line is moved from the previous position towards the target icon according to the updated current movement interval to obtain the new next position of the boundary line, and then it is determined whether the new next position intersects the target icon; if it does not intersect, it jumps back to the step of reducing the current movement interval by the preset multiple until the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is a unit pixel interval, so as to obtain the minimum bounding rectangle corresponding to the target icon. That is to say, after the boundary line intersects the target icon, it is necessary to determine whether the pixel interval between the icon boundary vertex on the side where the boundary line is located and the current boundary line is a unit pixel interval 1. If it is 1, this boundary line is used as the boundary of the target icon in this direction. If it is not 1, it returns to the previous position and reduces the pixel interval by the preset multiple. For example, assuming that the current movement interval is a pixel interval of 4 and the preset multiple is 2, then the reduced movement interval is 2. Then, the boundary line is continued to be moved to the right according to the reduced movement interval, and it is determined whether the pixel interval between the icon boundary vertex and the current boundary line is a unit pixel interval 1. That is to say, as long as the pixel interval between the icon boundary vertex and the current boundary line is not a unit pixel interval 1, the multiple of the current movement interval is reduced until the boundary of the target icon in this direction is obtained.
[0062] See Figure 4 as shown in Figure 4 It shows a method for obtaining the minimum bounding rectangle of a target icon. Starting from a possible edge on the left and advancing step by step to the right in the order of L1, L2, and L3, it is tested whether this vertical line intersects the target icon until L3, and then L3 is marked as the left boundary of the irregular figure. After obtaining the boundaries in all four directions, a minimum bounding rectangle can be obtained.
[0063] Step S12: Determine the target line segment by obtaining the line segment between the preset coordinate point on the electronic drawing board and the center of the bounding circle, and determine the first target intersection point between the target line segment and the bounding circle.
[0064] In this embodiment, the above-mentioned preset coordinate point may be the center point of another icon. Then, connect the center point and the center of the circumscribing circle to obtain a target line segment, and determine the first target intersection point of the target line segment and the circumscribing circle.
[0065] Step S13: Obtain two sampling points adjacent to the first target intersection point from all the sampling points.
[0066] In this embodiment, obtaining two sampling points adjacent to the first target intersection point from all the sampling points. It can be understood that since the circumscribing circle is sampled in advance according to the preset number of sampling points and a corresponding number of sampling points are obtained. In a specific embodiment, if the first target intersection point is one of these sampling points, then directly use this sampling point as the first target intersection point; in another specific embodiment, if the first target intersection point is located at other positions on the circumscribing circle, then select two sampling points adjacent to the first target intersection point. However, in the specific implementation process, the first target intersection point often does not exactly fall on the position of the sampling point. Therefore, usually two sampling points adjacent to the first target intersection point are obtained from all the sampling points.
[0067] Step S14: Predict the second target intersection point between the target line segment and the target icon based on the two sampling points, and draw and display the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point on the electronic drawing board.
[0068] In this embodiment, predict the second target intersection point between the target line segment and the target icon through two sampling points adjacent to the first target intersection point, and draw and display the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point on the electronic drawing board, and finally obtain the connection line between the preset coordinate point and the target icon. The final connection line schematic diagram can be seen Figure 5 as shown.
[0069] It can be seen that in this application, the circumcircle corresponding to the target icon on the electronic drawing board is first determined, and the circumcircle is sampled according to the preset number of sampling points to obtain a corresponding number of sampling points; then the line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle is determined to obtain the target line segment, and the first target intersection point between the target line segment and the circumcircle is determined; then two sampling points adjacent to the first target intersection point are obtained from all the sampling points; finally, the second target intersection point between the target line segment and the target icon is predicted based on the two sampling points, and the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point are drawn and displayed on the electronic drawing board. Thus, it can be seen that in this application, the circumcircle corresponding to the target icon on the electronic drawing board is first determined, and the target line segment is determined based on the preset coordinate point, and the first target intersection point between the target line segment and the circumcircle is determined, and then two sampling points adjacent to the first target intersection point are obtained from the sampling points obtained by pre-sampling the circumcircle, so as to predict the second target intersection point between the target line segment and the target icon based on the above two sampling points. Through the above technical solution, the intersection point between the target line segment and the target icon can be predicted more accurately, so as to draw and display the connection line between the preset coordinate point outside the circumcircle and the target icon based on this intersection point.
[0070] See Figure 6 As shown, an embodiment of the present application discloses a specific graphics processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically, it includes:
[0071] Step S21: Determine the circumcircle corresponding to the target icon on the electronic drawing board, and sample the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points.
[0072] Step S22: For each of the sampling points, emit rays around at a preset angle, and then screen out the target rays that intersect the target icon to obtain a set of target rays.
[0073] In this embodiment, it is necessary to emit rays around at a preset angle for each sampling point. First, it is necessary to determine the second precision value β, which represents the number of emitted rays, and obtain the preset angle through the number of rays. It should be noted that since any connection line will hit from a point outside the circumcircle to a point inside the circumcircle, the rays that may intersect the target icon must be within the 180-degree range emitted inward along the tangent of the point on the circumcircle. Assuming that 180 degrees is equally divided into N parts, N - 1 inward-emitted rays will be obtained, and the value of N - 1 is defined as β. When the value of β is 5, it means that 180 degrees is equally divided into 6 parts, that is, the preset angle is 30 degrees, and 5 rays are emitted inward along the tangent, as Figure 7As shown in the figure, among the five rays emitted from sampling point A, the two adjacent rays on the side do not intersect the target icon, while the three middle rays intersect the target icon to obtain three intersection points P1, P2, and P3 respectively. Then, based on the three middle rays, a target ray set of sampling point A is formed.
[0074] Step S23: Obtain the angle value of each target ray in the target ray set in the local coordinate system, and then record the intersection position information of each target ray and the target icon in the predefined data table in ascending order of the angle value for each target ray set.
[0075] In this embodiment, when a ray intersects the target icon, relevant data can be recorded. First, it is necessary to obtain the angle value of each target ray in the target ray set in the local coordinate system. In this embodiment, it is stipulated that the vertically upward direction is the initial direction, that is, the position where 0 degrees is located, and the included angle between the ray direction and the initial direction in the clockwise direction is used as the angle value of each target ray in the local coordinate system; then, in the predefined data table, record the intersection position information of each target ray and the target icon in ascending order of the angle value. Among them, the above intersection position information is the position of each intersection point relative to the center of the circle. After the above processing is performed on all sampling points, the pre-calculation data of this irregular figure can be obtained, and the corresponding quick reference table can be obtained through the above predefined data table. It can be understood that the amount of data in the quick reference table depends on the values of the precision values α and β. The larger the precision value, the more data, but the more accurate the result of the predicted second target intersection. In actual situations, the precision values α and β can be set according to specific needs. In this way, the target icon has been described as an enclosing circle, many sampling points on the enclosing circle, and rays on the sampling points. By obtaining the quick reference table through the above graphic processing method, the second target intersection between the target line segment and the target icon can be calculated more quickly in real time subsequently. In addition, the above pre-calculation process can also be completed by means of an external rectangle.
[0076] Step S24: Determine the line segment between the preset coordinate point on the electronic drawing board and the center of the enclosing circle to obtain the target line segment, determine the first target intersection of the target line segment and the enclosing circle, and then obtain two sampling points adjacent to the first target intersection from all the sampling points.
[0077] In this embodiment, in the process of determining the line segment between the preset coordinate point on the electronic drawing board and the center of the enclosing circle to obtain the target line segment, it further includes: obtaining the angle size of the target line segment in the local coordinate system based on the position coordinates of the preset coordinate point and the position coordinates of the center of the circle. It can be understood that, as Figure 8As shown in the figure, assume that the coordinates of the preset coordinate point on the electronic drawing board are P(x1, y1), and the coordinates of the center position of the circumscribing circle are (x2, y2). Then the vector from point P to the center can be denoted as a(x2 - x1, y2 - y1). According to vector a, the angle of this vector in the two-dimensional coordinate system can be obtained and denoted as θ. Assume that the intersection point of this line and the circle is A. Two sampling points closest to point A can be found through angle θ. Since the previously set precision value α represents the number of preset sampling points, the sampling points on the circle will be at positions such as 360 / α, 2*360 / α... α*360 / α. θ is an angle between 0 and 360. Therefore, through sorting, the two closest sampling points are found. Assume the angles are α1 and α2, then these are the two closest sampling points.
[0078] Step S25: Screen out the first target ray set and the second target ray set corresponding to the two sampling points respectively from the data table, and determine two target rays corresponding to two angle values with similar angle magnitudes from the first target ray set and the second target ray set respectively.
[0079] In this embodiment, since the target ray set where each sampling point intersects with the target icon has been recorded in the data table, the first target ray set and the second target ray set corresponding to the two sampling points are screened out from the data table. Since vector a can definitely intersect with the target icon, angle θ must be sandwiched among these rays. Assume that for α1, there are two rays α 11 and α 12 that are closest to θ, and α 11 < θ < α 12 .
[0080] Step S26: Obtain the first intersection position information between the two target rays in the first target ray set and the target icon from the data table, and obtain the second intersection position information between the two target rays in the second target ray set and the target icon from the data table.
[0081] In this embodiment, since the intersection position information between each target ray in the target ray set and the target icon has been recorded in the data table, the first intersection position information between the two target rays in the first target ray set and the target icon is obtained from the data table, and the second intersection position information between the two target rays in the second target ray set and the target icon is obtained from the data table.
[0082] Step S27: Based on the first intersection position information and the second intersection position information respectively, and using the interpolation algorithm to predict the corresponding third target intersection and fourth target intersection, and then using the interpolation algorithm to interpolate the third target intersection and the fourth target intersection, so as to obtain the prediction result of the second target intersection between the target line segment and the target icon, and draw and display the line segment between the preset coordinate point and the first target intersection and the line segment between the first target intersection and the second target intersection on the electronic drawing board.
[0083] In this embodiment, taking the two intersection positions P 11 and P 12 in the first intersection position information as an example, assuming that the coordinates of P 11 are (x 11 , y 11 ), and the position coordinates of P 12 are (x 12 , y 12 ), then based on these two coordinates, the corresponding third target intersection Q1 between α1 and the target icon can be predicted. The linear interpolation of P 11 and P 12 can be used to obtain the coordinates of Q1 as [x 11 *(α 12 -θ)+x 12 *(θ-α 11 ), y 11 *(α 12 -θ)+y 12 *(θ-α 11 )]. Similarly, the corresponding fourth target intersection Q2 between α1 and the target icon can be predicted according to the above method. Then continue to use the interpolation algorithm to interpolate the third target intersection and the fourth target intersection to obtain the prediction result of the second target intersection between the target line segment and the target icon. Finally, the coordinates of the second target intersection Q predicted by the interpolation algorithm can be recorded as [Q 1x *(α2-θ)+Q 2x *(θ-α1), Q 1y *(α2-θ)+Q 2y *(θ-α1)]. Where Q 1x and Q 1y represent the abscissa and ordinate of Q1 respectively, and Q 2x and Q 2y represent the abscissa and ordinate of Q2 respectively. Finally, draw and display the line segment between the preset coordinate point and the first target intersection and the line segment between the first target intersection and the second target intersection on the electronic drawing board. The drawn graph can be seen as shown in Figure 9 .
[0084] It can be seen that in the embodiment of the present application, it is necessary to emit rays around each of the sampling points at a preset angle, and screen out the target rays intersecting with the target icon to obtain a set of target rays. Then, the angle values of each of the target rays in the local coordinate system in the set of target rays are obtained, and in a predefined data table, the intersection position information of each of the target rays and the target icon in the set of target rays is recorded in ascending order of the angle values. Through this method, pre-computation is completed, that is, a target icon is described as an enclosing circle, many sampling points on the enclosing circle, and rays on the sampling points, and the relevant parameter information is recorded in the data table. When the target line segment is determined, two adjacent sampling points are obtained according to the first target intersection of the target line segment and the enclosing circle, and the first intersection position information between two target rays in the first set of target rays and the target icon is obtained from the data table, and the second intersection position information between two target rays in the second set of target rays and the target icon is obtained. Then, based on the first intersection position information and the second intersection position information respectively, the interpolation algorithm is used to predict the corresponding third target intersection and fourth target intersection, and then the interpolation algorithm is used to interpolate the third target intersection and the fourth target intersection to obtain the prediction result of the second target intersection between the target line segment and the target icon, and the line segment between the preset coordinate point and the first target intersection and the line segment between the first target intersection and the second target intersection are drawn and displayed on the electronic drawing board. In this way, through pre-computation, the graph can be processed in advance according to the accuracy values α and β to obtain the corresponding quick look-up table data, so that when calculating the second target intersection between the target line segment and the target icon in real time later, the position of the second target intersection can be calculated as quickly and accurately as possible.
[0085] See Figure 10 As shown in the figure, the embodiment of the present application discloses a graphic processing device, including:
[0086] A sampling module 11, configured to determine an enclosing circle corresponding to a target icon on the electronic drawing board, and sample the enclosing circle according to a preset number of sampling points to obtain a corresponding number of sampling points;
[0087] A parameter determination module 12, configured to determine a line segment between a preset coordinate point on the electronic drawing board and the center of the enclosing circle to obtain a target line segment, and determine a first target intersection of the target line segment and the enclosing circle;
[0088] A sampling point acquisition module 13, configured to obtain two sampling points adjacent to the first target intersection from all the sampling points;
[0089] A prediction module 14, configured to predict a second target intersection between the target line segment and the target icon based on the two sampling points;
[0090] A drawing module 15 is configured to draw and display a line segment between the preset coordinate point and the first target intersection point and a line segment between the first target intersection point and the second target intersection point on the electronic drawing board.
[0091] It can be seen that in this application, the circumcircle corresponding to the target icon on the electronic drawing board is first determined, and the circumcircle is sampled according to the preset number of sampling points to obtain a corresponding number of sampling points; then the line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle is determined to obtain the target line segment, and the first target intersection point between the target line segment and the circumcircle is determined; then two sampling points adjacent to the first target intersection point are obtained from all the sampling points; finally, the second target intersection point between the target line segment and the target icon is predicted based on the two sampling points, and the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point are drawn and displayed on the electronic drawing board. Thus, it can be seen that in this application, the circumcircle corresponding to the target icon on the electronic drawing board is first determined, and the target line segment is determined based on the preset coordinate point, and the first target intersection point between the target line segment and the circumcircle is determined, and then two sampling points adjacent to the first target intersection point are obtained from the sampling points obtained by pre-sampling the circumcircle, so as to predict the second target intersection point between the target line segment and the target icon based on the two sampling points. Through the above technical solution, the intersection point between the target line segment and the target icon can be predicted more accurately, so as to draw and display the connection line between the preset coordinate point outside the circumcircle and the target icon on the electronic drawing board based on the intersection point.
[0092] Figure 11 FIG. is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the graphic processing method executed by the electronic device disclosed in any of the foregoing embodiments.
[0093] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of the present application, and no specific limitation is made here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.
[0094] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for the rendering and drawing of the content to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computing operations related to machine learning.
[0095] In addition, the memory 22, as a carrier for resource storage, may be a read-only memory, a random access memory, a disk, or an optical disc, etc. The resources stored thereon include an operating system 221, a computer program 222, data 223, etc., and the storage method may be transient storage or permanent storage.
[0096] Among them, the operating system 221 is used to manage and control each hardware device and the computer program 222 on the electronic device 20, so as to implement the operation and processing of the massive data 223 in the memory 22 by the processor 21. It may be Windows, Unix, Linux, etc. In addition to the computer program that can be used to complete the graphic processing method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program that can be used to complete other specific tasks. In addition to the data transmitted by external devices received by the electronic device, the data 223 may also include data collected by its own input / output interface 25, etc.
[0097] Furthermore, the embodiments of the present application also disclose a computer-readable storage medium. When the computer program stored in the storage medium is loaded and executed by a processor, the method steps executed during the graphic processing disclosed in any of the foregoing embodiments are implemented.
[0098] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.
[0099] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this document can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0100] The steps of the methods or algorithms described in combination with the embodiments disclosed in this document can be directly implemented by hardware, software modules executed by a processor, or a combination of the two. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0101] Finally, it should also be noted that in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of another identical element in the process, method, article or device including the said element.
[0102] The above has introduced in detail a graphics processing method, apparatus, device and medium provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A graphics processing method, characterized in that, Including: Determine the circumcircle corresponding to the target icon on the electronic drawing board, and sample the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points; Determine the target line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle, and determine the first target intersection point of the target line segment and the circumcircle; Obtain two sampling points adjacent to the first target intersection point from all the sampling points; Predict the second target intersection point between the target line segment and the target icon based on the two sampling points, and draw and display the line segment between the preset coordinate point and the first target intersection point and the line segment between the first target intersection point and the second target intersection point on the electronic drawing board; Wherein, the determining the circumcircle corresponding to the target icon on the electronic drawing board includes: Determine the minimum circumscribed rectangle corresponding to the target icon on the electronic drawing board, and obtain the position parameter information of the minimum circumscribed rectangle; wherein, the position parameter information includes the position coordinates of the upper left corner vertex of the minimum circumscribed rectangle, the width information and the height information; Determine the center position coordinates and the radius size of the circumcircle based on the position parameter information, and determine the circumcircle according to the center position coordinates and the radius size.
2. The graphic processing method according to claim 1, wherein In the process of determining the target line segment by determining the line segment between the preset coordinate point on the electronic drawing board and the center of the circumcircle, it further includes: Obtain the angle size of the target line segment in the local coordinate system based on the position coordinates of the preset coordinate point and the center position coordinates.
3. The graphic processing method according to claim 2, wherein After sampling the circumcircle according to the preset number of sampling points to obtain a corresponding number of sampling points, it further includes: Emit rays around each sampling point at a preset angle, and then screen out the target rays intersecting with the target icon to obtain a target ray set; Obtain the angle values of each target ray in the target ray set in the local coordinate system, and then record the intersection position information of each target ray and the target icon in the predefined data table in ascending order of the angle values for each target ray set.
4. The graphic processing method according to claim 3, wherein The predicting the second target intersection point between the target line segment and the target icon based on the two sampling points includes: Screen out the first target ray set and the second target ray set corresponding to the two sampling points from the data table, and determine two target rays corresponding to two angle values close to the angle size from the first target ray set and the second target ray set respectively; Obtain the first intersection position information between the two target rays in the first target ray set and the target icon from the data table, and obtain the second intersection position information between the two target rays in the second target ray set and the target icon. Based on the first intersection position information and the second intersection position information respectively, and using an interpolation algorithm to predict the corresponding third target intersection and fourth target intersection, and then using the interpolation algorithm to interpolate the third target intersection and the fourth target intersection to obtain the prediction result of the second target intersection between the target line segment and the target icon.
5. The graphic processing method according to claim 1, wherein The determination of the minimum bounding rectangle corresponding to the target icon on the electronic drawing board includes: Determine the starting positions of the boundary lines in the horizontal and vertical directions on the electronic drawing board, and use the unit pixel interval as the current moving interval. Move the boundary line from the starting position towards the target icon to obtain the current position of the boundary line, and determine whether the current position intersects with the target icon; If so, determine the boundary line as the boundary of the minimum bounding rectangle corresponding to the target icon, and obtain the minimum bounding rectangle; if not, expand the current moving interval by a preset multiple to update the current moving interval, and move the boundary line from the current position towards the target icon according to the updated current moving interval to obtain the next position of the boundary line, and then determine whether the next position intersects with the target icon; If not, jump back to the step of expanding the current moving interval by a preset multiple to update the current moving interval until the position where the boundary line is located intersects with the target icon to obtain the minimum bounding rectangle corresponding to the target icon.
6. The graphic processing method according to claim 5, wherein After determining whether the next position intersects with the target icon, it further includes: If the next position intersects with the target icon, determine whether the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is the unit pixel interval; if so, determine the boundary line as the boundary of the minimum bounding rectangle corresponding to the target icon, and obtain the minimum bounding rectangle; If not, control the boundary line to return to the previous position, and reduce the current moving interval by the preset multiple to update the current moving interval, and then move the boundary line from the previous position towards the target icon according to the updated current moving interval to obtain the new next position of the boundary line, and then determine whether the new next position intersects with the target icon; If not, jump back to the step of reducing the current moving interval by the preset multiple to update the current moving interval until the pixel interval between the icon boundary vertex on the target icon on the side where the current boundary line is located and the current boundary line is the unit pixel interval to obtain the minimum bounding rectangle corresponding to the target icon.
7. A graphics processing device, characterized in that, It includes: A sampling module, configured to determine a bounding circle corresponding to the target icon on the electronic drawing board, and sample the bounding circle according to a preset number of sampling points to obtain a corresponding number of sampling points; A parameter determination module, configured to determine a line segment between a preset coordinate point on the electronic drawing board and the center of the bounding circle to obtain a target line segment, and determine a first target intersection between the target line segment and the bounding circle; A sampling point acquisition module, configured to acquire two sampling points adjacent to the first target intersection point from all the sampling points; A prediction module, configured to predict a second target intersection point between the target line segment and the target icon based on the two sampling points; A drawing module, configured to draw and display a line segment between the preset coordinate point and the first target intersection point and a line segment between the first target intersection point and the second target intersection point on the electronic drawing board; Wherein, determining the circumscribed circle corresponding to the target icon on the electronic drawing board includes: Determining the minimum circumscribed rectangle corresponding to the target icon on the electronic drawing board, and acquiring position parameter information of the minimum circumscribed rectangle; wherein, the position parameter information includes the position coordinates of the upper left corner vertex of the minimum circumscribed rectangle, width information, and height information; Determining the center position coordinates and radius size of the circumscribed circle based on the position parameter information, and determining the circumscribed circle according to the center position coordinates and radius size; 8. An electronic device, characterized in that, Including: A memory, configured to store a computer program; A processor, configured to execute the computer program to implement the steps of the graphic processing method according to any one of claims 1 to 6; 9. A computer-readable storage medium, characterized in that, For storing a computer program; wherein, when the computer program is executed by a processor, the steps of the graphic processing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Image-based positioning method and device, electronic equipment and storage medium
CN111680685A
Method for adjusting path angle in layout, computer storage medium and electronic equipment
CN114092599A