CN117541461B - Arc scaling drawing method, device, equipment and medium - Google Patents

Arc scaling drawing method, device, equipment and medium Download PDF

Info

Publication number
CN117541461B
CN117541461B CN202410034117.5A CN202410034117A CN117541461B CN 117541461 B CN117541461 B CN 117541461B CN 202410034117 A CN202410034117 A CN 202410034117A CN 117541461 B CN117541461 B CN 117541461B
Authority
CN
China
Prior art keywords
gpu
angle
arc
target
value
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.)
Active
Application number
CN202410034117.5A
Other languages
Chinese (zh)
Other versions
CN117541461A (en
Inventor
童声
胡巨振
孙凌云
夏峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zwcad Software Co ltd
Original Assignee
Zwcad Software Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zwcad Software Co ltd filed Critical Zwcad Software Co ltd
Priority to CN202410034117.5A priority Critical patent/CN117541461B/en
Publication of CN117541461A publication Critical patent/CN117541461A/en
Application granted granted Critical
Publication of CN117541461B publication Critical patent/CN117541461B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses an arc scaling drawing method, device, equipment and medium, the method comprises the steps of obtaining parameter data and current segmentation numbers corresponding to all arcs respectively through a CPU end, constructing an initial label array according to the current segmentation numbers through the CPU end, respectively caching the initial label array and the parameter data to different positions of a GPU end, responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array, caching the updated label array to the GPU end, generating a plurality of arc vertexes through the GPU end according to the updated label array and the lasting parameter data, drawing straight lines by the GPU end in response to a straight line drawing instruction called by the CPU end, sequentially connecting the arc vertexes, and generating a target arc. Therefore, the drawing efficiency is effectively improved while the redundant data and the video memory data are reduced.

Description

Arc scaling drawing method, device, equipment and medium
Technical Field
The present invention relates to the field of computer graphics drawing technology, and in particular, to an arc scaling drawing method, apparatus, device, and medium.
Background
In the design process of the manufacturing industry, design drawings are generally provided by a design department, and the drawings are usually graphic format files, and a designer carries out the design of related information based on the design drawings, such as clamp symbol marking, dimension marking, process graphic modification and the like. In drawing related drawings, no matter drawing a circle, an ellipse or other curved surface figures, arc drawing belongs to one of the indispensable required functions.
Conventional graphics rendering platforms such as CAD can typically render arcs such as arcs, elliptical arcs, etc. by using graphics APIs (e.g., openGL, etc.), and require that the arcs, elliptical arcs be generated in advance in segments at the CPU end into a large number of short straight lines to fit their curves. The circular arc and the elliptic arc can be represented by the data of a circle center, a major axis radius, a minor axis radius, a start angle, an end angle, a normal line and the like, but tens or even hundreds of vertexes are needed for segmentation to represent the short straight lines, and when hardware acceleration is used, a large amount of redundant data needs to be sent to the GPU, so that a large amount of video memory is occupied.
When the graph constructed by the arc is enlarged, the display length of the multi-segment line on the screen is increased because the multi-segment line data generated by the CPU end is not changed, and the arc is not smoothly represented. For this reason, the prior art usually draws a straight line with the number of segments by generating multiple short straight lines each time of scaling, or by increasing the number of segments of an arc in advance, or by using a geometry shader to draw a straight line with the number of segments as input and output. However, the above scheme generates more redundant data when zooming and drawing each time, and causes the drawing efficiency to be reduced while occupying a large amount of video memory.
Disclosure of Invention
The invention provides an arc scaling drawing method, device, equipment and medium, which solve the technical problem that the existing arc drawing scheme generates more redundant data when scaling drawing each time, occupies a large amount of video memory and simultaneously reduces drawing efficiency.
The first aspect of the present invention provides an arc scaling drawing method, which is applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, and the method comprises:
Acquiring parameter data and current segmentation number respectively corresponding to all arcs through the CPU end;
constructing an initial label array according to the current segmentation number through the CPU end, and respectively caching the initial label array and the parameter data to the GPU end;
responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
Generating a plurality of arc vertexes by the GPU end according to the updated index array and the parameter data;
And responding the straight line drawing instruction called by the CPU end through the GPU end, and drawing straight lines to sequentially connect the vertexes of the arcs to generate a target arc.
Optionally, the method further comprises:
If the scene scaling instruction is not received, determining the initial index array as an updated index array through the GPU end;
and executing the jump, wherein the GPU side generates a plurality of arc vertexes according to the updated label array and the parameter data.
Optionally, the constructing, by the CPU side, an initial tag array according to each current segment number, and buffering each initial tag array and each parameter data to the GPU side, including:
Generating a plurality of groups of label data according to the number of the arcs through the CPU end; the label data comprises vertex labels equal to the number of the current segments;
tiling all the vertex labels into a digital array form through the CPU end to obtain an initial label array;
And caching the initial index array to an index buffer area in the GPU end through the CPU end, and caching each parameter data to a parameter buffer area in the GPU end.
Optionally, the responding to the scene scaling instruction for any arc updates the initial tag array according to the scene scaling instruction by the CPU side, generates an updated tag array, and caches the updated tag array to the GPU side, including:
Responding to a scene scaling instruction aiming at any arc, acquiring a scaling coefficient corresponding to the scene scaling instruction through the CPU end, and positioning a target label in the initial label array;
calculating the multiplication value of the scaling factor and the current segmentation number through the CPU end to obtain an updated segmentation number;
generating a plurality of update labels according to the update segmentation number through the CPU end;
and replacing and updating the target label by adopting all the updated labels through the CPU end, generating an updated label array and caching the updated label array to the GPU end.
Optionally, the generating, by the GPU side, a plurality of arc vertices according to the updated index array and the parameter data includes:
Positioning a target arc line according to the position information of the update mark in the update mark array by the GPU terminal;
reading parameter data corresponding to the target arc line as target parameter data through the GPU terminal;
Determining a plurality of vertex coordinates by the GPU terminal based on the position information and the target parameter data;
And calling a shader by the GPU terminal according to each vertex coordinate to generate a plurality of arc vertexes on the current page.
Optionally, the target parameter data comprises a circle center vector, an axis vector and a start-stop point half angle cosine value; the determining, by the GPU side, a plurality of vertex coordinates based on the location information and the target parameter data, including:
Respectively calculating the starting angle and the ending angle of the target arc line by the GPU end according to the cosine value of the half angle of the start point and the half angle of the stop point;
Determining a vertex half-angle value corresponding to the position information by the GPU side according to the starting angle and the ending angle and combining the position information;
determining a target half-angle cosine value by the GPU end according to the vertex half-angle value and the start-stop point half-angle cosine value;
And calculating vertex coordinates by the GPU end according to the target half angle cosine value, the circle center vector and the axis vector.
Optionally, the start-stop point half angle cosine value includes a start point half angle cosine value and an end point half angle cosine value; the step of calculating, by the GPU end, the start angle and the end angle of the target arc according to the cosine values of the start and stop point half angles, respectively, includes:
substituting the starting point half angle cosine value into a double angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain the starting angle of the target arc line;
substituting the end point half angle cosine value into a double angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain the end angle of the target arc line.
Optionally, the location information includes vertex locations and total number of vertices; the determining, by the GPU side, a vertex half angle value corresponding to the position information according to the start angle and the end angle in combination with the position information includes:
The GPU end is used for obtaining the quantity ratio of the vertex positions to the total quantity of the vertices;
calculating a half angle difference value of the half angle value of the ending angle and the half angle value of the starting angle through the GPU end;
Comparing the starting angle with the ending angle through the GPU end;
if the initial angle is smaller than or equal to the end angle, the GPU end calculates a first multiplication value of the half angle difference value and the quantity ratio, and then the half angle value of the initial angle is overlapped to determine a vertex half angle value corresponding to the position information;
If the starting angle is larger than the ending angle, calculating an angle sum value of the half angle difference value and a preset value through the GPU end;
And after the GPU side calculates a second multiplication value of the ratio of the angle sum value to the number, the half angle value of the initial angle is overlapped, and the vertex half angle value corresponding to the position information is determined.
Optionally, the determining, by the GPU side, the target half angle cosine value according to the vertex half angle value and the start-stop point half angle cosine value includes:
Calculating a vertex half-angle cosine value of the vertex half-angle value through the GPU end;
if the vertex appointed by the position information is a starting point or an ending point, determining the starting point half-angle cosine value as a target half-angle cosine value through the GPU end;
If the vertex specified by the position information is not a starting point or an ending point, selecting a target half-angle cosine value from a preset value, the vertex half-angle cosine value and the starting and ending point half-angle cosine value by the GPU terminal according to a preset selection rule.
Optionally, the axis vector includes a major axis vector and a minor axis vector; the calculating, by the GPU side, vertex coordinates according to the target half angle cosine value, the center vector, and the axis vector, includes:
substituting the target half angle cosine value into a preset double angle cosine formula through the GPU end to determine a target cosine value;
performing inverse cosine calculation on the target cosine value through the GPU end to obtain a target angle;
calculating a target sine value by the GPU end according to the target angle and the target half-angle cosine value;
Calculating a first vector of the target cosine value and the long-axis vector through the GPU end;
calculating a second vector of the target sine value and the short axis vector through the GPU end;
And superposing the first vector, the second vector and the circle center vector through the GPU end to obtain a target vector serving as a vertex coordinate.
Optionally, before executing the step of calling, by the GPU side, the shader according to each vertex coordinate to generate a plurality of arc vertices on the current page, the method further includes:
Judging whether the vertex coordinates exceed an arc line range between a starting point and an ending point or not through the GPU end;
If yes, correcting the vertex coordinates to be within the arc range;
if not, executing a straight line drawing instruction which is called by the GPU end in response to the CPU end, and drawing straight lines to sequentially connect the arc vertexes to generate a target arc.
The second aspect of the present invention provides an arc scaling drawing device, applied to a drawing platform, where the drawing platform includes a CPU end and a GPU end, the device includes:
the data acquisition module is used for acquiring parameter data and the current segmentation number which respectively correspond to all the arcs through the CPU end;
The data caching module is used for constructing an initial index array according to the current segmentation number through the CPU end and caching the initial index array and the parameter data to the GPU end respectively;
the data updating module is used for responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
the vertex generation module is used for generating a plurality of arc vertices through the GPU end according to the updated label array and the parameter data;
and the vertex connection module is used for responding to the straight line drawing instruction called by the CPU end through the GPU end, drawing straight lines to sequentially connect the vertexes of the arcs, and generating a target arc.
A third aspect of the present invention provides a computer device comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to perform the steps of the arc scaling rendering method according to any of the first aspect of the present invention.
A fourth aspect of the present invention provides a computer readable storage medium having stored thereon a computer program which when executed implements the arc scaling rendering method according to any one of the first aspects of the present invention.
From the above technical scheme, the invention has the following advantages:
According to the method, the CPU end is used for acquiring parameter data and current segmentation numbers respectively corresponding to all arcs, the CPU end is used for constructing an initial label array according to the current segmentation numbers and respectively buffering the initial label array and the parameter data to the GPU end, the initial label array is updated according to a scene scaling instruction aiming at any arc by the CPU end in response to the scene scaling instruction, the updated label array is generated and buffered to the GPU end, the GPU end is used for generating a plurality of arc vertexes according to the updated label array and the parameter data, and the GPU end is used for responding to a straight line drawing instruction called by the CPU end to draw straight lines to be sequentially connected with the arc vertexes to generate a target arc. Therefore, generation and uploading of piecewise straight line data on a CPU (central processing unit) during zooming drawing each time are avoided, a small amount of real-time piecewise data of the circular arc or the elliptical arc is uploaded and updated from the CPU end through each frame, the vertex positions are determined by sampling in a GPU (graphics processing unit) end vertex shader according to the number of segments which are currently zoomed down by utilizing parameter data of the circular arc, and finally the vertex data are drawn into straight lines, so that the drawing efficiency is effectively improved while redundant data are reduced.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from these drawings without inventive faculty for a person skilled in the art.
FIG. 1 is a flow chart of steps of an arc scaling drawing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of an arc scaling rendering method according to another embodiment of the present invention;
FIG. 3 is a schematic diagram of a parameter and label caching process according to an embodiment of the present invention;
FIG. 4 is an overall flowchart of an arc scaling drawing method according to an embodiment of the present invention;
fig. 5 is a block diagram of an arc scaling drawing device according to an embodiment of the present invention;
fig. 6 is a block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides an arc scaling drawing method, device, equipment and medium, which are used for solving the technical problem that the existing arc drawing scheme generates more redundant data when scaling drawing is performed each time, occupies a large amount of video memory and simultaneously reduces drawing efficiency.
In order to make the objects, features and advantages of the present invention more comprehensible, the technical solutions in the embodiments of the present invention are described in detail below with reference to the accompanying drawings, and it is apparent that the embodiments described below are only some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating steps of an arc scaling drawing method according to an embodiment of the present invention.
The invention provides an arc scaling drawing method, which is applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, and the method comprises the following steps:
Step 101, acquiring parameter data and current segmentation number respectively corresponding to all arcs through a CPU (Central processing Unit) end;
a graphics platform refers to a terminal device, such as a computer, tablet or other device, that includes a GPU side and a CPU side, and has an operable display front-end.
The parameter data refer to an arc file loaded by the drawing platform or parameterized data of the drawn arc, including but not limited to a circle center, a long axis, a short axis, a starting half angle cosine value (i.e. a cosine value of a half starting angle of the arc), an ending half angle cosine value (i.e. a cosine value of a half ending angle of the arc) and the like of the arc or the elliptical arc, wherein the circle center, the long axis, the short axis, the starting half angle cosine value and the ending half angle cosine value are all 64 bit data (i.e. double type data), and the circle center, the long axis and the short axis are all composed of three components of XYZ.
In the embodiment of the invention, when a user imports a graphic file or draws an arc on a drawing platform, the graphic API such as OpenGL does not need to upload corresponding data of an entity when drawing the entity, but can store vertex data required by drawing in a public buffer area, and can be taken out in the form of textures when a shader at the GPU side draws. Therefore, in order to obtain the data base of scaling and drawing the arcs by the subsequent GPU end, the CPU end can obtain the parameter data corresponding to all the arcs displayed on the current page respectively, the parameter data aiming at the same arc is only needed to be obtained once when the arcs are loaded, and the obtained parameter data is cached in a parameter buffer zone in the GPU end to form lasting data.
Meanwhile, the number of segments required by arc smoothing is proportional to the size of the segments on a screen, the number of segments of one arc is calculated only when data are generated, and the common arc or elliptical arc is formed by drawing a plurality of sections of arcs, so that the current number of segments corresponding to each section of arc on the current page can be obtained as the data basis for scaling the subsequent arcs.
102, Constructing an initial label array according to the number of each current segment by a CPU (Central processing Unit) end, and respectively caching the initial label array and each parameter data to a GPU (graphics processing Unit) end;
After the CPU side counts the current segment number of each current arc, the same number of label data can be respectively created by the CPU side according to each current segment number and tiled into an array form for convenient storage and subsequent processing by the GPU side, so that an initial label array is created.
After the creation of the initial index array is completed, the initial index array and each parameter data are respectively cached in different buffer areas of the GPU, for example, the initial index array can be cached in the index buffer area of the GPU, and the parameter data can be cached in the parameter buffer area of the GPU so as to complete the data preparation for scaling and drawing the arc.
Step 103, responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
Scene zoom instructions refer to computer instructions that zoom in or out on an arc centered on a mouse or trigger point, which typically specify a segment, a point, etc. in a certain arc.
In the embodiment of the invention, when the drawing platform receives a scene scaling instruction for any arc, the number of segments required by arc smoothing is in direct proportion to the size of the arc on a screen, and the number of segments of one arc is calculated only when data is generated, so that the generation of updated label data can be performed by combining the current number of segments according to a scaling coefficient corresponding to the scene scaling instruction through a CPU (Central processing Unit) end in the platform, thereby updating an initial label array and generating an updated label array.
And then the CPU end caches the updated index array to the GPU end, so that the updating of the initial index array cached in the GPU end is completed.
It should be noted that, after the initial index array in the GPU end is updated to be the updated index array, the updated index array is used as a new initial index array, so as to facilitate the re-execution of the scene scaling instruction.
104, Generating a plurality of arc vertexes by the GPU end according to the updated label array and the parameter data;
Because the lengths of the arcs displayed by the page are different when the scene scaling instruction is executed, the original arc may not keep a smooth curve form after the page is enlarged, after the buffer of the updated label array is completed, the updated label array and the parameter data are read through the GPU end, the target arc needing to be redrawn is positioned according to the position of the updated label in the updated label array, the parameter data corresponding to the target arc are further obtained as target parameter data, and the vertex coordinates are calculated by combining a trigonometric function with the target parameter data, so that the vertex coordinates are input to the shader to generate a plurality of arc vertices on the current page.
The scene scaling instruction not only includes scene enlargement but also includes scene reduction, in this case, because the current page target arc is shorter than the original arc, in order to save the use of platform resources, the number of the newly determined arc vertices is smaller than the number of the original vertices.
And 105, drawing straight lines to sequentially connect the vertexes of each arc line through the GPU end in response to the straight line drawing instruction called by the CPU end, and generating a target arc line.
After the generation of the arc line vertexes is completed, a straight line drawing instruction can be directly called and executed through the CPU end and sent to the GPU end, and when the GPU end receives the straight line drawing instruction, straight line drawing operation is executed so as to draw a plurality of sections of straight lines to sequentially connect all adjacent arc line vertexes, so that a target arc line is generated.
In the embodiment of the invention, the CPU end is used for acquiring the parameter data and the current segmentation number respectively corresponding to all the arcs, the CPU end is used for constructing an initial mark number array according to each current segmentation number and respectively caching the initial mark number array and each parameter data to the GPU end, the initial mark number array is updated according to the scene scaling instruction for any arc by responding to the scene scaling instruction, an updated mark number array is generated and cached to the GPU end by the CPU end, a plurality of arc vertexes are generated by the GPU end according to the updated mark number array and the parameter data, and straight lines are drawn by the GPU end to be sequentially connected with each arc vertex by responding to the straight line drawing instruction called by the CPU end, so that the target arc is generated. Therefore, generation and uploading of piecewise straight line data on a CPU (central processing unit) during zooming drawing each time are avoided, a small amount of real-time piecewise data of the circular arc or the elliptical arc is uploaded and updated from the CPU end through each frame, the vertex positions are determined by sampling in a GPU (graphics processing unit) end vertex shader according to the number of segments which are currently zoomed down by utilizing parameter data of the circular arc, and finally the vertex data are drawn into straight lines, so that the drawing efficiency is effectively improved while redundant data are reduced.
Referring to fig. 2, fig. 2 is a flowchart illustrating steps of an arc scaling drawing method according to an embodiment of the present invention.
The invention provides an arc scaling drawing method, which is applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, and the method comprises the following steps:
step 201, acquiring parameter data and current segmentation number respectively corresponding to all arcs through a CPU (Central processing Unit) end;
in the embodiment of the present invention, the implementation process of step 201 is similar to that of step 101, and will not be repeated here.
Step 202, constructing an initial label array according to the number of each current segment by a CPU end, and respectively caching the initial label array and each parameter data to a GPU end;
in one example of the invention, step 202 may comprise the sub-steps of:
generating a plurality of groups of label data according to the number of the arcs through a CPU end; the label data comprises vertex labels equal to the number of each current segment;
all vertex labels are tiled into a number group form through a CPU end, so that an initial label array is obtained;
and caching the initial index array to an index buffer area in the GPU end through the CPU end, and caching each parameter data to a parameter buffer area in the GPU end.
Because the GPU end has high sampling efficiency in textures, but has low operation efficiency such as logic judgment and the like, the arc efficiency of the current vertex is judged to be low in the GPU through a logic expression. In order to balance the load of the CPU and the GPU, the segmentation calculation and the logic judgment can be converted into the sampling of continuous vertex textures to confirm the mark number of the arc to which the current vertex belongs. Namely, the labels corresponding to the vertexes of all the arcs are tiled to form an array, and the labels corresponding to the vertexes are taken as the labels of the corresponding arcs. After the CPU obtains the current segmentation number and the parameter data corresponding to each arc on the current page, the number of the corresponding label data can be generated according to the number of the arcs because multiple segments of the arcs possibly exist in the same page. Wherein each group of label data comprises a plurality of vertex labels, and the number of the vertex labels is the same as the current segmentation number of the arc.
After the generation of the label data is completed, dividing all vertex labels by a CPU end according to each group of label data, and tiling the label data into an array form to construct and obtain an initial label array. And caching the initial index array to an index buffer area in the GPU end through the CPU end, and caching parameter data corresponding to each arc line to the parameter buffer area in the GPU end respectively so as to finish data preparation of the GPU end.
It should be noted that, the vertex labels in each set of label data are different and may be related to the identification to which the arc belongs, for example, the identification of the arc is 0123, and then the vertex labels in each set of label data may be set to be all 0, all 1, all 2 and all 3, so as to distinguish each set of label data.
In a specific implementation, the graphics API such as OpenGL does not need to upload the corresponding data of the entity when drawing the entity, but can store vertex data required for drawing in a common buffer, and fetch the vertex data in the form of texture when drawing by a shader. By utilizing the characteristics, when the arc and the elliptic arc are drawn, the parameterized data of the arc can be recorded in a public buffer area of the GPU (hereinafter referred to as parameter buffer), and meanwhile, the mark of the arc is also required to be uploaded to the public buffer area of the GPU (hereinafter referred to as mark buffer), and the mark is read in a texture form at the GPU. The correspondence between label buffering and parameter buffering can be seen with reference to fig. 3. The arcs on the current page comprise 4 arcs, 160 vertexes are drawn in total, namely the current segmentation number is 160, the corresponding label data are generated, each group of label data are respectively identified and distinguished by adopting the corresponding vertex labels, and an initial label array is constructed in a tiling mode. For parameter buffering, different buffers are respectively set for each arc to buffer arc 1 data, arc 2 data, arc 3 data and arc 4 data. When a certain vertex is selected, determining an arc line where the vertex is positioned and the position of the vertex on the arc line according to the vertex number of the vertex, so that the arc line data is positioned from the parameter buffer to carry out subsequent vertex coordinate determination and arc line scaling drawing.
Step 203, responding to a scene scaling instruction for any arc, updating the initial label array by the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
In one example of the invention, step 203 may comprise the sub-steps of:
Responding to a scene scaling instruction aiming at any arc, acquiring a scaling coefficient corresponding to the scene scaling instruction through a CPU end, and positioning a target label in an initial label array;
Calculating the multiplication value of the scaling coefficient and the current segmentation number through a CPU end to obtain an updated segmentation number;
generating a plurality of update labels according to the update segmentation number through a CPU (Central processing Unit) end;
And replacing and updating the target label by adopting all the updated labels through the CPU end, generating an updated label array and caching the updated label array to the GPU end.
In this embodiment, if the drawing platform receives the scene scaling instruction for any arc, the CPU may obtain, according to the screen scaling ratio of the current page, the scaling coefficient corresponding to the scene scaling instruction. And at the same time, according to the triggering position of the scene scaling instruction, such as the mouse position or the page center, positioning the vertex closest to the position on the arc line, and positioning the corresponding target label in the initial label array according to the vertex.
Because the number of segments needed for arc smoothing is proportional to the size of the segments on a screen, the CPU end only needs to calculate the number of segments of an arc once when generating data, and then multiplies the corresponding scaling coefficient when scaling each time, thereby obtaining the updated number of segments, and then creates a plurality of updated labels according to the updated number of segments. And further adopting the updated label to replace and update the determined target label so as to generate an updated label array. And simultaneously, the updated index array is cached to an index buffer area in the GPU end, and the initial index array in the GPU end is updated.
It should be noted that, the specific identifiers of the update label and the target label may be the same or different, and the number of the update labels may also be different due to the influence of scene scaling, so that the update mode of the update label to the target label is specifically that after deleting the target label at the position of the target label in the initial label array, all the update labels are inserted for updating. In addition, in order to realize real-time smooth drawing, the label buffer needs to be uploaded in real-time organization every frame, the size of the data of the label buffer is 32-bit data which is the sum of the segmentation numbers of all arcs, compared with the fact that the multi-segment line of the regenerated circle every frame needs to send at least the sum of the segmentation numbers of arcs and vertex coordinate data (6-9 64-bit data are needed for every vertex generally), a large amount of video memory can be saved, and meanwhile, even if the data are uploaded every frame, the whole drawing efficiency is not affected excessively.
In another example of the present invention, the method further comprises:
If the scene scaling instruction is not received, determining the initial index array as an updated index array through the GPU end;
and generating a plurality of arc vertexes by the GPU side according to the updated label array and the parameter data.
If the drawing platform does not receive the scene scaling instruction, it indicates that the scene scaling is not needed at this time, the arc drawing can be directly performed according to the parameter data and the initial label array, at this time, the initial label array can be determined to be the updated label array through the GPU, and steps 104-105 are performed to complete the generation of the arc vertex and the drawing of the target arc.
In an embodiment of the present invention, to describe the arc vertex generation process in further detail, step 104 may be replaced with steps 204-207 described below.
Step 204, positioning the target arc line according to the position information of the update label in the update label array by the GPU end;
step 205, reading parameter data corresponding to the target arc line as target parameter data through the GPU terminal;
in the embodiment of the invention, after the initial index array in the index buffer of the GPU end is updated to the updated index array, the target arc line can be positioned by the GPU end according to the position information of the updated index in the updated index array, and then the parameter data corresponding to the target arc line is read as the target parameter data.
It should be noted that, the position information includes at least a vertex position and a total number of vertices, and may further include a vertex number, as shown in fig. 3, after the GPU side obtains the vertex number 103 with the updated label, it determines that the corresponding target arc is arc 4, and the 23 rd vertex (i.e. the vertex position) belonging to arc 4 has a total number of vertices of 80. And further reading corresponding parameter data from the parameter buffer area according to the target arc obtained by positioning, namely, arc 4 data serving as target parameter data.
Step 206, determining a plurality of vertex coordinates by the GPU terminal based on the position information and the target parameter data;
In one example of the present invention, the target parameter data includes a center vector, an axis vector, and a start-stop point half angle cosine value; the center vector and the axis vector are composed of three components of XYZ. Step 206 may include the following sub-steps S11-S14:
s11, respectively calculating a starting angle and an ending angle of the target arc line according to the cosine value of the half angle of the start point and the half angle of the stop point through the GPU end;
Further, the starting and ending point half angle cosine values comprise a starting point half angle cosine value and an ending point half angle cosine value; s11 may comprise the sub-steps of:
Substituting a starting point half-angle cosine value into a double-angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain a starting angle of the target arc line;
substituting the end point half angle cosine value into a double angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain the end angle of the target arc line.
Since the trigonometric function of double type data is not supported in the shader, the direct input of the start angle and the end angle can only use 32-bit precision (namely float type data), which may lead to insufficient calculation precision of the start point and the end point of the arc and bit running. The sine value and the cos value of the double type of the corresponding angle can be calculated under the accuracy of the double type by directly using the half angle cosine value or the half angle formula, so that the coordinates of the starting point and the ending point are accurately calculated. The other points between the starting point and the ending point are obtained by uniform sampling, and the angle sampling under the float precision does not affect the smoothness of the arc, so that the other sampling points do not need too much attention precision like the starting point and the ending point, and can still continue to use the float precision trigonometric function for calculation.
In the present embodiment, the starting point half angle cosine value and the ending point half angle cosine value are respectivelySubstituting the initial angle and the end angle of the target arc line into a double angle cosine formula through the GPU end and executing inverse cosine calculation. Taking calculation of an initial angle as an example, the corresponding trigonometric function value is:
In which For determining/>, onlyTherefore, the accuracy is not affected, the accuracy of double level can be maintained in the calculation process, and the calculation of the starting angle and the ending angle is only performed by using an inverse trigonometric function.
Similarly, for the end angleIt can also be calculated by the above calculation process, only byReplaced by/>And the method is just needed, and the description is omitted here.
S12, determining a vertex half angle value corresponding to the position information by the GPU end according to the starting angle and the ending angle and combining the position information;
further, the location information includes vertex locations and total number of vertices; s12 may comprise the sub-steps of:
The GPU end is used for calculating the quantity ratio of the vertex positions to the total quantity of the vertices;
calculating a half angle difference value of a half angle value of the ending angle and a half angle value of the starting angle through the GPU end;
Comparing the starting angle and the ending angle through the GPU end;
if the initial angle is smaller than or equal to the end angle, the GPU end calculates a first multiplication of a half angle difference value and a quantity ratio, and then the half angle value of the initial angle is overlapped to determine a vertex half angle value corresponding to the position information;
if the initial angle is larger than the end angle, calculating an angle sum value of the half angle difference value and a preset value through the GPU end;
and after the GPU side calculates a second multiplication value of the ratio of the angle sum value to the number, the half angle value of the initial angle is overlapped, and the vertex half angle value corresponding to the position information is determined.
In this embodiment, since the arc may be generally divided into an elliptical arc or an arc, it may be represented by parameter data such as a major axis, a minor axis, and a center of a circle. The long axis and the short axis in the data are mutually perpendicular, and the two axes can directly represent the plane where the arc is located due to the three-dimensional vector, so that the normal vector data of the incoming arc can be saved. The coordinates of the segment vertexes can be directly calculated by the circle center, the long and short axes and angles corresponding to the vertexes in the vertex shader.
Since the angle of the arc is always between [0,2 pi ], one half of the angle is always between [0, pi ], thereforeIs a monotonically decreasing function in the range of the value, and can combine the starting point half-angle cosine value and the end point half-angle cosine value halfCosStart, halfCosEnd to obtain the/>Limiting the range of the starting angle and the ending angle, and preventing drawing abnormality caused by running position near the starting point and the ending point due to float precision. In addition, for the special case that the initial angle of the arc is larger than the end angle, the drawing result can be correctly limited by using one half angle, when the initial angle of the arc is larger than the end angle, the arc sweeps the continuous area of [ alpha, 2 pi ] and [2 pi, 2 pi+beta ], and the area can be used for drawing the arc by/>Discussed separately. And therefore also half-angle auxiliary calculations are used in the rendering.
The vertex half angle values of the position information can be calculated by the GPU according to the number ratio of the vertex positions to the total number of the vertices, and then the half angle difference value of the half angle value of the ending angle and the half angle value of the starting angle is calculated. Further according to the initial angleAnd end angle/>Is calculated by comparing the conditions:
Wherein the preset value is pi, the vertex position is the mth vertex, the total vertex number of the arc line is n, and the initial angle is End angle is/>
S13, determining a target half-angle cosine value through the GPU end according to the vertex half-angle value and the start-stop point half-angle cosine value;
further, S13 may include the following sub-steps:
Calculating a vertex half-angle cosine value of the vertex half-angle value through the GPU end;
if the vertex designated by the position information is a starting point or an ending point, determining a starting point half-angle cosine value as a target half-angle cosine value through the GPU end;
If the vertex specified by the position information is not a starting point or an ending point, selecting a target half-angle cosine value from a preset fixed value, a vertex half-angle cosine value and a starting point half-angle cosine value by the GPU terminal according to a preset selection rule.
In the embodiment of the invention, the cosine value of the vertex half angle value is further calculated to obtain the vertex half angle cosine value, namely
And judging whether the vertex specified by the position information is a starting point or an ending point, if so, determining a starting point half-angle cosine value as a target half-angle cosine value through the GPU end, specifically, if the vertex specified by the position information is the starting point, determining the starting point half-angle cosine value as the target half-angle cosine value, and if so, determining the ending point half-angle cosine value as a template half-angle cosine value of the vertex.
In addition, if the vertex specified by the position information is not the starting point or the ending point, the GPU end can select the target half-angle cosine value from the preset fixed value, the vertex half-angle cosine value and the starting point half-angle cosine value according to a preset selection rule. Specifically, the preset selection rule may be as follows:
Wherein, The function is specifically adapted to limit a value between an upper limit and a lower limit, and to select a value between the minimum and maximum values for use when the value exceeds the range of the minimum and maximum values. It receives three parameters: minimum, preferred, maximum. In this embodiment, parameter substitution may be performed according to the following example, specifically:
S14, calculating vertex coordinates through the GPU end according to the target half angle cosine value, the circle center vector and the axis vector.
Further, the axis vector includes a long axis vector and a short axis vector; s14 may comprise the sub-steps of:
substituting the target half-angle cosine value into a preset double-angle cosine formula through the GPU end to determine the target cosine value;
performing inverse cosine calculation on the target cosine value through the GPU end to obtain a target angle;
Calculating a target sine value according to the target angle and the target half angle cosine value through the GPU terminal;
Calculating a first vector of a target cosine value and a long-axis vector through a GPU (graphics processing unit) end;
Calculating a second vector of the target sine value and the short axis vector through the GPU end;
And superposing the first vector, the second vector and the circle center vector through the GPU end to obtain a target vector serving as a vertex coordinate.
In this embodiment, the above procedure may be implemented by loading the following functions into the GPU side:
Wherein the angle of the vertex specified by the position information is The target half angle cosine value is/>Is the center vector,/>Is a long axis vector,/>Is a short axis vector,/>Is the vertex coordinates.
In another example of the present invention, prior to performing step 207, the method may further comprise the steps of:
Judging whether the vertex coordinates exceed the arc line range between the starting point and the ending point or not through the GPU end;
If yes, correcting the vertex coordinates to be within the arc range;
If not, executing a straight line drawing instruction which is called by the GPU end in response to the CPU end, and drawing straight lines to sequentially connect the vertexes of all the arcs to generate a target arc.
After the vertex coordinates of the vertex of the arc are obtained through calculation, whether the vertex coordinates are not in the arc range between the starting point and the ending point or not is judged, namely, the vertex coordinates are not between the coordinates of the starting point and the ending point, and the deviation exceeds a certain threshold value. If so, the vertex coordinates are corrected to be within the arc range, specifically, the vertex coordinates may be calculated by executing step 206 again, or the vertex coordinates may be adjusted according to a certain gradient until the vertex coordinates are within the arc range. If the vertex coordinates do not exceed the arc range, then step 207 is performed.
Step 207, calling a shader according to each vertex coordinate through the GPU end to generate a plurality of arc vertexes on the current page;
A shader refers to a device for constructing a two-dimensional or three-dimensional coordinate point in a specified shape with vertex coordinates and other related information such as data of colors or the like as input, such as a vertex shader.
In this embodiment, after the vertex coordinates are calculated according to each position information in the updated label array, the vertex coordinates are input to the shader respectively, and a plurality of arc vertices are generated on the current page by calling the shader, so as to wait for the subsequent drawing execution.
And step 208, drawing straight lines to sequentially connect the vertexes of each arc line through the GPU end in response to the straight line drawing instruction called by the CPU end, and generating a target arc line.
In this embodiment, the implementation process of step 208 is similar to that of step 105, and will not be described here again.
Referring to fig. 4, fig. 4 is an overall flowchart of an arc scaling drawing method according to an embodiment of the invention.
In this embodiment, arc and elliptical arc data are collected by the CPU end of the drawing platform, including but not limited to an arc file or a page arc, and the parameterized data of the arc are sent to the GPU and cached in the parameter buffer by the vertex shader of the GPU end. Meanwhile, the current segment numbers of all the arcs are recorded, and a label buffer array is created according to the current segment numbers and is buffered in a label buffer of the GPU side. And the CPU end of the drawing platform judges whether a page closing instruction is received currently, if so, the drawing is judged to be finished, and at the moment, the drawing page is closed. If the page closing instruction is not received, judging whether a scene scaling instruction is received or not through the CPU end, if yes, calculating a current scaling coefficient according to the screen scaling condition, updating the current segmentation number according to the scaling coefficient, creating a new label buffer array and caching the new label buffer array into a label buffer of the GPU end, sending a drawing instruction to the GPU end to draw the vertex frame by frame, monitoring whether the page closing instruction is received or not through the CPU end, and repeating the process frame by frame. In addition, when the GPU receives a drawing instruction, the parameter data in the parameter buffer at the current moment and the vertex marks in the mark buffer are read, corresponding arcs and actual segmentation numbers are determined according to the vertex marks, and then the vertex coordinates are calculated by combining trigonometric functions with the parameter data; and finally judging whether the vertex coordinates exceed the range of the starting point and the ending point one by one, if so, correcting the vertex coordinates to be in a correct range, otherwise, inputting each vertex coordinate to a subsequent shader to generate arc vertexes, and connecting each arc vertex by adopting a straight line so as to generate a sufficiently smooth target arc.
In the embodiment of the invention, the CPU end is used for acquiring the parameter data and the current segmentation number respectively corresponding to all the arcs, the CPU end is used for constructing an initial mark number array according to each current segmentation number and respectively caching the initial mark number array and each parameter data to the GPU end, the initial mark number array is updated according to the scene scaling instruction for any arc by responding to the scene scaling instruction, an updated mark number array is generated and cached to the GPU end by the CPU end, a plurality of arc vertexes are generated by the GPU end according to the updated mark number array and the parameter data, and straight lines are drawn by the GPU end to be sequentially connected with each arc vertex by responding to the straight line drawing instruction called by the CPU end, so that the target arc is generated. Generating and uploading piecewise linear data on a CPU (central processing unit) when zooming and drawing are performed each time, and performing piecewise sampling of the arc and the elliptical arc by vertex at a GPU (graphics processing unit) end by calculating and uploading the piecewise data of the arc and the elliptical arc in real time at the CPU end, so that loads of the CPU end and the GPU end are balanced, and the overall drawing efficiency is ensured; and the positions of the starting point and the ending point are accurately calculated by matching with a trigonometric function in the drawing process, so that drawing running caused by float precision is prevented, the accuracy of a drawing result is ensured, redundant data is reduced, and the drawing efficiency is effectively improved.
Referring to fig. 5, fig. 5 is a block diagram illustrating an arc scaling drawing apparatus according to an embodiment of the present invention.
The embodiment of the invention provides an arc scaling drawing device, which is applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, and the device comprises:
the data acquisition module 501 is configured to acquire, by using a CPU end, parameter data and a current segment number corresponding to all arcs respectively;
the data caching module 502 is configured to construct an initial index array according to each current segment number through the CPU end, and cache each initial index array and each parameter data to the GPU end respectively;
The data updating module 503 is configured to respond to a scene scaling instruction for any arc, update, by the CPU end, the initial tag array according to the scene scaling instruction, generate an updated tag array, and cache the updated tag array to the GPU end;
The vertex generation module 504 is configured to generate, by using the GPU end, a plurality of arc vertices according to the updated index array and the parameter data;
The vertex connection module 505 is configured to respond to a line drawing instruction called by the CPU through the GPU, and draw a line to connect vertices of each arc in sequence, so as to generate a target arc.
The embodiment of the invention provides a computer device, which comprises a memory and a processor, wherein the memory stores a computer program, and the computer program when executed by the processor causes the processor to execute the steps of the arc scaling drawing method according to any embodiment of the invention.
An embodiment of the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed, implements an arc scaling rendering method according to any embodiment of the present invention.
Schematically, as shown in fig. 6, fig. 6 is a schematic internal structure of a computer device according to an embodiment of the present invention, and the computer device 600 may be provided as a server. Referring to FIG. 6, a computer device 600 includes a processing component 602 that further includes one or more processors and memory resources represented by a memory 601 for storing instructions, such as applications, executable by the processing component 602. The application program stored in the memory 601 may include one or more modules each corresponding to a set of instructions. Further, the processing component 602 is configured to execute instructions to perform the text recognition method of any of the embodiments described above.
The computer device 600 may also include a power component 603 configured to perform power management of the computer device 600, a wired or wireless network interface 604 configured to connect the computer device 600 to a network, and an Input Output (IO) interface 605. The computer device 600 may operate based on storage.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus and modules described above may refer to the corresponding process in the foregoing method embodiment, which is not repeated herein.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical, mechanical or other form.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (13)

1. An arc scaling drawing method is characterized by being applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, and the method comprises the following steps:
Acquiring parameter data and current segmentation number respectively corresponding to all arcs through the CPU end;
constructing an initial label array according to the current segmentation number through the CPU end, and respectively caching the initial label array and the parameter data to the GPU end;
responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
Generating a plurality of arc vertexes by the GPU end according to the updated index array and the parameter data;
Drawing straight lines by the GPU end in response to the straight line drawing instruction called by the CPU end, and sequentially connecting the straight lines with the vertexes of the arcs to generate a target arc;
the response to the scene scaling instruction for any arc line updates the initial label array according to the scene scaling instruction by the CPU end, generates an updated label array and caches the updated label array to the GPU end, and comprises the following steps:
Responding to a scene scaling instruction aiming at any arc, acquiring a scaling coefficient corresponding to the scene scaling instruction through the CPU end, and positioning a target label in the initial label array;
calculating the multiplication value of the scaling factor and the current segmentation number through the CPU end to obtain an updated segmentation number;
generating a plurality of update labels according to the update segmentation number through the CPU end;
and replacing and updating the target label by adopting all the updated labels through the CPU end, generating an updated label array and caching the updated label array to the GPU end.
2. The method according to claim 1, wherein the method further comprises:
If the scene scaling instruction is not received, determining the initial index array as an updated index array through the GPU end;
and executing the jump, wherein the GPU side generates a plurality of arc vertexes according to the updated label array and the parameter data.
3. The method according to claim 1, wherein said constructing, by the CPU side, an initial tag array according to each of the current segment numbers, and buffering each of the initial tag array and each of the parameter data to the GPU side, respectively, includes:
Generating a plurality of groups of label data according to the number of the arcs through the CPU end; the label data comprises vertex labels equal to the number of the current segments;
tiling all the vertex labels into a digital array form through the CPU end to obtain an initial label array;
And caching the initial index array to an index buffer area in the GPU end through the CPU end, and caching each parameter data to a parameter buffer area in the GPU end.
4. The method according to claim 1, wherein generating, by the GPU side, a plurality of arc vertices according to the updated index array and the parameter data, comprises:
Positioning a target arc line according to the position information of the update mark in the update mark array by the GPU terminal;
reading parameter data corresponding to the target arc line as target parameter data through the GPU terminal;
Determining a plurality of vertex coordinates by the GPU terminal based on the position information and the target parameter data;
And calling a shader by the GPU terminal according to each vertex coordinate to generate a plurality of arc vertexes on the current page.
5. The method of claim 4, wherein the target parameter data comprises a center vector, an axis vector, and a start-stop point half angle cosine value; the determining, by the GPU side, a plurality of vertex coordinates based on the location information and the target parameter data, including:
Respectively calculating the starting angle and the ending angle of the target arc line by the GPU end according to the cosine value of the half angle of the start point and the half angle of the stop point;
Determining a vertex half-angle value corresponding to the position information by the GPU side according to the starting angle and the ending angle and combining the position information;
determining a target half-angle cosine value by the GPU end according to the vertex half-angle value and the start-stop point half-angle cosine value;
And calculating vertex coordinates by the GPU end according to the target half angle cosine value, the circle center vector and the axis vector.
6. The method of claim 5, wherein the start-stop point half angle cosine values include a start-point half angle cosine value and an end-point half angle cosine value; the step of calculating, by the GPU end, the start angle and the end angle of the target arc according to the cosine values of the start and stop point half angles, respectively, includes:
substituting the starting point half angle cosine value into a double angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain the starting angle of the target arc line;
substituting the end point half angle cosine value into a double angle cosine formula through the GPU end, and executing inverse cosine calculation to obtain the end angle of the target arc line.
7. The method of claim 5, wherein the location information comprises vertex locations and total number of vertices; the determining, by the GPU side, a vertex half angle value corresponding to the position information according to the start angle and the end angle in combination with the position information includes:
The GPU end is used for obtaining the quantity ratio of the vertex positions to the total quantity of the vertices;
calculating a half angle difference value of the half angle value of the ending angle and the half angle value of the starting angle through the GPU end;
Comparing the starting angle with the ending angle through the GPU end;
if the initial angle is smaller than or equal to the end angle, the GPU end calculates a first multiplication value of the half angle difference value and the quantity ratio, and then the half angle value of the initial angle is overlapped to determine a vertex half angle value corresponding to the position information;
If the starting angle is larger than the ending angle, calculating an angle sum value of the half angle difference value and a preset value through the GPU end;
And after the GPU side calculates a second multiplication value of the ratio of the angle sum value to the number, the half angle value of the initial angle is overlapped, and the vertex half angle value corresponding to the position information is determined.
8. The method according to claim 5, wherein the determining, by the GPU side, a target half angle cosine value from the vertex half angle value and the start-stop point half angle cosine value comprises:
Calculating a vertex half-angle cosine value of the vertex half-angle value through the GPU end;
if the vertex appointed by the position information is a starting point or an ending point, determining the starting point half-angle cosine value as a target half-angle cosine value through the GPU end;
If the vertex specified by the position information is not a starting point or an ending point, selecting a target half-angle cosine value from a preset value, the vertex half-angle cosine value and the starting and ending point half-angle cosine value by the GPU terminal according to a preset selection rule.
9. The method of claim 5, wherein the axis vector comprises a long axis vector and a short axis vector; the calculating, by the GPU side, vertex coordinates according to the target half angle cosine value, the center vector, and the axis vector, includes:
substituting the target half angle cosine value into a preset double angle cosine formula through the GPU end to determine a target cosine value;
performing inverse cosine calculation on the target cosine value through the GPU end to obtain a target angle;
calculating a target sine value by the GPU end according to the target angle and the target half-angle cosine value;
Calculating a first vector of the target cosine value and the long-axis vector through the GPU end;
Calculating a second vector of the target sine value and the short axis vector by the GPU side
And superposing the first vector, the second vector and the circle center vector through the GPU end to obtain a target vector serving as a vertex coordinate.
10. The method of claim 5, wherein prior to executing the invoking a shader by the GPU side according to each of the vertex coordinates to generate a plurality of arc vertices on a current page, the method further comprises:
Judging whether the vertex coordinates exceed an arc line range between a starting point and an ending point or not through the GPU end;
If yes, correcting the vertex coordinates to be within the arc range;
if not, executing a straight line drawing instruction which is called by the GPU end in response to the CPU end, and drawing straight lines to sequentially connect the arc vertexes to generate a target arc.
11. An arc scaling drawing device, characterized by being applied to a drawing platform, wherein the drawing platform comprises a CPU end and a GPU end, the device comprising:
the data acquisition module is used for acquiring parameter data and the current segmentation number which respectively correspond to all the arcs through the CPU end;
The data caching module is used for constructing an initial index array according to the current segmentation number through the CPU end and caching the initial index array and the parameter data to the GPU end respectively;
the data updating module is used for responding to a scene scaling instruction aiming at any arc, updating the initial label array through the CPU end according to the scene scaling instruction, generating an updated label array and caching the updated label array to the GPU end;
the vertex generation module is used for generating a plurality of arc vertices through the GPU end according to the updated label array and the parameter data;
The vertex connection module is used for responding to a straight line drawing instruction called by the CPU end through the GPU end, drawing straight lines to sequentially connect the vertexes of the arcs, and generating a target arc;
the data updating module is specifically configured to:
Responding to a scene scaling instruction aiming at any arc, acquiring a scaling coefficient corresponding to the scene scaling instruction through the CPU end, and positioning a target label in the initial label array;
calculating the multiplication value of the scaling factor and the current segmentation number through the CPU end to obtain an updated segmentation number;
generating a plurality of update labels according to the update segmentation number through the CPU end;
and replacing and updating the target label by adopting all the updated labels through the CPU end, generating an updated label array and caching the updated label array to the GPU end.
12. A computer device comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to perform the steps of the arc scaling rendering method of any one of claims 1-10.
13. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed implements the arc scaling rendering method of any one of claims 1-10.
CN202410034117.5A 2024-01-10 2024-01-10 Arc scaling drawing method, device, equipment and medium Active CN117541461B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410034117.5A CN117541461B (en) 2024-01-10 2024-01-10 Arc scaling drawing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410034117.5A CN117541461B (en) 2024-01-10 2024-01-10 Arc scaling drawing method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN117541461A CN117541461A (en) 2024-02-09
CN117541461B true CN117541461B (en) 2024-05-10

Family

ID=89784679

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410034117.5A Active CN117541461B (en) 2024-01-10 2024-01-10 Arc scaling drawing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117541461B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011253289A (en) * 2010-06-01 2011-12-15 Renesas Electronics Corp Curve drawing device, curve drawing method and curve drawing program
CN110286827A (en) * 2019-06-27 2019-09-27 广州视源电子科技股份有限公司 A kind of element zoom control method, device, equipment and storage medium
CN113763509A (en) * 2021-09-08 2021-12-07 中科三清科技有限公司 Trace graph drawing method and device
CN115619894A (en) * 2021-07-08 2023-01-17 荣耀终端有限公司 Icon rounded angle processing method and device
CN116048692A (en) * 2022-12-21 2023-05-02 博泰车联网(南京)有限公司 Progress bar drawing method and device and electronic equipment
CN116152411A (en) * 2022-12-16 2023-05-23 深圳市博思云创科技有限公司 Graphics rendering method, graphics rendering device, electronic equipment and storage medium
CN117173276A (en) * 2023-07-13 2023-12-05 南京维拓科技股份有限公司 TRIZ drawing implementation method based on Antv/X6

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11989807B2 (en) * 2021-09-10 2024-05-21 Adobe Inc. Rendering scalable raster content

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011253289A (en) * 2010-06-01 2011-12-15 Renesas Electronics Corp Curve drawing device, curve drawing method and curve drawing program
CN110286827A (en) * 2019-06-27 2019-09-27 广州视源电子科技股份有限公司 A kind of element zoom control method, device, equipment and storage medium
CN115619894A (en) * 2021-07-08 2023-01-17 荣耀终端有限公司 Icon rounded angle processing method and device
CN113763509A (en) * 2021-09-08 2021-12-07 中科三清科技有限公司 Trace graph drawing method and device
CN116152411A (en) * 2022-12-16 2023-05-23 深圳市博思云创科技有限公司 Graphics rendering method, graphics rendering device, electronic equipment and storage medium
CN116048692A (en) * 2022-12-21 2023-05-02 博泰车联网(南京)有限公司 Progress bar drawing method and device and electronic equipment
CN117173276A (en) * 2023-07-13 2023-12-05 南京维拓科技股份有限公司 TRIZ drawing implementation method based on Antv/X6

Also Published As

Publication number Publication date
CN117541461A (en) 2024-02-09

Similar Documents

Publication Publication Date Title
US8773439B2 (en) Approximation of stroked higher-order curved segments by quadratic bèzier curve segments
US10943375B2 (en) Multi-state vector graphics
US20140218353A1 (en) Image group processing and visualization
CN115409933B (en) Multi-style texture mapping generation method and device
CN114820905B (en) Virtual image generation method and device, electronic equipment and readable storage medium
US10535188B2 (en) Tessellation edge shaders
JP2017182302A (en) Image processing program, image processing apparatus, and image processing method
GB2478626A (en) Index-based shared patch edge processing
CN113012269A (en) Three-dimensional image data rendering method and equipment based on GPU
CN108122266A (en) A kind of method, apparatus and storage medium for caching skeleton cartoon and rendering texture
US8438199B1 (en) System and method for identifying and highlighting a graphic element
CN117541461B (en) Arc scaling drawing method, device, equipment and medium
CN106445445B (en) Vector data processing method and device
CN113538623A (en) Method and device for determining target image, electronic equipment and storage medium
CN113516697A (en) Image registration method and device, electronic equipment and computer-readable storage medium
US11392806B2 (en) Differentiable rasterizer for vector font generation and editing
CN113034582A (en) Pose optimization device and method, electronic device and computer readable storage medium
CN110264546B (en) Image synthesis method and device, computer-readable storage medium and terminal
CN112419430A (en) Animation playing method and device and computer equipment
CN115409951B (en) Image processing method, image processing device, electronic equipment and storage medium
CN114549303B (en) Image display method, image processing method, image display device, image processing apparatus, image display device, image processing program, and storage medium
Yang et al. CAD data visualization on mobile devices using sequential constrained Delaunay triangulation
CN114020390A (en) BIM model display method and device, computer equipment and storage medium
CN114240737A (en) Method, apparatus, device and medium for generating digital model from drawings
CN112988609A (en) Data processing method, device, storage medium and client

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