CN111260750A - Method and device for processing openFL drawn vector graphics and electronic equipment - Google Patents

Method and device for processing openFL drawn vector graphics and electronic equipment Download PDF

Info

Publication number
CN111260750A
CN111260750A CN202010019745.8A CN202010019745A CN111260750A CN 111260750 A CN111260750 A CN 111260750A CN 202010019745 A CN202010019745 A CN 202010019745A CN 111260750 A CN111260750 A CN 111260750A
Authority
CN
China
Prior art keywords
vector
vector diagram
openfl
graphics
user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010019745.8A
Other languages
Chinese (zh)
Other versions
CN111260750B (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.)
Guangdong 3vjia Information Technology Co Ltd
Original Assignee
Guangdong 3vjia Information Technology 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 Guangdong 3vjia Information Technology Co Ltd filed Critical Guangdong 3vjia Information Technology Co Ltd
Priority to CN202010019745.8A priority Critical patent/CN111260750B/en
Publication of CN111260750A publication Critical patent/CN111260750A/en
Application granted granted Critical
Publication of CN111260750B publication Critical patent/CN111260750B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention provides a processing method and a device for drawing a vector graph by an openFL (open field communication) and electronic equipment, and relates to the technical field of computers, wherein the method comprises the steps of analyzing a drawing command to acquire graphic information of the vector graph by the openFL when the drawing command triggered by a user is detected; the graphic information of the vector diagram includes path points constituting the vector diagram; triangularizing the vector diagram through openFL based on path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram; and rendering a plurality of triangular surfaces of the vector diagram through a preset open graphic library. According to the invention, the openFL is used for replacing flash to perform the processing of drawing the vector graphics, so that the processing efficiency of the openFL during the vector graphics drawing is effectively improved, and the memory consumption is reduced.

Description

Method and device for processing openFL drawn vector graphics and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for processing openFL drawn vector graphics and electronic equipment.
Background
When the home software is customized, a user interface UI can use a fillet button and an SVG control, and the complex 2D drawing functions depend on a flash vector graphic drawing interface, wherein the complex 2D drawing functions comprise special-shaped bricks and water jet cutting graphic bricks used in the brick laying service function of the home software. However, if the flash is to be detached from the web, the html5 or WebAssembly is changed, and the platform is expanded to a desktop cross-platform, so that the platform needs to be replaced by openFL. However, the cario library rendering used by the existing openFL is implemented by writing bit pixels through a CPU algorithm, but when a user zooms a 2D scene back and forth, the user needs to repeatedly apply for a new bitmap and draw a graph on the newly applied bitmap, which causes a situation of large memory consumption, and in addition, when the bitmap is large or the number of drawn graphs is too large, the time consumption is great during drawing calculation, which causes an obvious pause in zooming operation.
Disclosure of Invention
The invention aims to provide a processing method and device for drawing a vector graph by using an openFL and electronic equipment, so as to solve the technical problems of high time consumption and high memory occupation in drawing calculation when the openFL is used for replacing flash.
In a first aspect, an embodiment provides a processing method for an openFL drawing vector graphic, the method including: when a drawing command triggered by a user is detected, analyzing the drawing command through openFL to obtain graphic information of a vector diagram; the graphic information of the vector diagram includes path points constituting the vector diagram; triangularizing the vector diagram through openFL based on path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram; and rendering a plurality of triangular surfaces of the vector diagram through a preset open graphic library.
In an optional implementation mode, the vector Graphics are stored in Graphics classes of a preset open Graphics library; when a drawing command triggered by a user is detected, analyzing the drawing command through the openFL to acquire graphic information of the vector diagram, wherein the step comprises the following steps of: when a drawing command triggered by a user is detected, the drawing command is analyzed through the openFL, and therefore vector graphic information in Graphics classes of a preset open graphic library is obtained.
In an alternative embodiment, the vector diagram comprises a curvilinear figure; the method further comprises the following steps: and dividing the curve graph to obtain a plurality of sections of straight lines based on a cubic Bezier curve equation, so that the openFL triangulates the vector diagram based on the end point of each section of straight line.
In an alternative embodiment, the vector map comprises convex polygons, concave polygons, or self-intersecting polygons; the method comprises the following steps of triangularizing a vector diagram through openFL based on path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram, wherein the steps comprise: if the vector diagram is a convex polygon, a plurality of triangular surfaces are obtained through openFL based on path points of the convex polygon; if the vector diagram is a concave polygon, carrying out triangulation based on an ear cutting method, and obtaining a plurality of triangular surfaces through openFL; if the vector diagram is an inbred polygon, triangularization is carried out according to an odd-even rule or a non-zero winding rule, and a plurality of triangular surfaces are obtained through openFL.
In an alternative embodiment, the graphics information of the vector graphics further comprises a fill color of the vector graphics set by the user; the method comprises the following steps of rendering a plurality of triangular surfaces of a vector diagram through a preset open graphic library, wherein the steps comprise: calculating the UV coordinates of the vertex of each triangular surface of the vector diagram; and judging whether a user triggers a transformation instruction, if so, transforming according to a preset transformation mode based on the UV coordinate and a preset transformation matrix to obtain a transformed triangular surface, and rendering the transformed triangular surface according to the filling color of the vector diagram set by the user through a preset open graphic library.
In an optional embodiment, the graphic information of the vector diagram further comprises line widths of lines in the vector diagram set by a user; the method further comprises the following steps: determining a vertical vector of a line in the vector diagram based on a first end point of the line in the vector diagram and the line width of the line in the vector diagram set by a user, and drawing the line based on the path point and the vertical vector; the line drawing includes line drawing of a closed curve and line drawing of a non-closed curve.
In an alternative embodiment, the method further comprises: scaling the vector diagram; the step of scaling the vector image comprises: determining a type of a zoom mode; the types of the zooming mode comprise a common mode and a line non-zooming mode; judging whether the zooming mode is a line non-zooming mode; if yes, the line width is inversely scaled when the scaling operation is performed.
In an alternative embodiment, the method further comprises: performing template test before drawing by a user, and starting drawing if the current template value is equal to a pre-recorded template value; the pre-recorded template value comprises a template value recorded when the current graph drawn by the user is used as a mask.
In a second aspect, an embodiment provides a processing apparatus for drawing a vector graphic by openFL, the apparatus includes: the analysis module is used for analyzing the drawing command through the openFL to acquire graphic information of the vector diagram when the drawing command triggered by the user is detected; the graphic information of the vector diagram includes path points constituting the vector diagram; the triangulation processing module is used for triangulating the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram; and the rendering module is used for rendering a plurality of triangular surfaces of the vector diagram through a preset open graphic library.
In a third aspect, an embodiment provides an electronic device, including a processor and a memory; the memory has stored thereon a computer program which, when executed by the processor, performs the method according to any of the preceding embodiments.
In a fourth aspect, embodiments provide a computer readable storage medium for storing computer software instructions for a method according to any one of the preceding embodiments.
According to the processing method, device and electronic equipment for drawing the vector graphics by the openFL, when a drawing command triggered by a user is detected, the drawing command is analyzed by the openFL to obtain the graphic information (including path points forming the vector graphics) of the vector graphics, the vector graphics are triangulated by the openFL based on the path points of the vector graphics to obtain a plurality of triangular surfaces of the vector graphics, and therefore the plurality of triangular surfaces of the vector graphics are rendered through a preset open graphic library. The method has the advantages that the plurality of triangular surfaces are obtained by triangularization of the path points based on the vector graphics, when the graphics drawn by a user are processed, the graphics are drawn, rendered and the like based on the vertexes of the triangular surfaces, a new bitmap does not need to be applied for drawing during each processing, drawing efficiency is improved, and meanwhile consumption of memory is reduced. The embodiment of the invention effectively improves the processing efficiency of the openFL when the vector graphics are drawn, and simultaneously reduces the memory consumption.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flow chart of a processing method for drawing a vector graphic by an openFL according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of another processing method for rendering vector graphics by openFL according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a processing apparatus for drawing a vector graphic by an openFL according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Some embodiments of the invention are described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
The openFL is a Flash API realized by a Haxe programming language, and the method, the device and the electronic equipment for processing openFL drawn vector graphics are provided by the embodiment of the invention, so that the processing efficiency of openFL drawing vector graphics can be effectively improved, and the memory consumption is reduced at the same time.
For convenience of understanding, first, a detailed description is given to a processing method for drawing a vector graphic by an openFL according to an embodiment of the present invention, referring to a schematic flow chart of the processing method for drawing a vector graphic by an openFL shown in fig. 1, where an execution subject of the method is an electronic device such as a computer, and the method mainly includes the following steps S102 and S106:
step S102: when a drawing command triggered by a user is detected, analyzing the drawing command through openFL to obtain graphic information of a vector diagram; the graphic information of the vector diagram includes path points constituting the vector diagram;
in an implementation manner, the drawing command triggered by the user may include drawing Graphics, lines, filling colors, and the like, when the computer detects that the user triggers the drawing command, the drawing command triggered by the user is analyzed through openFL (flash API implemented based on Haxe programming language), and as the vector Graphics are stored in Graphics classes of a preset open Graphics library, the drawing command is called through the Graphics classes through a user interface, the Graphics classes are transmitted to VGGraphics to analyze the drawing command triggered by the user, so that vector Graphics information in the Graphics classes of the preset open Graphics library can be acquired.
Step S104: and triangularizing the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram.
In one embodiment, the path points of the vector diagram are points constituting the vector diagram, the vector diagram is determined by a plurality of path points operated by a user, the graphics defined by the user (namely, the vector diagram) is triangulated by OpenFL, the vector diagram can be further divided into finer lines, and the vector diagram is divided into a plurality of triangular surfaces by connecting end points of the lines.
Step S106: and rendering a plurality of triangular surfaces of the vector diagram through a preset open graphic library.
In an embodiment, vertex coordinates (i.e., UV coordinates) of a plurality of triangular surfaces of a triangulated vector diagram are calculated, a preset Open Graphics Library may be OpenGL (Open Graphics Library), the triangular surfaces are transmitted to OpenGL through openFL, so that the triangular surfaces can be identified and rendered through a graph api OpenGL, and a shader in the OpenGL renders the plurality of triangular surfaces obtained after the vector diagram is triangulated according to a setting of a user, so that a GPU hardware acceleration effect is achieved when the vector diagram is drawn.
The method for processing the openFL drawn vector graphics comprises the steps of analyzing a drawing command through the openFL to obtain graphic information (including path points forming a vector diagram) of the vector diagram when the drawing command triggered by a user is detected, triangularizing the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram, and rendering the plurality of triangular surfaces of the vector diagram through a preset open graphic library. The method has the advantages that the plurality of triangular surfaces are obtained by triangularization of the path points based on the vector graphics, when the graphics drawn by a user are processed, the graphics are drawn, rendered and the like based on the vertexes of the triangular surfaces, a new bitmap does not need to be applied for drawing during each processing, drawing efficiency is improved, and meanwhile consumption of memory is reduced. The embodiment of the invention effectively improves the processing efficiency of the openFL when the vector graphics are drawn, and simultaneously reduces the memory consumption.
In order to facilitate understanding of the function of drawing vector graphics by replacing flash with openFL, refer to a schematic flow diagram of another processing method for drawing vector graphics by openFL as shown in fig. 2, the method mainly includes: and analyzing a drawing command triggered by a user through the openFL, realizing a mask function, generating a triangular surface and submitting the triangular surface to the openGL for rendering. Specifically, the mask function is realized by adding 1 to the template value if the current graph is used as the mask of the other graphs, and performing template test if the other graphs are set as the masks of the current graph, wherein the template test can be performed after the test is passed. The generation of the triangular surface mainly comprises a line mode generation triangular surface and a filling mode generation triangular surface, wherein in the line mode, two different kinds of processing can be carried out according to a closed line and a non-closed line, in the filling mode, different processing can be carried out according to the types of polygons, such as a convex polygon, a concave polygon and an inbred polygon, in addition, in the filling mode, color filling and picture filling are further included, the triangular surface is generated by generating UV coordinates through the vertex of the triangular surface, and finally the generated triangular surface is submitted to OpenGL for rendering. This process will be described in detail below.
In one embodiment, the rendered 2D graphic may clip an area that, after setting the mask clip area, is not displayable if other graphics are rendered beyond this graphic. It is therefore required to process through stencil testing of the graphics API (i.e., openGL), if the current graphic is masked as another graphic, the graphic as the mask is prohibited from being drawn to the color buffer, drawn to the stencil buffer, for the stencil value +1, and the current stencil value is recorded. In the subsequent drawing, firstly, a template test is carried out, and if the current template value is equal to a pre-recorded template value, the drawing is started, wherein the pre-recorded template value is the template value recorded when the current graph drawn by the user is used as a mask. In addition, if the user uses off-screen rendering, in the presence of the mask, it is necessary to attach a stencil buffer to the FBO (frame buffer object) when applying for the FBO of openGL.
In one embodiment, the graphic information of the vector diagram further comprises line widths of lines in the vector diagram set by a user; after the user draws a line, a vertical vector is calculated through a vector generated from a current point to a next point, and then a parallel line on the upper side and a parallel line on the lower side of the vertical vector are obtained upwards and downwards according to the line width set by the user, so that a line corresponding to the line width set by the user is obtained.
In addition, the vector diagram drawn by the user can also comprise a curve diagram, and because a quadratic bezier, an ellipse and a circle can be converted into a cubic bezier curve, the curve is segmented to obtain a plurality of straight lines based on a cubic bezier curve equation, for example, the curve is substituted into the cubic bezier equation, the curve is advanced by a plurality of distances each time, the plurality of advanced distances can be set according to actual requirements, and the shorter the interval is, the better the smoothing effect is, so that openFL triangulates the vector diagram through the end points of the segmented straight lines.
In one embodiment, the filling drawing implemented by the openFL first needs to be triangulated, polygons in a vector diagram include convex polygons, concave polygons or self-intersected polygons, different modes of triangulation are adopted for different types of polygons, if the vector diagram is a convex polygon, such as a rectangle, a triangle, etc., and fan-shaped drawing is adopted, the first point of a path point of the convex polygon is used as a circle center, and other points are connected, one or more triangular surfaces can be generated, and a plurality of triangular surfaces are obtained by the openFL; if the vector diagram is a concave polygon, triangulation can be performed based on an ear-cutting method (a polygon triangulation algorithm), and then triangular surfaces are subdivided. If the vector diagram is an inbred polygon, triangularization is carried out according to an odd-even rule or a non-zero winding rule, specifically, an external ray is generated at any point in the region, the intersection times of the ray and the polygon edge are counted by +1 according to the odd-even rule, if the newly obtained intersection times are odd numbers, the overlapping region is filled, and if the newly obtained intersection times are even numbers, the overlapping region is not filled; according to the non-zero rule, if the ray is wound clockwise and the edge of the polygon is intersected with the count +1, the ray is wound anticlockwise and the edge of the polygon is intersected with the count-1, and the count is filled when the count is not zero. Since the C library libtess2 can process the triangularization of the complex polygon, the C library libtess2 can be newly compiled into the openFL to obtain a plurality of triangular surfaces through the openFL, and then the triangular surfaces are called through a native CFFI interface.
In one embodiment, the graphic information of the vector graphics drawn by the user further includes a fill color of the vector graphics set by the user; after the vector diagram (including a convex polygon, a concave polygon or an inbred polygon) is triangulated to obtain a plurality of triangular surfaces, the plurality of triangular surfaces of the vector diagram are rendered through a preset open graphics library (also called OpenGL), the position of the vertex of each triangular surface on the diagram needs to be determined, firstly, the UV coordinate of the vertex of each triangular surface of the vector diagram is calculated, U and V are respectively the coordinates of the picture in the horizontal direction and the vertical direction of a display, the values are generally 0-1, namely (the U pixel/picture width in the horizontal direction and the V pixel/picture height in the vertical direction), each picture can also be provided with a transformation matrix (used for carrying out operations such as transformation or translation) to judge whether a user triggers a transformation instruction or not, if so, calculating an inverse matrix of the transformation matrix, the inverse matrix transforming the vertices of the triangular surface, then, the picture filling with the same effect as the flash can be obtained by adding the width and the height of the picture set by the user.
In one embodiment, the vector diagram is further scaled by processing a scaling mode through an openFL, and the vector diagram can be processed by determining the type of the scaling mode, where the type of the scaling mode includes a normal mode and a line non-scaling mode, if the mode is the normal mode, scaling a triangular surface mesh, transforming by introducing a world transformation Matrix into a vertex shader of a shader in the openGL, if the mode is the line non-scaling mode, since the line width is not scaled together, it is necessary to recalculate the whole line triangularization each time, and inversely scale the line width, so that the scaling line width is kept from being scaled together, the required scaling value is stored in an a component and a component of a Matrix of the world transformation Matrix, the Matrix identifies a transformation Matrix, the a component and the d component are attributes of the Matrix, and the component a affects the positioning of pixels along the x axis when the image is scaled or rotated, d is the position of the affected pixel along the y-axis when scaling or rotating the image.
For the processing method of the openFL drawn vector graphics, an embodiment of the present invention further provides a processing apparatus for openFL drawn vector graphics, referring to a schematic structural diagram of the processing apparatus for openFL drawn vector graphics as shown in fig. 3, the apparatus mainly includes the following parts:
the analyzing module 302 is configured to, when a drawing command triggered by a user is detected, analyze the drawing command through an openFL to obtain graphic information of a vector diagram; the graphics information of the vector image includes waypoints constituting the vector image.
And the triangulation processing module 304 is used for triangulating the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram.
And the rendering module 306 is configured to render the plurality of triangular surfaces of the vector diagram through a preset open graphics library.
When a drawing command triggered by a user is detected, the openFL analyzes the drawing command to obtain graphic information (including path points forming the vector diagram) of the vector diagram, and triangularizes the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram, so that the plurality of triangular surfaces of the vector diagram are rendered through a preset open graphic library. The method has the advantages that the plurality of triangular surfaces are obtained by triangularization of the path points based on the vector graphics, when the graphics drawn by a user are processed, the graphics are drawn, rendered and the like based on the vertexes of the triangular surfaces, a new bitmap does not need to be applied for drawing during each processing, drawing efficiency is improved, and meanwhile consumption of memory is reduced. The embodiment of the invention effectively improves the processing efficiency of the openFL when the vector graphics are drawn, and simultaneously reduces the memory consumption.
In an embodiment, the vector Graphics are stored in Graphics classes of a preset open Graphics library, and the parsing module 302 is further configured to parse the drawing command through openFL when the drawing command triggered by the user is detected, so as to obtain vector Graphics information in the Graphics classes of the preset open Graphics library.
In one embodiment, the vector graphics comprise curvilinear graphics, the apparatus further comprising: and the curve segmentation module is used for segmenting the curve graph based on a cubic Bezier curve equation to obtain a plurality of sections of straight lines so that the openFL triangulates the vector diagram based on the end point of each section of straight line.
In one embodiment, the vector map comprises convex polygons, concave polygons, or selfed polygons; the triangulation processing module 304 is further configured to obtain a plurality of triangular surfaces through openFL based on path points of a convex polygon if the vector diagram is the convex polygon; if the vector diagram is a concave polygon, carrying out triangulation based on an ear cutting method, and obtaining a plurality of triangular surfaces through openFL; if the vector diagram is an inbred polygon, triangularization is carried out according to an odd-even rule or a non-zero winding rule, and a plurality of triangular surfaces are obtained through openFL.
In one embodiment, the graphics information of the vector graphics further includes filling colors of the vector graphics set by a user, and the rendering module 306 is further configured to calculate UV coordinates of vertices of each triangular surface of the vector graphics; and judging whether a user triggers a transformation instruction, if so, transforming according to a preset transformation mode based on the UV coordinate and a preset transformation matrix to obtain a transformed triangular surface, and rendering the transformed triangular surface according to the filling color of the vector diagram set by the user through a preset open graphic library.
In one embodiment, the graphics information of the vector graphics further comprises line widths of lines in the vector graphics set by a user, the apparatus further comprising: the line drawing module is used for determining a vertical vector of a line in the vector diagram based on a first end point of the line in the vector diagram and the line width of the line in the vector diagram set by a user, and drawing the line based on the path point and the vertical vector; the line drawing includes line drawing of a closed curve and line drawing of a non-closed curve.
In one embodiment, the apparatus further comprises: a scaling module for determining a type of a scaling mode; the types of the zooming mode comprise a common mode and a line non-zooming mode; judging whether the zooming mode is a line non-zooming mode; if yes, the line width is inversely scaled when the scaling operation is performed.
In one embodiment, the apparatus further comprises: the template testing module is used for testing a template before the user draws the template, and if the current template value is equal to the template value recorded in advance, drawing is started; the pre-recorded template value comprises a template value recorded when the current graph drawn by the user is used as a mask.
The device is an electronic device, and particularly, the electronic device comprises a processor and a storage device; the storage means has stored thereon a computer program which, when executed by the processor, performs the method of any of the above described embodiments.
Fig. 4 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present invention, where the electronic device 100 includes: a processor 40, a memory 41, a bus 42 and a communication interface 43, wherein the processor 40, the communication interface 43 and the memory 41 are connected through the bus 42; the processor 40 is arranged to execute executable modules, such as computer programs, stored in the memory 41.
The memory 41 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 43 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
The bus 42 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
The memory 41 is used for storing a program, the processor 40 executes the program after receiving an execution instruction, and the method executed by the apparatus defined by the flow process disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 40, or implemented by the processor 40.
The processor 40 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 40. The Processor 40 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory 41, and the processor 40 reads the information in the memory 41 and completes the steps of the method in combination with the hardware thereof.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A processing method for drawing vector graphics by openFL is characterized by comprising the following steps:
when a drawing command triggered by a user is detected, analyzing the drawing command through the openFL to acquire graphic information of a vector diagram; the graphics information of the vector graphics includes path points that constitute the vector graphics;
triangularizing the vector diagram through the openFL based on path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram;
and rendering the plurality of triangular surfaces of the vector diagram through a preset open graphic library.
2. The method according to claim 1, characterized in that the graphic information of the vector Graphics is stored in Graphics class of the preset open Graphics library; when a drawing command triggered by a user is detected, analyzing the drawing command through the openFL to acquire graphic information of a vector diagram, wherein the step comprises the following steps of:
when a drawing command triggered by a user is detected, analyzing the drawing command through the openFL so as to obtain the graphic information of the vector diagram in the Graphics class of the preset open graphic library.
3. The method of claim 1 wherein said vector graphics comprises curvilinear graphics; the method further comprises the following steps:
and dividing the curve graph to obtain a plurality of sections of straight lines based on a cubic Bezier curve equation, so that the openFL triangulates the vector diagram based on the end point of each section of the straight line.
4. The method of claim 1 wherein said vector graphics comprise convex polygons, concave polygons, or self-intersecting polygons; the step of triangulating the vector diagram by the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram includes:
if the vector diagram is the convex polygon, obtaining a plurality of triangular surfaces through the openFL based on the path points of the convex polygon;
if the vector diagram is the concave polygon, carrying out triangulation based on an ear cutting method, and obtaining a plurality of triangular surfaces through the openFL;
and if the vector diagram is the selfing polygon, carrying out triangulation according to an odd-even rule or a non-zero winding rule, and obtaining a plurality of triangular surfaces through the openFL.
5. The method according to claim 1 characterized in that said vector graphics information further comprises user-set fill colors for said vector graphics; the step of rendering the plurality of triangular surfaces of the vector diagram through a preset open graphic library includes:
calculating the UV coordinates of the vertex of each triangular surface of the vector diagram;
and judging whether the user triggers a transformation instruction, if so, transforming according to a preset transformation mode based on the UV coordinate and a preset transformation matrix to obtain a transformed triangular surface, and rendering the transformed triangular surface according to the filling color of the vector diagram set by the user through the preset open graphic library.
6. The method according to claim 1 characterized in that said vector graphics information further comprises user set line widths of said vector graphics; the method further comprises the following steps:
determining a vertical vector of a line of the vector diagram based on a first end point of the line of the vector diagram and a line width of the vector diagram set by a user, and drawing the line based on the path point and the vertical vector; the line drawing comprises line drawing of a closed curve and line drawing of a non-closed curve.
7. The method of claim 1, further comprising: scaling the vector diagram; the step of scaling the vector graphics comprises:
determining a type of a zoom mode; the types of the zooming mode comprise a common mode and a line non-zooming mode;
judging whether the zooming mode is a line non-zooming mode;
and if so, reversely scaling the line width of the line in the vector diagram during the scaling operation.
8. The method of claim 1, further comprising:
performing template test before drawing by a user, and starting drawing if the current template value is equal to a pre-recorded template value; the pre-recorded template value comprises a template value recorded when a current graph drawn by a user is used as a mask.
9. An openFL processing apparatus for rendering vector graphics, the apparatus comprising:
the analysis module is used for analyzing the drawing command to acquire graphic information of the vector diagram through the openFL when the drawing command triggered by a user is detected; the graphics information of the vector graphics includes path points that constitute the vector graphics;
the triangulation processing module is used for triangulating the vector diagram through the openFL based on the path points of the vector diagram to obtain a plurality of triangular surfaces of the vector diagram;
and the rendering module is used for rendering the plurality of triangular surfaces of the vector diagram through a preset open graphic library.
10. An electronic device comprising a processor and a memory;
the memory has stored thereon a computer program which, when executed by the processor, performs the method of any of claims 1 to 8.
CN202010019745.8A 2020-01-08 2020-01-08 Processing method and device for openFL drawing vector graphics and electronic equipment Active CN111260750B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010019745.8A CN111260750B (en) 2020-01-08 2020-01-08 Processing method and device for openFL drawing vector graphics and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010019745.8A CN111260750B (en) 2020-01-08 2020-01-08 Processing method and device for openFL drawing vector graphics and electronic equipment

Publications (2)

Publication Number Publication Date
CN111260750A true CN111260750A (en) 2020-06-09
CN111260750B CN111260750B (en) 2023-07-07

Family

ID=70948580

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010019745.8A Active CN111260750B (en) 2020-01-08 2020-01-08 Processing method and device for openFL drawing vector graphics and electronic equipment

Country Status (1)

Country Link
CN (1) CN111260750B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053410A (en) * 2020-08-24 2020-12-08 海南太美航空股份有限公司 Image processing method and system based on vector graphics drawing and electronic equipment
CN113822787A (en) * 2020-06-19 2021-12-21 深圳市立创软件开发有限公司 2D complex polygon rendering method based on GPU acceleration
CN114820873A (en) * 2022-05-13 2022-07-29 南京大学 Sketch regularization method, device and medium based on coloring
CN114968041A (en) * 2022-05-24 2022-08-30 北京有竹居网络技术有限公司 Event response method, device, equipment and medium based on graph

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090040230A1 (en) * 2007-06-27 2009-02-12 Nec System Technologies, Ltd. Vector image drawing device, method for vector image drawing, and computer readable recording medium
CN104952101A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Height-field based dynamic vector rendering method
CN105302445A (en) * 2015-11-12 2016-02-03 小米科技有限责任公司 Graphical user interface drawing method and device
CN106709863A (en) * 2016-12-28 2017-05-24 杭州趣维科技有限公司 GPU-based efficient 2D vector graph rendering method
CN109829962A (en) * 2019-01-29 2019-05-31 广联达科技股份有限公司 A kind of object space blanking line computation accelerated method using OPENGL

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090040230A1 (en) * 2007-06-27 2009-02-12 Nec System Technologies, Ltd. Vector image drawing device, method for vector image drawing, and computer readable recording medium
CN104952101A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Height-field based dynamic vector rendering method
CN105302445A (en) * 2015-11-12 2016-02-03 小米科技有限责任公司 Graphical user interface drawing method and device
CN106709863A (en) * 2016-12-28 2017-05-24 杭州趣维科技有限公司 GPU-based efficient 2D vector graph rendering method
CN109829962A (en) * 2019-01-29 2019-05-31 广联达科技股份有限公司 A kind of object space blanking line computation accelerated method using OPENGL

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113822787A (en) * 2020-06-19 2021-12-21 深圳市立创软件开发有限公司 2D complex polygon rendering method based on GPU acceleration
CN112053410A (en) * 2020-08-24 2020-12-08 海南太美航空股份有限公司 Image processing method and system based on vector graphics drawing and electronic equipment
CN114820873A (en) * 2022-05-13 2022-07-29 南京大学 Sketch regularization method, device and medium based on coloring
CN114968041A (en) * 2022-05-24 2022-08-30 北京有竹居网络技术有限公司 Event response method, device, equipment and medium based on graph

