CN112837394A - Polygon drawing method and device, electronic equipment and readable storage medium - Google Patents
Polygon drawing method and device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN112837394A CN112837394A CN201911166221.5A CN201911166221A CN112837394A CN 112837394 A CN112837394 A CN 112837394A CN 201911166221 A CN201911166221 A CN 201911166221A CN 112837394 A CN112837394 A CN 112837394A
- Authority
- CN
- China
- Prior art keywords
- polygon
- graph
- edges
- width
- side length
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 238000004364 calculation method Methods 0.000 claims description 59
- 238000013507 mapping Methods 0.000 claims description 32
- 238000004891 communication Methods 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 16
- 238000009877 rendering Methods 0.000 claims description 16
- 238000010586 diagram Methods 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/20—Drawing from basic elements, e.g. lines or circles
- G06T11/203—Drawing of straight lines or curves
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Generation (AREA)
Abstract
The embodiment of the invention provides a polygon drawing method, a polygon drawing device, electronic equipment and a readable storage medium, wherein the polygon drawing method comprises the following steps: determining the number of edges of a first graph drawn by a user through a polygon tool; obtaining the side length to be set for the first graph input by a user; calculating the height and width of the polygon meeting the number of edges and the side length; and adjusting the first graph by using the height and the width to obtain a polygon meeting the number of sides and the side length. By applying the polygon drawing method provided by the embodiment of the invention, the polygon with the specified side length can be simply and quickly drawn.
Description
Technical Field
The present invention relates to the field of document processing technologies, and in particular, to a polygon rendering method and apparatus, an electronic device, and a readable storage medium.
Background
Currently, users often need to draw polygons using drawing tools in office software. For example, a user may need to draw a hexagon with a drawing tool.
However, the user cannot directly set the polygon to a polygon of a specified side length. Moreover, the side length of the polygon can only be adjusted slowly by the naked eye or by auxiliary means (e.g., ruler measurement). Therefore, the method for drawing the polygon is time-consuming and labor-consuming, so that the user experience is not good.
Disclosure of Invention
An embodiment of the present invention provides a polygon drawing method, an apparatus, an electronic device, and a readable storage medium, so as to draw a polygon with a specified side length simply and quickly. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a polygon rendering method, which may include:
determining the number of edges of a first graph drawn by a user through a polygon tool;
obtaining the side length to be set for the first graph input by a user;
calculating the height and width of the polygon meeting the number of edges and the side length;
and adjusting the first graph by using the height and the width to obtain a polygon meeting the number of sides and the side length.
Optionally, in this embodiment of the present invention, the step of obtaining the side length to be set for the first graphic, which is input by the user, may include:
displaying a side length input box;
and acquiring the numerical value input into the side length input box by the user as the side length to be set for the first graph.
Optionally, in the embodiment of the present invention, the step of calculating the height and the width of the polygon satisfying the number of sides and the side length may include:
inputting the number of edges and the side length into a circumscribed circle radius calculation formula, and calculating the radius of a circumscribed circle of a polygon meeting the number of edges and the side length;
inputting the number of edges and the radius into a height calculation formula, and calculating the height of the polygon;
when the number of the edges is an odd number, inputting the number of the edges and the radius into a first width calculation formula, and calculating the width of the polygon;
and when the number of the edges is even, inputting the number of the edges, the radius and the height into a second width calculation formula, and calculating the width of the polygon.
Optionally, in the embodiment of the present invention, the height calculation formula may be:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the polygon, w1Is the width of the polygon with odd number of sides, w2The width of the polygon when the number of sides is even; r is the radius of the circumscribed circle, n is the number of edges of the first graph, mod is the remainder operator.
Optionally, in this embodiment of the present invention, when the number of sides is an even number, the step of adjusting the first graph by using the height and the width to obtain a polygon satisfying the number of sides and the side length may include:
under the condition of keeping the number of edges of the first graph unchanged, adjusting the width and the height of the first graph by using the height and the width to obtain a second graph;
under the condition of keeping the number of edges and the width and the height of the second graph unchanged, setting the side length of each edge of the second graph as the side length and setting the angle of each vertex angle of the second graph as the same to obtain a polygon;
the first graphic is replaced with a polygon.
Optionally, in this embodiment of the present invention, the step of setting the length of each side of the second graph as the length of the side and setting each vertex angle of the second graph as the same to obtain the polygon may include:
searching for parameter information of the adjusting points which have a mapping relation with the number of edges in a preset mapping table; the adjusting point parameter information is parameter information used for adjusting the second graph;
and adjusting the adjusting points of the second graph according to the parameter information of the adjusting points so that the side length of each side of the second graph is the side length and the angle of each vertex angle of the second graph is equal to obtain a polygon.
Optionally, in this embodiment of the present invention, the preset mapping table records:
the mapping relation between the number of edges six and the parameter information of the first adjusting point, and the mapping relation between the number of edges eight and the parameter information of the second adjusting point; wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
in a second aspect, an embodiment of the present invention provides a polygon rendering apparatus, which may include:
the determining module is used for determining the number of edges of a first graph drawn by a user through the polygon tool;
the obtaining module is used for obtaining the side length to be set for the first graph input by a user;
the calculation module is used for calculating the height and the width of a polygon meeting the number of edges and the side length;
and the adjusting module is used for adjusting the first graph by using the height and the width to obtain a polygon meeting the number of sides and the side length.
Optionally, in an embodiment of the present invention, the obtaining module may include:
the display unit is used for displaying the side length input box;
and the acquisition unit is used for acquiring the numerical value input into the side length input box by the user as the side length to be set for the first graph.
Optionally, in an embodiment of the present invention, the calculation module includes:
the first calculation unit is used for inputting the number of edges and the side length into a circumscribed circle radius calculation formula and calculating the radius of a circumscribed circle of a polygon meeting the number of edges and the side length;
the second calculation unit is used for inputting the number of edges and the radius into a height calculation formula and calculating the height of the polygon;
the third calculation unit is used for inputting the number of edges and the radius into the first width calculation formula when the number of the edges is an odd number, and calculating the width of the polygon;
and the fourth calculation unit is used for inputting the number of the edges, the radius and the height into the second width calculation formula to calculate the width of the polygon when the number of the edges is an even number.
Optionally, in the embodiment of the present invention, the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the polygon, w1Is the width of the polygon with odd number of sides, w2The width of the polygon when the number of sides is even; r is the radius of the circumscribed circle, n is the number of edges of the first pattern, mod isAnd (4) taking the remainder operator.
Optionally, in an embodiment of the present invention, the fourth calculating unit includes:
the first adjusting subunit is used for adjusting the width and the height of the first graph by using the height and the width under the condition of keeping the number of edges of the first graph unchanged to obtain a second graph;
the second adjusting subunit is used for setting the side length of each side of the second graph as the side length and setting the angle of each vertex angle of the second graph as the same to obtain a polygon under the condition of keeping the number of sides and the width and the height of the second graph unchanged;
a replacement subunit for replacing the first graphic with the polygon.
Optionally, in an embodiment of the present invention, the second adjusting subunit is specifically configured to:
searching for parameter information of the adjusting points which have a mapping relation with the number of edges in a preset mapping table; the adjusting point parameter information is parameter information used for adjusting the second graph;
and adjusting the adjusting points of the second graph according to the parameter information of the adjusting points so that the side length of each side of the second graph is the side length and the angle of each vertex angle of the second graph is equal to obtain a polygon.
Optionally, in this embodiment of the present invention, the preset mapping table records:
the mapping relation between the number of edges six and the parameter information of the first adjusting point, and the mapping relation between the number of edges eight and the parameter information of the second adjusting point; wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
in a third aspect, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the method steps of any one of the polygon drawing methods when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, where a computer program is stored in the readable storage medium, and when the computer program is executed by a processor, the method steps of any one of the above polygon rendering methods are implemented.
In a fifth aspect, an embodiment of the present invention further provides a computer program product, which when run on an electronic device, causes the electronic device to perform: method steps of any of the above polygon rendering methods.
The polygon drawing method, the polygon drawing device, the electronic device and the readable storage medium provided by the embodiment of the invention can determine the number of edges of a first graph drawn by a user through a polygon tool. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a polygon rendering method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the height h and width w of a hexagon provided by an embodiment of the present invention;
FIG. 3 is a schematic diagram of an adjustment point provided by an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a polygon rendering apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve technical problems in the related art, embodiments of the present invention provide a polygon rendering method, an apparatus, an electronic device, and a readable storage medium.
The electronic device may perform the method steps of the polygon rendering method provided by the embodiment of the present invention. The electronic devices include, but are not limited to, computers, smart phones, and smart wearable devices.
In addition, office software can be installed in the electronic equipment, and a user can draw a graph through a drawing tool in the office software. The office software includes but is not limited to: word software, PPT (PowerPoint, presentation) software, and WPS (WPS software).
Referring to fig. 1, a polygon rendering method provided by an embodiment of the present invention may include the following steps:
s101: determining the number of edges of a first graph drawn by a user through a polygon tool;
when a user wants to draw a polygon with a specified side length, the user can draw a first graph by using a polygon tool. For example, the user may draw a resulting hexagon as the first graphic using a hexagon tool.
The electronic device may then determine the number of edges of the first graphic. For example, the electronic device may determine that the number of edges of the first pattern drawn by the hexagon tool is 6.
The electronic device may record a mapping relationship between the polygon tool and the number of edges. In this way, after the user draws the first graphic through the polygon tool, the electronic device may determine the number of edges corresponding to the polygon tool according to the mapping relationship, so as to determine the number of edges of the first graphic drawn through the polygon tool.
Of course, a margin input box may also be displayed. In this way, it is reasonable that the user can input the number of edges of the first graphic in this edge number input box, so that the electronic device can obtain the number of edges of the first graphic.
In addition, it can be understood that when the user selects the polygon tool and draws the polygon by dragging the mouse, the side length of the drawn polygon is not always the side length desired by the user. For example, a user wants to draw a hexagon with all sides of 5 cm, but the drawn first graph has each side with a length of 5 cm and is different from each other.
S102: obtaining the side length to be set for the first graph input by a user;
wherein, the electronic equipment can display a side length input box. The user may input a value of the side length the user wants to set for the first graphic in the side length input box. The electronic device, after obtaining the value, may determine the value as a side length to be set for the first graphic.
For example, the user may enter, within a side length input box: the user wants to set a value of 5 cm for each side length for the hexagon.
S103: calculating the height and width of the polygon meeting the number of edges and the side length;
for example, the number of edges obtained may be 6, and the length of the edges obtained may be 5 cm. After obtaining the number of sides and the side length, the electronic device may input the side length and the number of sides to a circumscribed circle radius calculation formula. Thus, the radius of the circumscribed circle of the polygon satisfying the number of sides and the side length can be calculated.
Wherein, the circumscribed circle radius calculation formula can be:
wherein r is the radius of the circumscribed circle of the polygon, l is the side length input by the user, and n is the number of sides of the first graph.
After calculating the radius of the circumscribed circle of the polygon, the electronic device may input the number of edges of the first graph and the radius to a height calculation formula. Thus, the height of the polygon can be calculated. Wherein, the height calculation formula is as follows:
where h is the height of the polygon and mod is the remainder operator.
In addition, when the determined number of edges is an odd number, the electronic device may input the number of edges and the calculated radius to the first width calculation formula. Therefore, the polygon which is externally connected with the circumscribed circle and satisfies the width of the polygon with odd number of sides; wherein the first width calculation formula is:
wherein, w1The width of the polygon calculated when the number of sides is odd.
When the number of sides is an even number, the width of the polygon may be calculated by inputting the number of sides, the radius, and the height to the second width calculation formula. Therefore, the width of the polygon which can be circumscribed to the circumscribed circle and satisfies the even number of sides can be directly calculated based on the second width calculation formula. Wherein the second width calculation formula is:
wherein, w2The width of the polygon calculated when the number of sides is even.
In the above, the height and width of the polygon to be drawn may be calculated based on the number of sides and the length of the sides of the polygon to be drawn and the radius of the circumscribed circle. For example, the height h and width w of the hexagon to be drawn as shown in fig. 2 may be calculated. Wherein the hexagon can circumscribe a circumcircle with radius r.
S104: and adjusting the first graph by using the height and the width to obtain a polygon meeting the number of sides and the side length.
In particular, the first pattern may be adjusted to a pattern that conforms to the height and width. Then, the side length of the first graph can be adjusted to the specified side length input by the user, so that a polygon with the specified side length can be drawn.
When the number of the obtained edges is determined to be even, obtaining a polygon to be drawn by the following method:
the width and height of the first pattern are adjusted by using the height and width while keeping the number of edges of the first pattern constant. That is, the width and height of the first pattern are adjusted to satisfy the height and width, thereby obtaining the second pattern.
And then, under the condition of keeping the number of sides and the width and the height of the second graph unchanged, setting the side length of each side of the second graph as the side length input by a user and setting the angle of each vertex angle of the second graph as equal to obtain a polygon. Thereafter, the polygon may be rendered and the first graphic replaced with the polygon.
Wherein, the side length of each side of the second graph is set as the side length input by the user and the angle of each vertex angle of the second graph is set as equal, and the polygon is obtained by the following steps:
and searching for the parameter information of the adjusting points which have a mapping relation with the edge number in a preset mapping table. And the adjusting point parameter information is parameter information used for adjusting the second graph. Then, the adjustment point of the second graph can be adjusted according to the adjustment point parameter information, so that the side length of each side of the second graph is the side length input by the user, and the angle of each vertex angle of the second graph is equal, thereby obtaining a polygon.
Wherein, the preset mapping table may specifically record: the mapping relationship between the number of edges six and the first adjustment point parameter information, and the mapping relationship between the number of edges eight and the second adjustment point parameter information are, of course, not limited thereto. Wherein the first adjustment point parameter information may be parameter information for adjusting the hexagon to a regular hexagon. The second adjustment point parameter information may be parameter information for adjusting the octagon to a regular octagon.
Wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
the following explains the adjustment points provided by the embodiments of the present invention:
referring to fig. 3, the adjustment point is provided at the position of the upper left vertex of the hexagon shown in fig. 3. And the position of the adjustment point will change with the change of the parameter information of the adjustment point. Wherein one position of the adjustment point corresponds to one adjustment point parameter information. When the adjustment point parameter information of the second graph is set to 0.25/cos30 °, the hexagonal adjustment point may be located at a quarter of the long side of the rectangular dashed box shown in fig. 3, that is, the distance from the position of the adjustment point to the wide side of the rectangular dashed box is a quarter of the long side.
The adjustment point shown in fig. 3 may move left and right on the long side of the rectangular dashed frame where the adjustment point is located when the value of the adjustment point parameter information changes (where the rightmost position may move to the center of the long side). When the adjusting point moves leftwards for a preset distance, the point of the lower left vertex angle of the hexagon also moves leftwards for the preset distance horizontally, and the point of the upper right vertex angle and the point of the lower right vertex angle of the hexagon move rightwards for the preset distance horizontally. In addition, when the adjusting point moves rightwards for a preset distance, the point of the lower left corner of the hexagon also moves rightwards horizontally for the preset distance, and the point of the upper right corner and the point of the lower right corner of the hexagon move leftwards horizontally for the preset distance.
In an embodiment of the invention, the number of edges of a first graphic drawn by a user via a polygon tool may be determined. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
In conclusion, by applying the polygon drawing scheme provided by the embodiment of the invention, the polygon with the specified side length can be simply and quickly drawn, and the user experience is improved.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a polygon rendering apparatus, and referring to fig. 4, the apparatus may include:
a determining module 401, configured to determine the number of edges of a first graph drawn by a user through a polygon tool;
an obtaining module 402, configured to obtain a side length to be set for a first graph, which is input by a user;
a calculating module 403, configured to calculate the height and width of a polygon that satisfies the number of sides and the side length;
and an adjusting module 404, configured to adjust the first graph by using the height and the width to obtain a polygon satisfying the number of edges and the length of the edge.
By applying the device provided by the embodiment of the invention, the number of the edges of the first graph drawn by the user through the polygon tool can be determined. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
Optionally, in this embodiment of the present invention, the obtaining module 402 may include:
the display unit is used for displaying the side length input box;
and the acquisition unit is used for acquiring the numerical value input into the side length input box by the user as the side length to be set for the first graph.
Optionally, in an embodiment of the present invention, the calculating module 403 may include:
the first calculation unit is used for inputting the number of edges and the side length into a circumscribed circle radius calculation formula and calculating the radius of a circumscribed circle of a polygon meeting the number of edges and the side length;
the second calculation unit is used for inputting the number of edges and the radius into a height calculation formula and calculating the height of the polygon;
the third calculation unit is used for inputting the number of edges and the radius into the first width calculation formula when the number of the edges is an odd number, and calculating the width of the polygon;
and the fourth calculation unit is used for inputting the number of the edges, the radius and the height into the second width calculation formula to calculate the width of the polygon when the number of the edges is an even number.
Optionally, in the embodiment of the present invention, the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the polygon, w1Is the width of the polygon with odd number of sides, w2The width of the polygon when the number of sides is even; r is the radius of the circumscribed circle, n is the number of edges of the first graph, mod is the remainder operator.
Optionally, in an embodiment of the present invention, the fourth calculating unit includes:
the first adjusting subunit is used for adjusting the width and the height of the first graph by using the height and the width under the condition of keeping the number of edges of the first graph unchanged to obtain a second graph;
the second adjusting subunit is used for setting the side length of each side of the second graph as the side length and setting the angle of each vertex angle of the second graph as the same to obtain a polygon under the condition of keeping the number of sides and the width and the height of the second graph unchanged;
a replacement subunit for replacing the first graphic with the polygon.
Optionally, in an embodiment of the present invention, the second adjusting subunit is specifically configured to:
searching for parameter information of the adjusting points which have a mapping relation with the number of edges in a preset mapping table; the adjusting point parameter information is parameter information used for adjusting the second graph;
and adjusting the adjusting points of the second graph according to the parameter information of the adjusting points so that the side length of each side of the second graph is the side length and the angle of each vertex angle of the second graph is equal to obtain a polygon.
Optionally, in this embodiment of the present invention, the preset mapping table records:
the mapping relation between the number of edges six and the parameter information of the first adjusting point, and the mapping relation between the number of edges eight and the parameter information of the second adjusting point; wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
corresponding to the above method embodiment, an embodiment of the present invention further provides an electronic device, referring to fig. 5, including a processor 501, a communication interface 502, a memory 503, and a communication bus 504, where the processor 501, the communication interface 502, and the memory 503 complete mutual communication through the communication bus 504;
a memory 503 for storing a computer program;
the processor 501 is configured to implement the method steps of any one of the above polygon rendering methods when executing the program stored in the memory 503.
In an embodiment of the invention, the electronic device may determine a number of edges of a first graphic drawn by a user via a polygon tool. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps of any one of the above polygon rendering methods.
After the computer program stored in the readable storage medium provided by the embodiment of the invention is executed by the processor of the electronic device, the electronic device may determine the number of edges of the first graph drawn by the user through the polygon tool. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer program product, which when run on an electronic device, causes the electronic device to perform: method steps of any of the above polygon rendering methods.
After the computer program product provided by the embodiment of the invention is executed by a processor of the electronic device, the electronic device can determine the number of edges of the first graph drawn by the user through the polygon tool. Also, the side length to be set for the first graphic input by the user may be obtained. Thereafter, the height and width of the polygon satisfying the number of sides and the side length may be calculated. Then, the first graph is adjusted by using the height and the width to obtain a polygon meeting the number of sides and the side length. In this way, the side length of the polygon obtained by drawing is the specified side length. Moreover, the polygon with the specified side length can be simply and quickly drawn.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, the readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (16)
1. A polygon rendering method, comprising:
determining the number of edges of a first graph drawn by a user through a polygon tool;
obtaining the side length to be set for the first graph input by a user;
calculating the height and width of the polygon meeting the number of edges and the side length;
and adjusting the first graph by using the height and the width to obtain the polygon meeting the number of edges and the side length.
2. The method of claim 1, wherein the step of obtaining the user-entered side length to be set for the first graphic comprises:
displaying a side length input box;
and acquiring the numerical value input into the side length input box by the user as the side length to be set for the first graph.
3. The method of claim 1, wherein the step of calculating the height and width of the polygon satisfying the number of sides and the length of the sides comprises:
inputting the number of sides and the side length into a circumscribed circle radius calculation formula, and calculating the radius of a circumscribed circle of a polygon meeting the number of sides and the side length;
inputting the number of edges and the radius into a height calculation formula, and calculating the height of the polygon;
when the number of the edges is an odd number, inputting the number of the edges and the radius into a first width calculation formula, and calculating the width of the polygon;
and when the number of the edges is an even number, inputting the number of the edges, the radius and the height into a second width calculation formula, and calculating the width of the polygon.
4. The method of claim 3, wherein the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the polygon, and w1Is the width of the polygon when the number of sides is odd, w2The width of the polygon when the number of the sides is an even number; the r is the radius of the circumscribed circle, the n is the number of edges of the first graph, and the mod is a remainder operator.
5. The method of claim 1, wherein when the number of sides is an even number, the step of adjusting the first graph using the height and the width to obtain the polygon satisfying the number of sides and the side length comprises:
under the condition of keeping the number of edges of the first graph unchanged, adjusting the width and the height of the first graph by using the height and the width to obtain a second graph;
under the condition of keeping the number of the edges and the width and the height of the second graph unchanged, setting the length of each edge of the second graph as the length of each edge and setting the angle of each vertex angle of the second graph as equal to obtain the polygon;
replacing the first graphic with the polygon.
6. The method of claim 5, wherein the step of setting the side lengths of the second graph as the side lengths and setting the corner angles of the second graph as equal to each other to obtain the polygon comprises:
searching for parameter information of the adjusting points in a preset mapping table, wherein the parameter information of the adjusting points has a mapping relation with the edge number; the adjusting point parameter information is parameter information used for adjusting the second graph;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so as to enable the side length of each side of the second graph to be the side length and the angle of each vertex angle of the second graph to be equal, and obtaining the polygon.
7. The method according to claim 6, wherein the preset mapping table records:
the mapping relation between the number of edges six and the parameter information of the first adjusting point, and the mapping relation between the number of edges eight and the parameter information of the second adjusting point; wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
8. a polygon rendering apparatus, comprising:
the determining module is used for determining the number of edges of a first graph drawn by a user through the polygon tool;
the obtaining module is used for obtaining the side length to be set for the first graph input by a user;
the calculation module is used for calculating the height and the width of a polygon meeting the number of edges and the side length;
and the adjusting module is used for adjusting the first graph by using the height and the width to obtain the polygon meeting the number of the edges and the side length.
9. The apparatus of claim 8, wherein the obtaining module comprises:
the display unit is used for displaying the side length input box;
and the acquisition unit is used for acquiring the numerical value input into the side length input box by the user as the side length to be set for the first graph.
10. The apparatus of claim 8, wherein the computing module comprises:
the first calculation unit is used for inputting the number of edges and the side length into a circumscribed circle radius calculation formula and calculating the radius of a circumscribed circle of a polygon meeting the number of edges and the side length;
the second calculation unit is used for inputting the number of the edges and the radius into a height calculation formula and calculating the height of the polygon;
a third calculation unit, configured to, when the number of edges is an odd number, input the number of edges and the radius into a first width calculation formula, and calculate a width of the polygon;
and the fourth calculation unit is used for inputting the number of the edges, the radius and the height into a second width calculation formula to calculate the width of the polygon when the number of the edges is an even number.
11. The apparatus of claim 10, wherein the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the polygon, and w1Is the width of the polygon when the number of sides is odd, w2The width of the polygon when the number of the sides is an even number; the r is the radius of the circumscribed circle, the n is the number of edges of the first graph, and the mod is a remainder operator.
12. The apparatus of claim 8, wherein the fourth computing unit comprises:
the first adjusting subunit is used for adjusting the width and the height of the first graph by using the height and the width under the condition of keeping the number of edges of the first graph unchanged to obtain a second graph;
the second adjusting subunit is configured to set the side length of each side of the second graph as the side length and set the angle of each vertex angle of the second graph as equal to obtain the polygon, under the condition that the number of sides and the width and the height of the second graph are maintained unchanged;
a replacement subunit configured to replace the first graphic with the polygon.
13. The apparatus according to claim 12, wherein the second adjusting subunit is specifically configured to:
searching for parameter information of the adjusting points in a preset mapping table, wherein the parameter information of the adjusting points has a mapping relation with the edge number; the adjusting point parameter information is parameter information used for adjusting the second graph;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so as to enable the side length of each side of the second graph to be the side length and the angle of each vertex angle of the second graph to be equal, and obtaining the polygon.
14. The apparatus according to claim 13, wherein the preset mapping table records:
the mapping relation between the number of edges six and the parameter information of the first adjusting point, and the mapping relation between the number of edges eight and the parameter information of the second adjusting point; wherein, the first adjusting point parameter information is:
the second adjustment point parameter information is:
15. an electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 7 when executing a program stored in the memory.
16. A readable storage medium, characterized in that a computer program is stored in the readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911166221.5A CN112837394B (en) | 2019-11-25 | 2019-11-25 | Polygonal drawing method and device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911166221.5A CN112837394B (en) | 2019-11-25 | 2019-11-25 | Polygonal drawing method and device, electronic equipment and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112837394A true CN112837394A (en) | 2021-05-25 |
CN112837394B CN112837394B (en) | 2024-06-18 |
Family
ID=75922212
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911166221.5A Active CN112837394B (en) | 2019-11-25 | 2019-11-25 | Polygonal drawing method and device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112837394B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001067485A (en) * | 1999-08-27 | 2001-03-16 | Digital Electronics Corp | Device and method for drawing polygon, and computer- readable recording medium where for program drawing polygon is recorded |
US20070046675A1 (en) * | 2005-08-31 | 2007-03-01 | Fujitsu Limited | Polygonal chart drawing processing method, device and computer-readable medium recording a program of the same |
US20090115786A1 (en) * | 2006-04-24 | 2009-05-07 | Takamasa Shimasaki | Drawing device, and drawing method |
CN103065344A (en) * | 2012-11-30 | 2013-04-24 | 贵州电网公司六盘水供电局 | Drawing method of two dimensional graph |
CN106530228A (en) * | 2016-11-04 | 2017-03-22 | 中科宇图科技股份有限公司 | Vector polygon right-angle correction method |
CN108780572A (en) * | 2017-02-22 | 2018-11-09 | 华为技术有限公司 | The method and device of image rectification |
WO2019088713A1 (en) * | 2017-11-01 | 2019-05-09 | 주식회사 위즈엑스퍼트 | Method and device for drawing figure |
CN110297932A (en) * | 2019-06-28 | 2019-10-01 | 北京金山安全软件有限公司 | Method and device for determining maximum inscribed circle of closed graph in vector diagram and electronic equipment |
-
2019
- 2019-11-25 CN CN201911166221.5A patent/CN112837394B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001067485A (en) * | 1999-08-27 | 2001-03-16 | Digital Electronics Corp | Device and method for drawing polygon, and computer- readable recording medium where for program drawing polygon is recorded |
US20070046675A1 (en) * | 2005-08-31 | 2007-03-01 | Fujitsu Limited | Polygonal chart drawing processing method, device and computer-readable medium recording a program of the same |
US20090115786A1 (en) * | 2006-04-24 | 2009-05-07 | Takamasa Shimasaki | Drawing device, and drawing method |
CN103065344A (en) * | 2012-11-30 | 2013-04-24 | 贵州电网公司六盘水供电局 | Drawing method of two dimensional graph |
CN106530228A (en) * | 2016-11-04 | 2017-03-22 | 中科宇图科技股份有限公司 | Vector polygon right-angle correction method |
CN108780572A (en) * | 2017-02-22 | 2018-11-09 | 华为技术有限公司 | The method and device of image rectification |
WO2019088713A1 (en) * | 2017-11-01 | 2019-05-09 | 주식회사 위즈엑스퍼트 | Method and device for drawing figure |
CN110297932A (en) * | 2019-06-28 | 2019-10-01 | 北京金山安全软件有限公司 | Method and device for determining maximum inscribed circle of closed graph in vector diagram and electronic equipment |
Non-Patent Citations (1)
Title |
---|
沈克祥 等: "AutoCAD 讲座 第五讲 绘图命令(Draw)", 电脑技术, pages 33 - 36 * |
Also Published As
Publication number | Publication date |
---|---|
CN112837394B (en) | 2024-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109271685B (en) | BIM-based urban updating and reconstruction data storage method and device | |
CN109753641B (en) | Method and device for changing object position, electronic equipment and storage medium | |
US9400597B2 (en) | Presenting dynamic grids | |
US10319129B2 (en) | Snapping line generation | |
US20210132743A1 (en) | Interactive Display of Data Distributions | |
CN111414727A (en) | Method and device for editing header and footer of PDF (Portable document Format) document and electronic equipment | |
US9977581B2 (en) | Selection refinement tool | |
CN112558969A (en) | Webpage form generation method, device, equipment and medium | |
CN112784551A (en) | Method, device and equipment for realizing cell and picture adaptation | |
CN112837394B (en) | Polygonal drawing method and device, electronic equipment and readable storage medium | |
US10366518B2 (en) | Extension of text on a path | |
CN112233202B (en) | Regular polygon drawing method and device, electronic equipment and readable storage medium | |
CN112987992B (en) | Navigation element display method and device and electronic equipment | |
CN110019492B (en) | Information display method and device | |
CN111696169A (en) | Method and device for generating equilateral polygon and electronic equipment | |
CN112540961A (en) | Method and device for positioning audio file in document | |
CN111784559B (en) | Graph adjustment method and device | |
CN112784526A (en) | Document page adjusting method and device | |
CN112231316B (en) | Graph display method and device and electronic equipment | |
CN112232046A (en) | Method and device for displaying repeated items of table | |
CN111199144A (en) | Document content altering method and device, electronic equipment and readable storage medium | |
CN112785638A (en) | Graph processing method and device | |
CN111897661A (en) | Method and device for copying cell contents in spreadsheet and electronic equipment | |
CN112181240B (en) | Information display method and device | |
CN111191427A (en) | PDF document annotation method and device and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |