A rounded corner drawing method, device, and storage medium

By obtaining the fillet size and graphic parameters of the polygon vertices, accurate elliptical fillets can be automatically drawn, solving the problem of lack of rounded polygon drawing function in existing office software and improving drawing efficiency.

CN113553807BActive Publication Date: 2025-09-23GUANGZHOU KINGSOFT MOBILE TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010331965.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-24
Publication Date
2025-09-23
Estimated Expiration
2040-04-24

AI Technical Summary

Technical Problem

Existing office software lacks the function of drawing rounded polygons, which requires users to perform manual operations and is inefficient.

Method used

By obtaining the fillet size parameters and graphic parameters of each vertex of the polygon, the fillet drawing parameters are determined, including the coordinates of the curve nodes, the coordinates of the control points and the distance of the tangent points, and accurate elliptical fillets are automatically drawn.

Benefits of technology

It realizes the automatic and accurate drawing of rounded polygons, improving the drawing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553807B_ABST
    Figure CN113553807B_ABST
Patent Text Reader

Abstract

A rounded corner drawing method, device, and storage medium, comprising: upon receiving an instruction to round the corners of a selected polygon, obtaining the size parameters of the rounded corners corresponding to each vertex of the selected polygon; determining the rounded corner drawing parameters corresponding to each vertex of the selected polygon based on the obtained rounded corner size parameters and the graphic parameters of the selected polygon; the rounded corner drawing parameters for each vertex include the coordinates of the curve node of the vertex, the coordinates of the control point of the curve, and the distance from the vertex to the tangent point of the rounded corner; and setting and drawing the curve node for each vertex of the selected polygon based on the determined rounded corner drawing parameters, replacing the original angle of the vertex with the drawn elliptical curve; the graphic parameters include the coordinates of each vertex of the selected polygon and the angle parameters of each vertex. This application can achieve automatic and accurate rounded corner drawing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and more particularly to a method, device, and storage medium for drawing rounded corners. Background Art

[0002] When using similar office software such as WPS Office or Microsoft Office, it is sometimes necessary to create rounded polygons. However, existing tools only provide conventional sharp-cornered polygon drawing tools and rounded rectangle drawing tools, and fail to provide functions related to drawing rounded polygons of other shapes (such as rounded hexagons, rounded arrows, etc.). Users can only draw manually, which is often inefficient and takes a lot of users' time. Summary of the Invention

[0003] The present application provides a rounded corner drawing method, device, and storage medium, which can achieve the goal of automatically and accurately drawing rounded corners.

[0004] The present application provides a rounded corner drawing method, device, and storage medium, including, upon receiving an instruction to draw the corner of a selected polygon as a rounded corner, obtaining the size parameters of the rounded corner corresponding to each vertex of the selected polygon; determining the rounded corner drawing parameters corresponding to each vertex of the selected polygon based on the obtained rounded corner size parameters and the graphic parameters of the selected polygon; the rounded corner drawing parameters of each vertex include the coordinates of the curve node of the vertex, the coordinates of the control point of the curve, and the distance from the vertex to the tangent point of the rounded corner; according to the determined rounded corner drawing parameters, setting a curve node for each vertex of the selected polygon and drawing the curve, so as to replace the original angle of the vertex with the drawn curve; the graphic parameters include the coordinates of each vertex of the selected polygon and the angle parameters of each vertex.

[0005] Compared with the related art, the present application obtains the size parameters of the fillet corresponding to each vertex of the selected polygon; determines the fillet drawing parameters corresponding to each vertex of the selected polygon based on the obtained fillet size parameters and the graphic parameters of the selected polygon. The fillet drawing parameters of each vertex include the coordinates of the curve node of this vertex, the coordinates of the control point of the curve, and the distance from this vertex to the tangent point of the fillet, thereby realizing automatic and accurate drawing of elliptical fillets.

[0006] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. Other advantages of the present application can be realized and obtained by the solutions described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.

[0008] Figure 1 This is a flow chart of the rounded corner drawing method according to an embodiment of the present application;