Also Published As

Publication number Publication date
CN111260750B (en) 2023-07-07

Similar Documents

Publication Publication Date Title
CN111260750A (en) Method and device for processing openFL drawn vector graphics and electronic equipment
EP2107528B1 (en) Method of and arrangement for rendering a path
US7280121B2 (en) Image processing apparatus and method of same
US8773439B2 (en) Approximation of stroked higher-order curved segments by quadratic bèzier curve segments
JP5232358B2 (en) Rendering outline fonts
JP4157569B2 (en) Drawing apparatus, drawing method, and drawing program
US9723204B2 (en) Dynamic motion path blur kernel
US20160343155A1 (en) Dynamic filling of shapes for graphical display of data
US9955065B2 (en) Dynamic motion path blur user interface
CN110033507B (en) Method, device and equipment for drawing internal trace of model map and readable storage medium
CN115439609B (en) Three-dimensional model rendering method, system, equipment and medium based on map service
US8107729B2 (en) Method for improving character outlines using multiple alignment zones
US20160035068A1 (en) Dynamic Motion Path Blur Techniques
US20210082165A1 (en) Rendering of cubic bezier curves in a graphics processing unit (gpu)
CN109427084B (en) Map display method, device, terminal and storage medium
CN114820853A (en) Vector graphics processing method and device, computer equipment and storage medium
US20220414986A1 (en) Segmenting three-dimensional meshes in graphical applications based on detection of elongated shapes
CN115033226A (en) Page display method and device, terminal equipment and computer readable storage medium
CN104008558A (en) Bezier curve rasterization processing method and system
CN109710122B (en) Method and device for displaying information
US11651520B2 (en) Method and system for unified encoding of path segments, caps, and joins for path stroking
CN114143477B (en) Image labeling method and device
US11182932B2 (en) Color gradient capture from source image content
CN115797506A (en) Method and device for drawing lane line object, terminal equipment and storage medium
EP2159754B1 (en) Method of and arrangement for filling a shape

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