CN114529630A - Method, device and equipment for generating sector primitives and computer readable storage medium - Google Patents
Method, device and equipment for generating sector primitives and computer readable storage medium Download PDFInfo
- Publication number
- CN114529630A CN114529630A CN202210099072.0A CN202210099072A CN114529630A CN 114529630 A CN114529630 A CN 114529630A CN 202210099072 A CN202210099072 A CN 202210099072A CN 114529630 A CN114529630 A CN 114529630A
- Authority
- CN
- China
- Prior art keywords
- fan
- sector
- shaped
- generating
- primitive
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000001960 triggered effect Effects 0.000 claims abstract description 14
- 230000006870 function Effects 0.000 claims description 15
- 238000013506 data mapping Methods 0.000 claims description 10
- 238000009877 rendering Methods 0.000 claims description 7
- 230000004044 response Effects 0.000 claims description 6
- 238000009434 installation Methods 0.000 claims description 5
- 238000012545 processing Methods 0.000 abstract description 3
- 238000004904 shortening Methods 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 9
- 230000000694 effects Effects 0.000 description 6
- 238000004364 calculation method Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000007 visual effect Effects 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Processing Or Creating Images (AREA)
Abstract
The invention discloses a method, a device and equipment for generating a sector primitive and a computer readable storage medium, and belongs to the technical field of data processing. The method is applied to the plug-in unit mounted on the browser, and after detecting that the fan-shaped primitive generation function of the plug-in unit is triggered, fan-shaped drawing parameters which are collected by an operation panel of the plug-in unit and are needed for generating the fan-shaped primitive are obtained, wherein the fan-shaped drawing parameters comprise the radius, the rotation angle and the starting angle of a fan to be drawn; generating a sector graphic primitive according to the sector drawing parameters; and displaying the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements in a display panel of the plug-in, thereby realizing the purposes of quickly generating the fan shape, shortening the fan-shaped debugging time and improving the convenience of fan-shaped drawing.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for generating a sector primitive.
Background
At present, fan-shaped graphs are generally generated by approximately drawing in a mode of dividing a fan into triangles, in an occasion with higher requirement on graph effect, a fan shape can be obtained approximately only by splitting a large number of triangles, and the problems of low drawing efficiency and long time consumption for debugging fan-shaped drawing exist, so that the fan-shaped graphs are inconvenient.
Disclosure of Invention
The invention mainly aims to provide a method, a device and equipment for generating a sector primitive and a computer readable storage medium, and aims to solve the technical problems of long time consumption and low efficiency in sector drawing debugging.
In order to achieve the above object, the present invention provides a method for generating a sector primitive, where the method is applied to a plug-in mounted on a browser, and the method includes the following steps:
acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered, wherein the fan-shaped drawing parameters comprise the radius, the rotation angle and the starting angle of a fan to be drawn;
generating a sector graphic primitive according to the sector drawing parameters;
and displaying the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements in a display panel of the plug-in.
Optionally, the step of obtaining the sector drawing parameters collected by the operation panel of the plug-in and required for generating the sector primitive includes:
opening an operation panel of the plug-in, wherein the operation panel comprises an operation control for dynamically adjusting the sector drawing parameters;
and acquiring sector drawing parameters required by generating the sector graphic primitives based on the user operation acquired by the operation control and a preset control response library.
Optionally, the step of generating a sector primitive according to the sector drawing parameters includes:
calculating path data required for generating the fan-shaped graphic elements according to the fan-shaped drawing parameters, wherein the path data comprises the width and height of a drawing board of the drawing board, the fan-shaped starting position and the fan-shaped ending position for drawing the fan-shaped graphic elements in the drawing board and the arc direction data values of the fan-shaped graphic elements;
and generating a sector primitive according to the path data.
Optionally, the step of calculating, according to the sector drawing parameter, path data required for generating a sector primitive includes:
substituting the radius in the fan-shaped drawing parameter into a first group of formulas preset in a plug-in, and calculating the width and height of the drawing board in the path data so as to adjust the size of the drawing board;
substituting the radius, the rotation angle and the starting angle in the sector drawing parameters into a second group of formulas preset in the plug-in, respectively calculating the position coordinates of a sector starting position and a sector ending position, and further acquiring the sector starting position and the sector ending position in the path data;
and acquiring an arc direction data value in the path data according to the rotation angle in the sector drawing parameter.
Optionally, the step of obtaining the arc direction data value in the path data according to the rotation angle in the sector drawing parameter includes:
if the rotation angle in the sector drawing parameter is larger than a preset angle, the arc direction is clockwise, and an arc direction data value corresponding to the clockwise direction in the arc direction is selected according to a preset path data mapping table;
and if the rotation angle in the sector drawing parameters is not greater than the preset angle, the arc direction is in the anticlockwise direction, and an arc direction data value corresponding to the anticlockwise direction in the arc direction is selected according to the path data mapping table.
Optionally, the sector drawing parameter further includes a graphic color of a sector to be drawn, the path data further includes a color attribute value, and the step of calculating the path data required for generating the sector primitive according to the sector drawing parameter further includes:
and selecting a color code corresponding to the sector drawing parameter from a color code table preset in a plug-in according to the graphic color of the sector in the sector drawing parameter, wherein the color code is used as the color attribute value in the path data.
Optionally, after detecting that the fan-shaped primitive generation function of the plug-in is triggered, the step of obtaining fan-shaped drawing parameters, collected by an operation panel of the plug-in and required for generating a fan-shaped primitive, includes:
and after the completion of the installation of the plug-in is detected, automatically generating an icon of the plug-in the browser.
In addition, to achieve the above object, the present invention further provides an apparatus for generating a sector primitive, the apparatus comprising:
the acquisition module is used for acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered;
the generating module is used for generating a sector graphic primitive according to the sector drawing parameters;
and the display module is used for displaying the generated fan-shaped graphic elements and the corresponding style codes in a display panel of the plug-in.
In addition, to achieve the above object, the present invention further provides a device for generating a sector primitive, including: the system comprises a memory, a processor and a fan-shaped primitive generation program stored on the memory and capable of running on the processor, wherein the fan-shaped primitive generation program is configured to realize the steps of the fan-shaped primitive generation method.
In addition, to achieve the above object, the present invention further provides a computer-readable storage medium having a program for generating a sector primitive stored thereon, wherein the program for generating a sector primitive implements the steps of the method for generating a sector primitive described above when executed by a processor.
The sector graphic primitive generation method is applied to a plug-in unit hung on a browser, sector drawing parameters which are collected by an operation panel of the plug-in unit and are needed for generating the sector graphic primitive are obtained, and the sector drawing parameters comprise the radius, the rotation angle and the initial angle of a sector to be drawn; generating a sector primitive according to the sector drawing parameters; displaying the generated fan-shaped primitive and the style code corresponding to the fan-shaped primitive in a display panel of the plug-in, namely: the method is mounted on the browser end in a plug-in mode, so that time for finding and opening drawing software is saved, convenience is brought to users, dynamic adjustment of sector drawing parameters is simplified and supported, sectors required by the users can be generated and displayed quickly, debugging time of sector drawing is shortened, and convenience of sector drawing is improved greatly.
Drawings
Fig. 1 is a schematic structural diagram of a sector primitive generation device in a hardware operating environment according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a method for generating a sector primitive according to a first embodiment of the method for generating a sector primitive according to the present invention;
FIG. 3 is a schematic interface diagram of an operation panel in the method for generating a sector primitive according to the present invention;
FIG. 4 is a schematic interface diagram of a display panel in the method for generating a sector primitive according to the present invention;
FIG. 5 is a detailed flowchart of step S20 in FIG. 2;
FIG. 6 is a detailed flowchart of step S21 in FIG. 5;
FIG. 7 is a geometric diagram of a coordinate system established in the method for generating a sector primitive according to the present invention;
fig. 8 is a flowchart illustrating a method for generating a sector primitive according to another embodiment.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
At present, fan-shaped graphs are generally generated by approximately drawing in a mode of dividing a fan into triangles, in an occasion with a high requirement on the graph effect, a fan shape can be approximately obtained only by splitting a large number of triangles, the problems of low drawing efficiency and long time consumption for debugging fan-shaped drawing exist, the productivity of a designer and the coding efficiency of a front-end development engineer are influenced, and the efficiency of debugging and drawing the fan-shaped graph needs to be improved, so that the productivity of the designer is liberated, and the coding efficiency of the front-end development engineer is improved.
The main solution of the embodiment of the invention is as follows: the method comprises the steps of acquiring sector drawing parameters collected by an operation panel of the plug-in and required for generating sector primitives after detecting that a sector primitive generating function of the plug-in is triggered, wherein the sector drawing parameters comprise the radius, the rotating angle and the starting angle of a sector to be drawn, then generating the sector primitives according to the sector drawing parameters, finally displaying the generated sector primitives and style codes corresponding to the sector primitives in a display panel of the plug-in and hanging the generated sector primitives and the style codes at a browser end in a plug-in mode, so that the time for searching and opening drawing software is saved, convenience is brought to users, the sector drawing parameters are simplified and supported to be dynamically adjusted, and the sector required by the users is quickly generated and displayed.
In the conventional technical scheme, the fan shape is generally approximately drawn and generated by dividing the fan shape into triangles, so that the debugging time is long and the drawing efficiency is low.
The invention provides a solution, which solves the problems of overlong debugging time and insufficient convenience in sector drawing.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a device for generating a sector primitive in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the generating device of the sector primitive may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory, or may be a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001 described previously.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of the generation device for the sector primitives and may include more or fewer components than those shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include therein an operating system, a data storage module, a network communication module, a user interface module, and a generation program of a sector primitive.
In the generation device of the sector primitive shown in fig. 1, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the sector primitive generation apparatus of the present invention may be provided in the sector primitive generation apparatus, which calls the generation program of the sector primitive stored in the memory 1005 by the processor 1001 and performs the following operations:
acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered, wherein the fan-shaped drawing parameters comprise the radius, the rotation angle and the starting angle of a fan to be drawn;
generating a sector graphic primitive according to the sector drawing parameters;
and displaying the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements in a display panel of the plug-in.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the step of obtaining the sector drawing parameters required by the generation of the sector graphics primitive collected by the operation panel of the plug-in comprises the following steps:
opening an operation panel of the plug-in, wherein the operation panel comprises an operation control for dynamically adjusting the sector drawing parameters;
and acquiring sector drawing parameters required for generating the sector graphic elements based on the user operation acquired by the operation control and a preset control response library.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the step of generating the sector primitive according to the sector drawing parameters comprises:
calculating path data required for generating the fan-shaped graphic elements according to the fan-shaped drawing parameters, wherein the path data comprises the width and height of a drawing board of the drawing board, the fan-shaped starting position and the fan-shaped ending position for drawing the fan-shaped graphic elements in the drawing board and the arc direction data values of the fan-shaped graphic elements;
and generating a sector primitive according to the path data.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the step of calculating the path data required for generating the sector graphic primitive according to the sector drawing parameters comprises the following steps:
substituting the radius in the fan-shaped drawing parameter into a first group of formulas preset in a plug-in, and calculating the width and height of the drawing board in the path data so as to adjust the size of the drawing board;
substituting the radius, the rotation angle and the starting angle in the sector drawing parameters into a second group of formulas preset in the plug-in, respectively calculating the position coordinates of a sector starting position and a sector ending position, and further acquiring the sector starting position and the sector ending position in the path data;
and acquiring an arc direction data value in the path data according to the rotation angle in the sector drawing parameter.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the step of obtaining the arc direction data value in the path data according to the rotation angle in the sector drawing parameter includes:
if the rotation angle in the sector drawing parameter is larger than a preset angle, the arc direction is clockwise, and an arc direction data value corresponding to the clockwise direction in the arc direction is selected according to a preset path data mapping table;
and if the rotation angle in the sector drawing parameters is not greater than the preset angle, the arc direction is in the anticlockwise direction, and an arc direction data value corresponding to the anticlockwise direction in the arc direction is selected according to the path data mapping table.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the sector drawing parameters further include a color of a sector to be drawn, the path data further includes a color attribute value, and the step of calculating the path data required for generating the sector primitive according to the sector drawing parameters further includes:
and selecting a color code corresponding to the sector drawing parameter from a color code table preset in a plug-in according to the graphic color of the sector in the sector drawing parameter, wherein the color code is used as the color attribute value in the path data.
Further, processor 1001 may invoke a generation program for a sector primitive stored in memory 1005, and also perform the following operations:
the method comprises the following steps of acquiring fan-shaped drawing parameters required by the generation of the fan-shaped primitive collected by an operation panel of the plug-in after the triggering of the fan-shaped primitive generation function of the plug-in is detected:
and after the completion of the installation of the plug-in is detected, automatically generating an icon of the plug-in the browser.
An embodiment of the present invention provides a method for generating a sector primitive, and referring to fig. 2, fig. 2 is a schematic flow diagram of a first embodiment of the method for generating a sector primitive according to the present invention.
In this embodiment, the method for generating the sector primitive includes:
step S10: acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered, wherein the fan-shaped drawing parameters comprise the radius, the rotation angle and the starting angle of a fan to be drawn;
the plug-in is a program written by an application program interface conforming to a certain specification, and can only run under a system platform (possibly supporting multiple platforms simultaneously) specified by the program, but cannot run independently from a specified platform.
The fan-shaped primitive generating function is an attribute which is preset in the plug-in and can meet the fan-shaped drawing requirement of a user, and is used for generating fan-shaped primitives required by the user, fan-shaped drawing parameters collected by an operation panel of the plug-in are obtained after the fan-shaped primitive generating function of the plug-in is detected to be triggered, the convenience of fan-shaped debugging and drawing is improved by simplifying parameters input by the user, the fan-shaped drawing parameters are used for calculating and analyzing some data required by subsequent fan-shaped drawing, and meanwhile, the fan-shaped primitives are generated by establishing a coordinate system.
The starting angle is an included angle between a connecting line of a sector starting position to be drawn and an original point of a coordinate system and a positive half shaft of a transverse shaft, and the sector starting position to be drawn is a starting point of a sector arc line of a sector to be drawn.
The starting edge is a connecting line between the circle center of the sector and the starting position of the sector to be drawn, the ending edge is a connecting line between the circle center of the sector and the ending position of the sector to be drawn, and the ending position of the sector to be drawn is the end point of the sector arc line.
The rotation angle is the angle from the beginning edge to the end edge of the sector, i.e. the central angle of the sector.
Specifically, the step of obtaining the fan-shaped drawing parameters required for generating the fan-shaped primitive collected by the operation panel of the plug-in includes: opening an operation panel of the plug-in, wherein the operation panel comprises an operation control for dynamically adjusting the sector drawing parameters, and the operation control can be in various forms such as a sliding bar and an input frame, and is not limited herein, so that a user can conveniently adjust the sector drawing parameters; and acquiring sector drawing parameters required by generating the sector graphic primitives based on user operation acquired by the operation control and a preset control response library, wherein the user operation can be actions of sliding the operation control by a user or inputting or selecting after clicking and the like through the operation control, the preset control response library is sector drawing parameters preset in the plug-in and corresponding to the user operation, and in addition, if the user operation acquired by the operation control on the operation panel is changed, the sector drawing parameters are acquired by the changed user operation, so that the user operation is quickly responded.
Referring to fig. 3, fig. 3 is a schematic interface diagram of an operation panel of a method for generating a sector primitive according to the present invention.
In fig. 3, the left side is a sector drawing parameter, and the right side is an operation control, so that a user can modify and adjust the sector drawing parameter on the left side through the operation control on the right side. For example, the user actions collected based on the operation control are: dragging the sliding bar with the radius to a point a, clicking an input box with the start angle to input a point b, and enabling the plug-in to select the radius corresponding to the point a and the start angle corresponding to the point b according to the preset control response library as the radius and the start angle in the sector drawing parameters.
Step S20: generating a sector primitive according to the sector drawing parameters;
and converting the acquired fan-shaped drawing parameters into path data required by generating a fan-shaped primitive, and generating the fan-shaped primitive required by a user according to the path data, wherein the path data is a value required by drawing a fully-named route from a fan-shaped starting position to a fan-shaped ending position.
Step S30: and displaying the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements in a display panel of the plug-in.
Referring to fig. 4, fig. 4 is a schematic interface diagram of a display panel of a method for generating a sector primitive according to the present invention.
As shown in fig. 4, the display panel 4003 is an interface for presenting a sector effect and a style code of the sector to a user, and may include a sector presentation frame 4001 and a code frame 4002. Wherein the code box 4002 may include a style code to be copied and a copy control for copying the style code. The sector display frame 4001 is configured to display the generated sector primitive to a user, and the code frame 4002 is configured to display a style code of the generated sector primitive to the user and copy the style code by the user to obtain the generated sector primitive, where the style code is a source file of the generated sector primitive.
And displaying the generated fan-shaped graphic primitives on a fan-shaped display frame 4001 in a display panel 4003, displaying an effect to a user so as to determine whether debugging is needed, and displaying a style code corresponding to the fan-shaped graphic primitives on a code frame 4002 in the display panel 4003, so that the user can copy the style code to obtain a required fan shape conveniently.
In this embodiment, after detecting that the fan-shaped primitive generation function of the plug-in is triggered, fan-shaped drawing parameters, which are acquired by an operation panel of the plug-in and are required for generating a fan-shaped primitive, are acquired, where the fan-shaped drawing parameters include a radius, a rotation angle, and an initial angle of a fan to be drawn; generating a sector primitive according to the sector drawing parameters; the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements are displayed on a display panel of the plug-in and are mounted on a browser end in a plug-in mode, time for finding and opening drawing software is saved, the use by a user is facilitated, fan-shaped drawing parameters are flexibly input and simplified through a visual operation panel, user operation experience is improved, the fan shape is rapidly generated, dynamic adjustment of the fan-shaped drawing parameters is supported, the generated fan-shaped graphic elements and the style codes are dynamically displayed on the display panel, effects can be conveniently displayed for the user, fan-shaped debugging time is shortened, the style codes are copied by the user to obtain a needed fan shape, and convenience in fan-shaped drawing is improved.
Further, referring to fig. 5, a second embodiment of the present invention provides a method for generating a sector primitive, based on the above embodiment shown in fig. 2, the step S20 of generating a sector primitive according to the sector rendering parameters includes:
step S21: calculating path data required for generating the fan-shaped graphic elements according to the fan-shaped drawing parameters, wherein the path data comprises the width and height of a drawing board of the drawing board, the fan-shaped starting position and the fan-shaped ending position for drawing the fan-shaped graphic elements in the drawing board and the arc direction data values of the fan-shaped graphic elements;
the drawing board is used for bearing the fan-shaped primitives displayed in the display panel, and the width and the height of the drawing board are the width and the height of the generated scalable vector diagram of the fan-shaped primitives.
Specifically, referring to fig. 6, the step S21 of calculating path data required to generate a sector primitive according to the sector rendering parameters includes:
step S211: substituting the radius in the fan-shaped drawing parameter into a first group of formula preset in a plug-in, and calculating the width and height of the drawing board in the path data so as to adjust the size of the drawing board;
the first set of formulas, preset in the insert, is: the width of the drawing board = the height of the drawing board = the radius x 2, for example, the radius r, then the width of the drawing board and the height of the drawing board can be calculated to be 2r, at this time, the drawing board can bear a complete sector, and simultaneously, redundant space is avoided.
Step S212: substituting the radius, the rotation angle and the starting angle in the sector drawing parameters into a second group of formulas preset in the plug-in, respectively calculating the position coordinates of the sector starting position coordinate and the sector ending coordinate position, and further acquiring the sector starting position and the sector ending position in the path data;
referring to fig. 7, a coordinate system is established with the lower left vertex of the drawing board as an origin O, the direction from the lower left vertex to the lower right vertex as the positive direction of the horizontal axis (x axis), and the direction from the lower left vertex to the upper left vertex as the positive direction of the vertical axis (y axis), where the circle center of the sector is the center of the drawing board, for example, the radius is r, and the position coordinates of the circle center are (r, r).
The starting position of the fan is the starting point of the fan arc line, and the position coordinate of the starting position of the fan arc line is (sx, sy); the fan-shaped end position is the end point of the fan-shaped arc line, and the position coordinate of the fan-shaped end position is (ex, ey).
The second set of equations preset in the insert are:
sx = (r + (r × math.cos ((start angle + rotation angle-90) × math.pi/180))) toFixed (2);
sy = (r + (r × math.sin ((start angle + rotation angle-90) × math.pi/180))) toFixed (2);
ex = (r + (r × math.cos ((starting angle-90) × math.pi/180))). toFixed (2);
ey = (r + (r matrix.sin ((starting angle-90) × matrix.pi/180))). toFixed (2);
wherein, math.cos represents the cosine value of an angle of mathematical calculation, math.sin represents the sine value of an angle of mathematical calculation, PI is the circumference ratio, i.e. the ratio of the circumference of a circle and the diameter of the circle, math.pi/180 represents the ratio of the circumference ratio of the mathematical calculation to 180, and toFixed (2) represents that the final calculation result retains two decimal numbers.
Substituting the radius, the rotation angle and the starting angle into the above formula to calculate the horizontal and vertical coordinates of the starting position and the ending position of the sector, so as to obtain the starting position (sx, sy) and the ending position (ex, ey) of the sector in the coordinate system, and further determine the arc track of the sector.
Step S213: and acquiring an arc direction data value in the path data according to the rotation angle in the sector drawing parameter.
The arc direction is the direction of drawing a fan-shaped arc, and the arc is drawn clockwise or anticlockwise from the fan-shaped starting position to the fan-shaped ending position.
Specifically, the step S213 of acquiring the arc direction data value in the path data according to the rotation angle in the sector drawing parameter includes:
if the rotation angle in the sector drawing parameter is larger than a preset angle, the arc direction is clockwise, and an arc direction data value corresponding to the clockwise direction in the arc direction is selected according to a preset path data mapping table;
if the rotation angle in the sector drawing parameters is not larger than the preset angle, the arc direction is in the anticlockwise direction, and an arc direction data value corresponding to the anticlockwise direction in the arc direction is selected according to the path data mapping table.
For example, the preset angle is 180 degrees, in the path data mapping table, the arc direction data value corresponding to the arc direction in the clockwise direction is 1, the arc direction data value corresponding to the arc direction in the counterclockwise direction is 0, the rotation angle of the sector required by the user input is 150 degrees, 150 degrees are not greater than 180 degrees, the arc direction is counterclockwise, the corresponding arc direction data value is selected to be 0 according to the path data mapping table, and therefore the sector arc track required by the user can be accurately obtained.
Additionally, if the sector drawing parameter further includes a color of a to-be-drawn sector, the path data further includes a color attribute value, and the step S21 of calculating the path data required for generating the sector primitive according to the sector drawing parameter further includes:
and selecting a color code corresponding to the sector drawing parameter from a color code table preset in a plug-in according to the graphic color of the sector in the sector drawing parameter, wherein the color code is used as the color attribute value in the path data.
For example, when it is detected that the graphic color of the sector selected by the user is blue, the color code F, F corresponding to blue, that is, the color attribute value in the path data is selected from the color code table.
Step S22: and generating a sector primitive according to the path data.
All path data required by drawing the sector are obtained through the steps, the path data are substituted into a preset sector primitive generation code to execute a sector primitive generation instruction, the coordinate system is established according to the path data, the starting position and the ending position of the sector to be drawn are determined, the contour of the sector to be drawn is sketched through the path data, and finally the sector primitive required by a user is generated.
In the embodiment, by performing calculation analysis on the sector drawing parameters input by the user, the path data required by sector drawing is acquired, the path data comprises the width and height of the drawing board, the sector starting position and sector ending position for drawing the sector primitives in the drawing board, the arc direction data value and the color attribute value of the sector primitives, the method has the advantages that the fan-shaped graphic primitive generation instruction is executed according to the coordinate system established by the path data, the fan-shaped graphic primitive required by a user is finally generated, the simplification of parameters for drawing the fan shape is realized, the path data required for drawing the fan shape is calculated and analyzed by means of the simplified parameters, the effects of quickly generating the fan shape and improving the convenience for generating the fan shape are achieved, the display content of the fan-shaped graphic primitive is enriched by adding the color attribute value, and the surplus in space is avoided while the size of the drawing board is adjusted so that the drawing board can bear the complete fan shape.
Referring to fig. 8, a third embodiment of the present invention provides a method for generating a sector primitive, based on the embodiment shown in fig. 2, before the step S10, the method further includes:
step S40: and after the completion of the installation of the plug-in is detected, automatically generating an icon of the plug-in the browser.
The icon is a mark for identifying the plug-in and controlling the opening of the plug-in, and after the completion of the installation of the plug-in on the browser is detected, the icon of the plug-in is automatically generated, so that a user can open the plug-in when a fan needs to be drawn, a fan-shaped primitive generating function on the plug-in is triggered, and relevant steps for subsequently generating fan-shaped primitives are executed.
In the embodiment, the generation device of the sector graphic primitive is mounted on the browser in a plug-in mode, and the icon of the plug-in is generated, so that the problem that a user cannot find the sector graphic primitive in an urgent situation when the sector graphic primitive needs to be drawn is avoided, and the convenience of sector drawing is improved.
In addition, an embodiment of the present invention further provides a device for generating a sector primitive, where the device includes:
the acquisition module is used for acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered;
the generating module is used for generating a sector graphic primitive according to the sector drawing parameters;
and the display module is used for displaying the generated fan-shaped graphic elements and the corresponding style codes in a display panel of the plug-in.
In addition, an embodiment of the present invention further provides a device for generating a sector primitive, where the device for generating a sector primitive includes: the system comprises a memory, a processor and a fan-shaped primitive generation program stored on the memory and capable of running on the processor, wherein the fan-shaped primitive generation program is configured to realize the steps of the fan-shaped primitive generation method.
In addition, an embodiment of the present invention further provides a computer-readable storage medium, where a program for generating a sector primitive is stored, and when the program is executed by a processor, the steps of the method for generating a sector primitive described above are implemented.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system 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 system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. A method for generating a sector primitive, which is applied to a plug-in mounted on a browser, the method comprising the following steps:
acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered, wherein the fan-shaped drawing parameters comprise the radius, the rotation angle and the starting angle of a fan to be drawn;
generating a sector graphic primitive according to the sector drawing parameters;
and displaying the generated fan-shaped graphic elements and the style codes corresponding to the fan-shaped graphic elements in a display panel of the plug-in.
2. A method for generating a fan-shaped primitive according to claim 1, wherein the step of obtaining the fan-shaped drawing parameters collected by the operation panel of the plug-in unit for generating the fan-shaped primitive comprises:
opening an operation panel of the plug-in, wherein the operation panel comprises an operation control for dynamically adjusting the sector drawing parameters;
and acquiring sector drawing parameters required by generating the sector graphic primitives based on the user operation acquired by the operation control and a preset control response library.
3. A method for generating fan primitives in accordance with claim 1 wherein said step of generating fan primitives in accordance with said fan rendering parameters comprises:
calculating path data required for generating the fan-shaped graphic elements according to the fan-shaped drawing parameters, wherein the path data comprises the width and height of a drawing board of the drawing board, the fan-shaped starting position and the fan-shaped ending position for drawing the fan-shaped graphic elements in the drawing board and the arc direction data values of the fan-shaped graphic elements;
and generating a sector primitive according to the path data.
4. A method for generating fan primitives as recited in claim 3, wherein said step of calculating path data required to generate fan primitives from said fan rendering parameters comprises:
substituting the radius in the fan-shaped drawing parameter into a first group of formulas preset in a plug-in, and calculating the width and height of the drawing board in the path data so as to adjust the size of the drawing board;
substituting the radius, the rotation angle and the starting angle in the sector drawing parameters into a second group of formulas preset in the plug-in, respectively calculating the position coordinates of a sector starting position and a sector ending position, and further acquiring the sector starting position and the sector ending position in the path data;
and acquiring an arc direction data value in the path data according to the rotation angle in the sector drawing parameter.
5. A method for generating fan primitives as recited in claim 4, wherein said step of obtaining arc direction data values in said path data according to rotation angles in said fan rendering parameters comprises:
if the rotation angle in the sector drawing parameter is larger than a preset angle, the arc direction is clockwise, and an arc direction data value corresponding to the clockwise direction in the arc direction is selected according to a preset path data mapping table;
and if the rotation angle in the sector drawing parameters is not greater than the preset angle, the arc direction is in the anticlockwise direction, and an arc direction data value corresponding to the anticlockwise direction in the arc direction is selected according to the path data mapping table.
6. A method for generating a fan primitive in accordance with claim 3, wherein the fan rendering parameters further include a graphics color of a fan to be rendered, the path data further includes a color attribute value, and the step of calculating the path data required to generate the fan primitive in accordance with the fan rendering parameters further comprises:
and selecting a color code corresponding to the sector drawing parameter from a color code table preset in a plug-in according to the graphic color of the sector in the sector drawing parameter, wherein the color code is used as the color attribute value in the path data.
7. A method for generating a fan-shaped primitive according to claim 1, wherein the step of obtaining the fan-shaped drawing parameters required for generating a fan-shaped primitive collected by the operation panel of the plug-in after detecting that the fan-shaped primitive generation function of the plug-in is triggered comprises:
and after the completion of the installation of the plug-in is detected, automatically generating an icon of the plug-in the browser.
8. An apparatus for generating a sector primitive, the apparatus comprising:
the acquisition module is used for acquiring fan-shaped drawing parameters which are acquired by an operation panel of the plug-in and are required for generating fan-shaped primitives after detecting that the fan-shaped primitive generation function of the plug-in is triggered;
the generating module is used for generating a sector graphic primitive according to the sector drawing parameters;
and the display module is used for displaying the generated fan-shaped graphic elements and the corresponding style codes in a display panel of the plug-in.
9. A device for generating a sector primitive, characterized in that it comprises: memory, processor and a program for generating a sector primitive stored on said memory and executable on said processor, said program for generating a sector primitive being configured to implement the steps of the method for generating a sector primitive as claimed in any one of the claims 1 to 7.
10. A computer-readable storage medium, on which a program for generating a fan-shaped primitive is stored, which program, when executed by a processor, carries out the steps of the method for generating a fan-shaped primitive according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210099072.0A CN114529630A (en) | 2022-01-27 | 2022-01-27 | Method, device and equipment for generating sector primitives and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210099072.0A CN114529630A (en) | 2022-01-27 | 2022-01-27 | Method, device and equipment for generating sector primitives and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114529630A true CN114529630A (en) | 2022-05-24 |
Family
ID=81623328
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210099072.0A Pending CN114529630A (en) | 2022-01-27 | 2022-01-27 | Method, device and equipment for generating sector primitives and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114529630A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109254976A (en) * | 2017-07-11 | 2019-01-22 | 中国移动通信集团北京有限公司 | A kind of method for drafting of figure, device, electronic equipment and storage medium |
CN111583360A (en) * | 2020-06-04 | 2020-08-25 | 长沙景嘉微电子股份有限公司 | Method and device for generating sector graph, computer storage medium and electronic equipment |
CN113672210A (en) * | 2021-10-25 | 2021-11-19 | 深圳市明源云空间电子商务有限公司 | Triangular icon code generation method and device and readable storage medium |
-
2022
- 2022-01-27 CN CN202210099072.0A patent/CN114529630A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109254976A (en) * | 2017-07-11 | 2019-01-22 | 中国移动通信集团北京有限公司 | A kind of method for drafting of figure, device, electronic equipment and storage medium |
CN111583360A (en) * | 2020-06-04 | 2020-08-25 | 长沙景嘉微电子股份有限公司 | Method and device for generating sector graph, computer storage medium and electronic equipment |
CN113672210A (en) * | 2021-10-25 | 2021-11-19 | 深圳市明源云空间电子商务有限公司 | Triangular icon code generation method and device and readable storage medium |
Non-Patent Citations (2)
Title |
---|
ITCLANCODER: "实现一扇形生成器", HTTPS://MP.WEIXIN.QQ.COM/S/FYQ1WSHAN_SWXTOGNRAQXQ, 27 December 2021 (2021-12-27), pages 1 - 2 * |
王文澄编著: "微电脑图形学入门", 30 November 1988, 北京:机械工业出版社, pages: 82 - 84 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101787586B1 (en) | Manipulating graphical objects | |
CN107992304B (en) | Method and device for generating display interface | |
CN109726261A (en) | A kind of heating power drawing generating method and device | |
CN110413161B (en) | Component configuration method and device and electronic equipment | |
CN111583379A (en) | Rendering method and device of virtual model, storage medium and electronic equipment | |
CN114675925A (en) | Configuration image processing method and device, computer equipment and storage medium | |
US9501812B2 (en) | Map performance by dynamically reducing map detail | |
CN114022604A (en) | Model drawing method and device, electronic equipment and storage medium | |
CN109598672B (en) | Map road rendering method and device | |
CN108279956B (en) | Progress indicating method, progress indicating device, storage medium and electronic equipment | |
CN115061680A (en) | Method for realizing custom display panel based on ECharts map component | |
CN110764864A (en) | Terraform-based visual resource arrangement method | |
CN110895834A (en) | Method for generating a movement comprising at least a rotation | |
CN114529630A (en) | Method, device and equipment for generating sector primitives and computer readable storage medium | |
US10529100B2 (en) | Interaction-driven format for graph visualization | |
JP7480076B2 (en) | Content Creation System and Method | |
CN112115680B (en) | Font splitting method and device, computer equipment and computer readable storage medium | |
CN112330772A (en) | Radar map generation method, device, equipment and storage medium | |
CN113407080A (en) | Method and device for generating component label, computer equipment and storage medium | |
CN117078797B (en) | Rendering method and device of road identification, electronic equipment, storage medium and product | |
US20240033625A1 (en) | Rendering method and apparatus for virtual scene, electronic device, computer-readable storage medium, and computer program product | |
JP4365965B2 (en) | Information processing apparatus, information processing method, and storage medium | |
US20240153172A1 (en) | Automatically generating axes for data visualizations including data bound objects | |
CN115272512A (en) | GIS vector diagram generation method, device, equipment and computer storage medium | |
JP2000020294A (en) | Program development support device and computer- readable recording medium |
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 |