[0009] Figure 2 This is a schematic diagram of the elliptical fillet size parameters obtained in the embodiment of the present application;

[0010] Figure 3 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 1 ;

[0011] Figure 4 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 2 ;

[0012] Figure 5 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 3 ;

[0013] Figure 6 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 4 ;

[0014] Figure 7 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 5 ;

[0015] Figure 8 This application shows the process of drawing elliptical rounded corners on polygon vertices Figure 6 ;

[0016] Figure 9 A flowchart of a portion of the computer processing for drawing elliptical rounded corners on polygon vertices in this application;

[0017] Figure 10 This is another flowchart of the computer processing for drawing elliptical rounded corners on polygon vertices in this application. DETAILED DESCRIPTION

[0018] This application describes multiple embodiments, but this description is exemplary rather than restrictive, and it will be apparent to those skilled in the art that more embodiments and implementations may be included within the scope of the embodiments described herein. Although many possible feature combinations are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.

[0019] This application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features, and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive solution defined by the claims. Any features or elements of any embodiment may also be combined with features or elements from other inventive solutions to form another unique inventive solution defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in this application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the appended claims and their equivalents, the embodiments are not subject to other limitations. In addition, various modifications and changes may be made within the scope of protection of the appended claims.

[0020] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps in the specific order described. As one of ordinary skill in the art will understand, other orders of steps are also possible. Therefore, the specific order of the steps set forth in the specification should not be interpreted as a limitation on the claims. In addition, the claims for the method and / or process should not be limited to performing their steps in the order written, and those skilled in the art can readily understand that these orders can be changed and still remain within the spirit and scope of the embodiments of the present application.

[0021] like Figure 1 , as shown in FIG, a method for drawing rounded corners includes the following operations:

[0022] S1. Upon receiving an instruction to round the corners of a selected polygon, obtaining a size parameter of the rounded corner corresponding to each vertex of the selected polygon;

[0023] S2. Determine fillet drawing parameters corresponding to each vertex of the selected polygon based on the obtained fillet size parameters and the graphic parameters of the selected polygon; the fillet drawing parameters for each vertex include the coordinates of the curve node of the vertex, the coordinates of the control point of the curve, and the distance from the vertex to the fillet tangent point;

[0024] S3. According to the determined rounded corner drawing parameters, a curve node is set for each vertex of the selected polygon and the curve is drawn, so that the original corner of the vertex is replaced by the drawn curve;

[0025] The graphic parameters include the coordinates of each vertex of the selected polygon and an angle parameter of each vertex.

[0026] The size parameters of the above-mentioned elliptical fillets refer to the radius or diameter of the tangent circle with equal radius drawn for each vertex, which is generally the major axis and minor axis of the non-elliptical fillet; but in extreme cases, such as when α = 90 degrees, the elliptical fillet is actually a circular fillet with equal radius or diameter.

[0027] like Figure 2 As shown, an elliptical fillet is drawn for a vertex of the polygon, and r is actually the radius of the circle tangent to both sides of the vertex.

[0028] In an exemplary embodiment, the angle parameters of each vertex include: an angle α between two line segments connected to the vertex and a relative angle β from the vertex to the next adjacent vertex.

[0029] In an exemplary embodiment, the angle α between the two line segments connected by the vertex is obtained in the following manner:

[0030] CP1B1X, obtain the coordinates of the current vertex (x1, y1), the coordinates of the adjacent previous vertex (x0, y0), and the coordinates of the adjacent next vertex (x2, y2) of the selected polygon, and use a first predetermined formula to determine the length n0 of the line segment connecting the current vertex and the adjacent previous vertex, the length n1 of the line segment connecting the current vertex and the adjacent next vertex, and the length a of the line segment connecting the adjacent previous vertex and the adjacent next vertex;

[0031] In an exemplary embodiment, the first predetermined formula is: n0=((x1-x 0) 2 +(y1-y0) 2 ) 0.5 ; n1=((x2-x 1) 2 +(y2-y1) 2 ) 0.5 ; a=[(x2-x0) 2 +(y2-y0)2 ] 0.5 ;

[0032] M2, using a second predetermined formula to determine the angle α between the two sides connected to the current vertex based on the determined length n0 of the line segment connecting the current vertex and the adjacent previous vertex, the length n1 of the line segment connecting the current vertex and the adjacent next vertex, and the length a of the line segment connecting the adjacent previous vertex and the adjacent next vertex;

[0033] In an exemplary embodiment, the second predetermined formula is: α=Arccos((n1 2 +n0 2 -a 2 ) / 2n1n0).

[0034] In an exemplary embodiment, the relative angle β from the current vertex to the next adjacent vertex is obtained in the following manner:

[0035] Determine the relative angle β between the current vertex and the next adjacent vertex using a third predetermined formula based on the coordinates of the current vertex and the next adjacent vertex;

[0036] In an exemplary embodiment, the third predetermined formula is: β=Arctan(a / b); wherein, a=y2-y1, b=x2-x1; x1 represents the horizontal coordinate of the current vertex; x2 represents the horizontal coordinate of the next adjacent vertex; y1 represents the vertical coordinate of the current vertex; y2 represents the horizontal coordinate of the next adjacent vertex.

[0037] In an exemplary embodiment, determining the rounding parameters for drawing the rounded corners according to the acquired size parameters of the elliptical rounded corners corresponding to the circular rounded corners and the graphic parameters of the selected polygon in operation S2 includes:

[0038] Perform the following operations on each vertex and the next adjacent vertex:

[0039] The coordinates of the curve nodes CP1 and CP2 of the current vertex and the adjacent next vertex located on the line connecting the current vertex and the adjacent next vertex are determined using a fourth predetermined formula based on the obtained fillet radius r, the coordinates of the current vertex (x1, y1), the length c of the connecting line segment from the current vertex P1 to the adjacent next vertex, the relative angle β between the current vertex P1 and the adjacent next vertex, the distance between the current vertex and the fillet tangent point, and the relative positional relationship between the current vertex and the adjacent next vertex.

[0040] In an exemplary embodiment, the fourth predetermined formula includes: a calculation formula for the curve nodes of the current vertex and the next adjacent vertex;

[0041] When a is greater than or equal to zero, the calculation formula of the abscissa CP1x of the curve node of the current vertex is adopted: CP1x=x1+R×|Cos(α)|, to obtain the abscissa CP1x of the curve node of the current vertex; the calculation formula of the abscissa CP2x of the curve node of the next adjacent vertex is adopted: CP2x=x1+(cR)×|Cos(α)|, to obtain the abscissa CP2x of the curve node of the next adjacent vertex;

[0042] When b is greater than or equal to zero, the calculation formula of the ordinate CP1y of the curve node of the current vertex is adopted: CP1y=y1+R×|Sin(α)|, to obtain the ordinate CP1y of the curve node of the current vertex; the calculation formula of the ordinate CP2y of the curve node of the next adjacent vertex is adopted: CP2y=y1+(cR)×|Sin(α)|, to obtain the ordinate CP2y of the curve node of the next adjacent vertex;

[0043] When a is less than zero, the abscissa CP1x of the curve node of the current vertex is calculated using the formula: CP1x = x1-R×|Cos(α)| to obtain the abscissa CP1x of the curve node of the current vertex; the abscissa CP2x of the curve node of the next adjacent vertex is calculated using the formula: CP2x = x1-(cR)×|Cos(α)| to obtain the abscissa CP2x of the curve node of the next adjacent vertex;

[0044] When b is less than zero, the calculation formula for the vertical coordinate CP1y of the curve node of this vertex is used: CP1y=y1-R×|Sin(α)|, to obtain the vertical coordinate CP1y of the curve node of this vertex; the calculation formula for the vertical coordinate CP2y of the curve node of the next adjacent vertex is used: CP2y=y1+(cR)×|Sin(α)|, to obtain the vertical coordinate CP2y of the curve node of the next adjacent vertex.

[0045] In an exemplary embodiment, determining the fillet drawing parameter corresponding to each vertex of the selected polygon according to the obtained specified fillet drawing distance and the graphic parameters of the selected polygon includes:

[0046] Perform the following operations on each vertex:

[0047] According to the obtained fillet radius r, the vertex coordinates (x 1,y1), the relative angle β from each vertex to the next adjacent vertex, and the relative position relationship from each vertex to the next adjacent vertex, and the fifth predetermined formula is used to determine the coordinates of the control points of the current vertex and the curve of the next adjacent vertex located on the connecting line between the current vertex and the next adjacent vertex, wherein one of the two control points corresponding to the current vertex is located at the center point of the connecting line between the current vertex and the corresponding curve node; one of the two control points corresponding to the next adjacent vertex is located at the center point of the connecting line between the next adjacent vertex and the corresponding curve node.

[0048] The present application can draw elliptical rounded corners by determining the position relationship between the control point position of the curve and the corresponding vertex and the corresponding curve node.

[0049] In an exemplary embodiment, the predetermined fifth formula includes a control point calculation formula for a curve of a current vertex and an adjacent next vertex;

[0050] When a is greater than or equal to zero, the calculation formula of the abscissa CP1B1x of the first control point of the curve of this vertex is adopted: CP1B1x=x1+(R×0.5)×|Cos(α)|, and the abscissa CP1B1x of the first control point of the curve of this vertex is obtained; the calculation formula of the abscissa CP1B2x of the second control point of the curve of this vertex is adopted: CP1B2x=x1-(R×0.5)×|Cos(α)|, and the abscissa CP1B2x of the second control point of the curve of this vertex is obtained; the adjacent The calculation formula for the abscissa CP2B1x of the first control point of the curve of the next vertex is: CP2B1x = x1 + (cR × 1.5) * |Cos(α)|, and the abscissa CP2B1x of the first control point of the curve of the next adjacent vertex is obtained. The calculation formula for the abscissa CP2B2x of the second control point of the curve of the next adjacent vertex is: CP2B2x = x1 - (cR × 1.5) * |Cos(α)|, and the abscissa CP2B2x of the second control point of the curve of the next adjacent vertex is obtained.

[0051] When a is less than zero, the calculation formula of the abscissa CP1B1x of the first control point of the curve of this vertex is adopted: CP1B1x=x1-(R×0.5)×|Cos(α)|, and the abscissa CP1B1x of the first control point of the curve of this vertex is obtained; the calculation formula of the abscissa CP1B2x of the second control point of the curve of this vertex is adopted: CP1B2x=x1+(R×0.5)×|Cos(α)|, and the abscissa CP1B2x of the second control point of the curve of this vertex is obtained; the calculation formula of the abscissa CP1B1x of the second control point of the curve of this vertex is adopted: The calculation formula for the abscissa CP2B1x of the first control point of the curve of the next vertex is: CP2B1x=x1-(cR×1.5)*|Cos(α)|, and the abscissa CP2B1x of the first control point of the curve of the next adjacent vertex is obtained; the calculation formula for the abscissa CP2B2x of the second control point of the curve of the next adjacent vertex is: CP2B2x=x1+(cR×1.5)*|Cos(α)|, and the abscissa CP2B2x of the second control point of the curve of the next adjacent vertex is obtained;

[0052] When b is greater than or equal to zero, the calculation formula of the ordinate CP1B1y of the first control point of the curve of this vertex is used: CP1B1y=y1+(R×0.5)×|Sin(α)| to obtain the ordinate CP1B1y of the first control point of the curve of this vertex; the calculation formula of the ordinate CP1B2y of the second control point of the curve of the next adjacent vertex is used: CP1B2y=y1-(R×0.5)×|Sin(α)| to obtain the ordinate CP1B2 of the second control point of the curve of the next adjacent vertex y; the calculation formula of the first control point ordinate CP2B1y of the curve of the next adjacent vertex is used: CP2B1y=y1+(cR×1.5)×|Sin(α)|, to obtain the first control point ordinate CP2B1y of the curve of the next adjacent vertex; the calculation formula of the second control point ordinate CP2B2y of the curve of the next adjacent vertex is used: CP2B2y=y1-(cR×1.5)×|Sin(α)|, to obtain the second control point ordinate CP2B2y of the curve of the next adjacent vertex.

[0053] When b is less than zero, the calculation formula for the ordinate CP1B1x of the first control point of the curve of this vertex is adopted: CP1B1x = y1-(R×0.5)×|Sin(α)|, to obtain the ordinate CP1B1x of the first control point of the curve of this vertex; the calculation formula for the ordinate CP1B2y of the second control point of the curve of this vertex is adopted: CP1B2y = y1+(R×0.5)×|Sin(α)|; the calculation formula for the first control ordinate CP2B1y of the curve of the next adjacent vertex is adopted: CP2B1y = y1-(cR×1.5)×|Sin(α)|, to obtain the first control ordinate CP2B1y of the curve of the next adjacent vertex; the calculation formula for the second control point ordinate CP2B2y of the curve of the next adjacent vertex is adopted: CP2B2y = y1+(cR×1.5)×|Sin(α)|, to obtain the second control point ordinate CP2B2y of the curve of the next adjacent vertex.

[0054] In an exemplary embodiment, the length of the connecting line segment from the current vertex to the next adjacent vertex is obtained in the following manner:

[0055] Determine the length c of the connecting line segment from the current vertex to the next adjacent vertex using a predetermined sixth formula according to the coordinates of the current vertex and the next adjacent vertex;

[0056] In an exemplary embodiment, the predetermined sixth formula is: c=((x2-x1)2+(y2-y1) 2 ) 0.5 .

[0057] In an exemplary embodiment, the distance t from the vertex to the fillet tangent point is obtained as follows:

[0058] Determine the distance t from the vertex to the fillet tangent point using a seventh predetermined formula based on the obtained fillet radius r and the angle α between the two sides connected to the vertex;

[0059] In an exemplary embodiment, the seventh predetermined formula is: t=r / tan(α / 2).

[0060] like Figure 3-9 As shown, the drawing principle and computer processing process embodiment of the equal radius fillet or equal cross-section fillet of the present application are described in detail as follows, taking a pentagon as an example:

[0061] The program will traverse each vertex of the polygon selected by the user, and use the vertical and horizontal coordinates of each vertex to calculate the length n of the line segment between each vertex and the next vertex (the relative distance between the two vertices) using geometric formulas, for example Figure 3 As shown, the distance calculation principle from vertex P1 to vertex P2 is:

[0062] The horizontal coordinate x1 and vertical coordinate y1 of P1 are known, and the horizontal coordinate x2 and vertical coordinate y2 of P2 are also known; then the length of line segment l is y2-y1, and the length of line segment m is x2-x1; according to the relationship between the lengths of the sides of a right triangle: the square of the hypotenuse = the sum of the squares of the two right-angled sides, when the lengths of the two right-angled sides are known, the length of the hypotenuse can be calculated according to the formula, which is n=(l 2 +m 2 ) 0.5 , the formula for converting to the coordinates of two rectangular points is: n=((x2-x1) 2 +(y2-y1) 2 ) 0.5 .

[0063] The length of the line segment from each vertex to the next vertex can be calculated. Then, by using trigonometric functions and the law of cosines, the angle between the two line segments connected to each vertex (that is, the convex or concave angle where the vertex is located) can be calculated. Figure 4 In the calculation method of angle α, the angle α is:

[0064] Calculate the distance a from P0 to P2 using the formula: a = [(x2-x0) 2 +(y2-y0) 2 ] 0.5 ; Calculate the angle α, the calculation formula is: α=Arccos((n1 2 +n0 2 -a 2 ) / 2n1n0).

[0065] After calculating the degree of α, we can use α to calculate the distance from the point of tangency to the vertex P1 when the circle with radius r and the two sides of this angle are tangent. This tangent point will be used as the vertex CP of the new figure. Figure 5 As shown, the calculation formula of the distance t from the midpoint P1 to the tangent point CP1 is: t=r / tan(α / 2).

[0066] Then use the vertical and horizontal coordinates of each vertex to calculate the relative angle from each vertex to the next vertex, for example Figure 6 , the relative angle α from P1 to P2 (which can be understood as the inclination angle of line segment c) is calculated as: β = Arctan (l / m).

[0067] Then calculate the vertical and horizontal coordinates of the corresponding fillet vertex of each vertex, such as Figure 7As shown, the horizontal coordinate x of the fillet vertex CP1 is x = x1 ± R × |Cos(β)|, and the vertical coordinate y is y1 ± R × |Sin(β)|; the horizontal coordinate x of CP2 is x = x1 ± (cR) * |Cos(β)|, and the vertical coordinate y = y1 ± (cR) × |Sin(β)|; in the previous four formulas, the "±" symbol represents addition or subtraction. Whether to use addition or subtraction needs to be judged based on the relative position relationship between P1 and P2 (i.e., whether x2-x1 and y2-y1 are greater than or equal to 0, i.e., whether b and a are greater than or equal to 0 as mentioned above). The judgment logic is as follows:

[0068] If b is greater than or equal to 0, the calculation formula for the CP1 horizontal coordinate is x=x1+R×|Cos(β)|, and the calculation formula for the CP2 horizontal coordinate is x=x1+(cR)*|Cos(β)|; otherwise, the calculation formula for the CP1 horizontal coordinate is x=x1-R×|Cos(β)|, and the calculation formula for the CP2 horizontal coordinate is x=x1-(cR)*|Cos(β)|;

[0069] If a is greater than or equal to 0, the calculation formula for the ordinate of CP1 is y=y1+R×|Sin(β)|, and the calculation formula for the ordinate of CP2 is y=y1+(cR)×|Sin(β)|; otherwise, the calculation formula for the ordinate of CP1 is y=y1-R×|Sin(β)|, and the calculation formula for the ordinate of CP2 is y=y1-(cR)×|Sin(β)|.

[0070] Then calculate the vertical and horizontal coordinates of the first and second control points of the fillet vertices CP1 and CP2 on the line from each vertex to the next vertex, such as Figure 7 As shown in the figure, the calculation method for the first and second control points of CP1 and CP2 is:

[0071] The first control point B1 of CP1 has a horizontal coordinate x = x1 ± (R × 0.5) × |Cos(β)| and a vertical coordinate y = y1 ± (R × 0.5) × |Sin(β)|;

[0072] The second control point B2 of CP1 has a horizontal coordinate x = x1 ± (R × 1.5) × |Cos(β)| and a vertical coordinate y = y1 ± (R × 1.5) × |Sin(β)|;

[0073] The first control point B1 of CP2 has a horizontal coordinate x=x1±(cR×1.5)*|Cos(β)| and a vertical coordinate y=y1±(cR×1.5)×|Sin(β)|;

[0074] The second control point B2 of CP2 has a horizontal coordinate x=x1±(cR×0.5)*|Cos(β)| and a vertical coordinate y=y1±(cR×0.5)×|Sin(β)|;

[0075] In the formulas for calculating the curve nodes and control points, the "±" symbol indicates addition or subtraction, and the logic used is the same as the judgment logic for calculating the vertical and horizontal coordinates of CP1 and CP2.

[0076] After calculating the vertical and horizontal coordinates of the rounded corner vertices and their control points on the line segment from each vertex to the next vertex, use these rounded corner vertex coordinates to create a new graphic at the corresponding coordinates in the document, and add a graphic node at each rounded corner vertex coordinate. Then, adjust the positions of the first and second control points of the node according to the coordinates of the first and second control points of the corresponding rounded corner vertex. Finally, a new polygonal graphic will be obtained, and the corners of the new polygon will be rounded.

[0077] An embodiment of the present application provides a device for drawing rounded corners, including a processor and a memory, wherein the memory stores a program for drawing rounded corners; the processor is used to read the program for drawing rounded corners and execute any of the methods described above.

[0078] An embodiment of the present application provides a computer storage medium having a computer program stored thereon, wherein the computer program implements any of the methods described above when executed by a processor.

[0079] Those skilled in the art will appreciate that the above formula may have other situations by adopting mathematical changes, which are not limited here.

[0080] like Figure 8 、 Figure 9 As shown, the computer processing example of the rounded corner drawing method of the present application includes the following operations:

[0081] M1: The user selects polygon S and initiates a command to draw a rounded polygon;

[0082] M2: Call up the preset parameter setting interface, and the user enters the fillet radius value r;

[0083] M3: Traverse all vertices of S (P1 will be used to represent the vertex pointed to by the current loop, P0 will be used to represent the previous vertex, P2 will be used to represent the next vertex, and P3 will be used to represent the next vertex) and execute the following steps M4-M25;

[0084] M4: Get the horizontal coordinate x1 and vertical coordinate y1 of P1, get the horizontal coordinate x0 and vertical coordinate y0 of P0, get the horizontal coordinate x2 and vertical coordinate y2 of P2, get the horizontal coordinate x3 and vertical coordinate y3 of P3;

[0085] M5: Calculate the angle α1 formed by the lines connecting the three vertices P0, P1, and P2 (that is, the angle where the vertex P1 is located). The formula is:

[0086] M6: Calculate the distance t1 between the tangent point CP1 on P1 and P2 (i.e., the fillet control point) when the circle with radius r is tangent to the line segments P0 to P1 and P1 to P2. The calculation formula is: t1 = r ÷ tan(α1 ÷ 2);

[0087] M7: Calculate the angle α2 formed by the lines connecting the three vertices P1, P2, and P3 (that is, the angle where the vertex P2 is located). The formula is:

[0088]

[0089] M8: Calculate the distance t2 between the tangent point CP2 on P1 and P2 (i.e., the fillet control point) when the circle with radius r is tangent to the line segments P1 to P2 and P2 to P3. The calculation formula is: t2 = r ÷ tan(α2 ÷ 2);

[0090] M9: Determine whether x2 is greater than or equal to x1; if so, assign variable E = 1; if not, assign variable E to -1;

[0091] M10: Determine whether y2 is greater than or equal to y1; if so, assign variable F = 1; if not, assign variable F to -1;

[0092] M11: Calculate the x-coordinate of the first fillet vertex CP1 on the line segment from P1 to P2. Formula:

[0093] M12: Calculate the y-coordinate value of the first fillet vertex CP1 on the line segment from P1 to P2. Formula:

[0094] M13: Create a graphic path node CP1 at the corresponding coordinates in the document according to the values ​​of x and y;

[0095] M14: Calculate and set the x-coordinate value of the first control point B1 of the fillet vertex CP1. Formula:

[0096] M15: Calculate and set the y-coordinate value of the first control point B1 of the fillet vertex CP1. Formula:

[0097] M16: Calculate and set the x-coordinate value of the second control point B2 of the fillet vertex CP1. Formula:

[0098] M17: Calculate and set the y-coordinate value of the second control point B2 of the fillet vertex CP1. Formula:

[0099] M18: Calculate the x-coordinate of the second fillet vertex CP2 on the line segment from P1 to P2. Formula:

[0100] M19: Calculate the y-coordinate value of the second fillet vertex CP2 on the line segment from P1 to P2. Formula:

[0101] M20: Create a graphic path node CP2 at the corresponding coordinates in the document according to the values ​​of x and y;

[0102] M21: Calculate and set the x-coordinate value of the first control point B1 of the fillet vertex CP2. Formula:

[0103] M22: Calculate and set the y-coordinate value of the first control point B1 of the fillet vertex CP2. Formula:

[0104] M23: Calculate and set the x-coordinate value of the second control point B2 of the fillet vertex CP2. Formula:

[0105] M24: Calculate and set the y-coordinate value of the second control point B2 of the fillet vertex CP2. Formula:

[0106] M25: The next vertex

[0107] M26: Close the new graphics path and generate a new graphics.

[0108] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable, and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media generally embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

Claims

1. A method for drawing rounded corners, used in office software, characterized in that: include: M1: The user selects polygon S and initiates a command to draw a rounded polygon; M2: Call up the preset parameter setting interface, and the user enters the fillet radius value r; M3: Traverse all vertices of S, P1 represents the vertex pointed to by the current loop, P0 represents the previous vertex, P2 represents the next vertex, and P3 represents the next vertex. Execute the following steps M4-M25; M4: Get the horizontal coordinate x1 and vertical coordinate y1 of P1, get the horizontal coordinate x0 and vertical coordinate y0 of P0, get the horizontal coordinate x2 and vertical coordinate y2 of P2, get the horizontal coordinate x3 and vertical coordinate y3 of P3; M5: Calculate the angle α1 formed by the lines connecting the three vertices P0, P1, and P2 (that is, the angle where the P1 vertex is located). The formula is: ; M6: Calculate the distance t1 from the fillet vertex CP1 on P1 to P2 when the circle with radius r is tangent to the line segments P0 to P1 and P1 to P2. The calculation formula is: ; M7: Calculate the angle α2 formed by the lines connecting the three vertices P1, P2, and P3 (that is, the angle where the P2 vertex is located). The formula is: ; M8: Calculate the distance t2 between the fillet vertex CP2 on P1 and P2 when the circle with radius r is tangent to the line segments P1 to P2 and P2 to P3. The calculation formula is: ; M9: Determine whether x2 is greater than or equal to x1; if so, assign variable E = 1; if not, assign variable E to -1; M10: Determine whether y2 is greater than or equal to y1; if so, assign variable F = 1; if not, assign variable F to -1; M11: Calculate the x-coordinate value of the fillet vertex CP1 on the line segment from P1 to P2. Formula: ; M12: Calculate the y-coordinate value of the fillet vertex CP1 on the line segment from P1 to P2. Formula: ; M 13: Create a graphic path node CP1 at the corresponding coordinates of the document according to the values ​​of x and y; M14: Calculate and set the x-coordinate value of the first control point B1 of the fillet vertex CP1. Formula: ; M15: Calculate and set the y-coordinate value of the first control point B1 of the fillet vertex CP1. Formula: ; M16: Calculate and set the x-coordinate value of the second control point B2 of the fillet vertex CP1. Formula: ; M17: Calculate and set the y-coordinate value of the second control point B2 of the fillet vertex CP1. Formula: ; M18: Calculate the x-coordinate of the fillet vertex CP2 on the line segment from P1 to P2. Formula: ; M19: Calculate the y-coordinate value of the fillet vertex CP2 on the line segment from P1 to P2. Formula: ; M20: Create a graphic path node CP2 at the corresponding coordinates in the document according to the values ​​of x and y; M21: Calculate and set the x-coordinate value of the first control point B1 of the fillet vertex CP2. Formula: ; M22: Calculate and set the y-coordinate value of the first control point B1 of the fillet vertex CP2. Formula: ; M23: Calculate and set the x-coordinate value of the second control point B2 of the fillet vertex CP2. Formula: ; M24: Calculate and set the y-coordinate value of the second control point B2 of the fillet vertex CP2. Formula: ; M25: Next vertex.

2. A device for drawing rounded corners, comprising a processor and a memory, characterized in that: The memory stores a program for rounded corner drawing; the processor is configured to read the program for rounded corner drawing and execute the method according to claim 1.

Citation Information

Patent Citations

  • Method for drawing arbitrary arc in mobile terminal

    CN101958001A

  • Bezier curve drawing device, bezier curve drawing method, and recording medium

    US20110199381A1