Picture drawing method and device, equipment and storage medium
By extracting and converting drawing configuration parameters, obtaining and parsing the API to determine the tool class, cross-platform picture drawing is realized, which solves the problem of insufficient versatility of existing tools, improves efficiency and compatibility, and simplifies developers' work between different platforms. operate.
Patent Information
- Application Number
- CN202410760614.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-08-23
AI Technical Summary
Existing image drawing tools are optimized for specific platforms, resulting in reduced versatility. Developers need to relearn and adapt when switching between different platforms, which increases the complexity of the image drawing process and reduces work efficiency.
By responding to the request instructions initiated by the user on the client, we extract the drawing configuration parameters, obtain the API required by the client, convert the parameters into matching drawing instructions, parse the instructions to determine the tool class, and use the tool class to draw pictures to achieve cross-border Platform adaptation.
It improves the efficiency of image drawing, enhances the versatility and compatibility of the method, allows developers to operate freely between different platforms, and reduces the complexity of adaptation.
Smart Images

Figure CN118535254A
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of picture drawing, and in particular to a picture drawing method, device, equipment and storage medium. Background Art
[0002] In the process of front-end development, picture drawing and image generation have become a common requirement. Currently, developers usually write custom drawing logic to achieve specific image effects. However, this method has certain complexity and limitations.
[0003] Many existing image drawing tools are optimized for specific platforms, which reduces their versatility. When developers switch between different platforms, they need to relearn the drawing rules of the current platform based on the current platform, which greatly increases the complexity of the image drawing process and is not conducive to the developer's work efficiency. Summary of the invention
[0004] In view of this, the present application provides a picture drawing method, apparatus, device and storage medium, which are used to solve the problem that many existing picture drawing tools optimize themselves for specific platforms, thereby reducing their versatility. When developers switch between different platforms, they need to relearn and adapt according to the current platform, which greatly increases the complexity of the picture drawing process and is not conducive to the developer's work efficiency.
[0005] To achieve the above objectives, the proposed solution is as follows:
[0006] In a first aspect, a method for drawing a picture includes:
[0007] In response to a request instruction for drawing a picture initiated by a user on a client, extract various drawing configuration parameters from the request instruction;
[0008] Obtain the API requested by the client;
[0009] Convert each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client;
[0010] Parsing each of the drawing instructions to determine each corresponding tool class;
[0011] Use each of the tool classes to draw a picture to obtain a target picture.
[0012] Preferably, converting the drawing configuration parameters according to the API to obtain drawing instructions matching the client includes:
[0013] Extracting a drawing rule table whose rule type is picture drawing type from the API;
[0014] Comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table;
[0015] For each of the drawing configuration parameters, encapsulate the drawing configuration parameter and the configuration format to obtain a parameter object corresponding to the drawing configuration parameter;
[0016] Generate drawing instructions corresponding to the parameter objects.
[0017] Preferably, the parsing of each of the drawing instructions to determine each corresponding tool class includes:
[0018] Determining each configuration field from each of the drawing instructions;
[0019] For each of the configuration fields, the configuration field is parsed to determine whether the configuration field contains only one item;
[0020] If yes, then obtain the digital configuration requirements in the item, and search for the corresponding tool class according to the digital configuration requirements;
[0021] If not, determining the hierarchy of each item and determining the item with the lowest hierarchy from among the items;
[0022] Search for the corresponding tool class according to the item at the lowest level.
[0023] Preferably, the drawing of a picture using each of the tool classes to obtain a target picture includes:
[0024] Determine the upstream and downstream relationship between every two drawing instructions;
[0025] Based on the upstream and downstream drawing relationship between each two drawing instructions, the corresponding tool classes are sorted;
[0026] According to the order of the sorting, and using each of the tool classes, the picture is drawn to obtain the target picture.
[0027] Preferably, after the target image is drawn, the method further includes:
[0028] Calling a callback function corresponding to the target image;
[0029] Determine a return parameter based on the callback function;
[0030] If the returned parameter is the first preset parameter, it is determined that the target image is drawn successfully;
[0031] If the return parameter is the second preset parameter, it is determined that the target image is the same as the image drawn last time;
[0032] If the returned parameter is the third preset parameter, it is determined that an abnormality occurs in the target image.
[0033] Preferably, the drawing configuration parameter is width, height or view.
[0034] In a second aspect, a picture drawing device includes:
[0035] A response module, used to respond to a request instruction for drawing a picture initiated by a user on a client, and extract various drawing configuration parameters from the request instruction;
[0036] An API acquisition module, used to acquire the API required by the client;
[0037] A conversion module, used for converting each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client;
[0038] A parsing module, used for parsing each of the drawing instructions to determine each corresponding tool class;
[0039] The target image obtaining module is used to use each of the tool classes to draw an image to obtain a target image.
[0040] Preferably, the conversion module comprises:
[0041] An extraction module, used for extracting a drawing rule table whose rule type is a picture drawing type from the API;
[0042] A comparison module, used for comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table;
[0043] A packaging module, used for packaging each of the drawing configuration parameters with the configuration format to obtain a parameter object corresponding to the drawing configuration parameter;
[0044] The drawing instruction generation module is used to generate each drawing instruction corresponding to each of the parameter objects.
[0045] In a third aspect, a picture drawing device includes a memory and a processor;
[0046] The memory is used to store programs;
[0047] The processor is used to execute the program to implement each step of the picture drawing method as described in any one of the first aspects.
[0048] In a fourth aspect, a storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the picture drawing method as described in any one of the first aspects are implemented.
[0049] It can be seen from the above technical solution that the present application extracts various drawing configuration parameters from the request instruction for drawing a picture initiated by the user on the client; obtains the API required by the client; converts each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client; parses each of the drawing instructions to determine each corresponding tool class; and uses each of the tool classes to draw the picture to obtain the target picture. This solution first obtains the drawing configuration parameters required by the user to draw the picture, that is, obtains them from the request instruction initiated by the user, and then needs to obtain the API required by the client. The client API is a rule or regulation unique to the client, indicating that the drawing needs to be performed according to this API. Then, the various drawing configuration parameters can be converted according to this API to ensure that these various drawing configuration parameters can be adapted to the current client. There is no need to re-learn the drawing rules of the current platform as in the prior art. Only adaptation and fusion are required to obtain various drawing instructions, and these various drawing instructions are drawing instructions that the current client can recognize and execute, and the tool class corresponding to the drawing instruction is used to perform the final picture drawing to obtain the target picture. This solution can greatly improve the drawing efficiency, and the method has high versatility and compatibility, can adapt to various clients across platforms, and is less restricted, so that developers can freely operate various clients, which brings a lot of convenience to developers. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0051] Figure 1 An optional flow chart of a picture drawing method provided in an embodiment of the present application;
[0052] Figure 2 A schematic diagram of the structure of a picture drawing device provided in an embodiment of the present application;
[0053] Figure 3 A schematic diagram of the structure of a picture drawing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0055] In the process of front-end development, picture drawing and image generation have become a common requirement. Currently, developers usually write custom drawing logic to achieve specific image effects. However, this method has certain complexity and limitations.
[0056] Many existing image drawing tools are optimized for specific platforms, which reduces their versatility. For example, the Canvas drawing tool is optimized for the Web platform, so the tool may not be directly applied to the mini-program or APP development process. Therefore, when developers switch between different platforms, they need to relearn the drawing rules of the current platform according to the current platform, or rewrite a large amount of drawing code, including drawing logic, coordinate calculation, etc., and the drawing logic may be scattered everywhere, and the code structure is messy, resulting in reduced readability and maintainability of the code, which greatly increases the complexity of the image drawing process and is not conducive to the developer's work efficiency.
[0057] In order to solve the defects of the above-mentioned prior art, an embodiment of the present invention provides a picture drawing method, which can be applied to various computer terminals or smart terminals, and its execution subject can be a processor or server of the computer terminal or smart terminal. The method flow chart of the method is as follows Figure 1 As shown, specifically including:
[0058] S1: In response to a request instruction for drawing a picture initiated by a user on a client, extract various drawing configuration parameters from the request instruction.
[0059] The instruction initiated by the user on the client can be considered as a request instruction for image drawing initiated by the user in the current image drawing software of the user's client, such as clicking a picture drawing button, etc. It can be understood that the user will upload one or more drawing configuration parameters in advance, and each of these drawing configuration parameters can be obtained from the request instruction, and each of these drawing configuration parameters represents the drawing indicators or requirements for the image to be drawn.
[0060] Among them, each drawing configuration parameter can be adapted to any drawing tool or drawing software in the client without limitation.
[0061] Drawing configuration parameters can include width, height or view, which respectively represent the drawing box width, drawing box height, and array of the drawing tool / drawing software in the client. It can also include maxImgs, which represents the maximum number of images that can be drawn, which can be set according to requirements, such as 10 or 20 images, painting, which represents the parameter object for drawing images, and onGetImage, which represents the callback function after drawing is completed.
[0062] S2: Obtain the API required by the client.
[0063] API is an Application Programming Interface, which is a set of predefined functions. Its purpose is to provide applications and developers with the ability to access a set of routines based on certain software or hardware without having to access the source code or understand the details of the internal working mechanism. Therefore, a client drawing software or drawing tool corresponds to an API, and API can also be understood as its own working rules. If other drawing software or drawing tools want to call the drawing software tool, they need to draw according to the API of the software drawing tool.
[0064] S3: converting each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client.
[0065] This application integrates and adapts the API with the various drawing configuration parameters obtained, that is, converts the various drawing configuration parameters according to the API so that these various drawing configuration parameters can match the current client, and the user does not need to relearn the drawing rules of the client, thereby saving time and improving efficiency. After the conversion, various drawing instructions are obtained, which are drawing instructions that the current client can recognize and execute, and pictures can be drawn according to these various drawing instructions.
[0066] S4: Parse each of the drawing instructions to determine each corresponding tool class.
[0067] It is understandable that in the process of drawing pictures, the pictures that the user wants to draw may require multi-faceted and multi-level drawing, such as drawing the background color first, then drawing the graphics, adding text, and then rendering the color, etc. Different drawing types mean that different tool categories are required to complete the drawing. Therefore, after obtaining each drawing instruction, the drawing instruction needs to be parsed to determine which tool category is required for each drawing instruction, that is, to determine the tool classes corresponding to each drawing instruction.
[0068] S5: Use each of the tool classes to draw a picture to obtain a target picture.
[0069] The target image is finally drawn by using the tool class. The tool classes can be used to draw the image at the same time according to the specific situation of the image to be drawn, or they can be arranged in sequence and drawn by using each tool class in turn. This embodiment does not limit this.
[0070] It can be seen from the above technical solution that the present application extracts various drawing configuration parameters from the request instruction for drawing a picture initiated by the user on the client; obtains the API required by the client; converts each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client; parses each of the drawing instructions to determine each corresponding tool class; and uses each of the tool classes to draw the picture to obtain the target picture. This solution first obtains the drawing configuration parameters required by the user to draw the picture, that is, obtains them from the request instruction initiated by the user, and then needs to obtain the API required by the client. The client API is a rule or regulation unique to the client, indicating that the drawing needs to be performed according to this API. Then, the various drawing configuration parameters can be converted according to this API to ensure that these various drawing configuration parameters can be adapted to the current client. There is no need to re-learn the drawing rules of the current platform as in the prior art. Only adaptation and fusion are required to obtain various drawing instructions, and these various drawing instructions are drawing instructions that the current client can recognize and execute, and the tool class corresponding to the drawing instruction is used to perform the final picture drawing to obtain the target picture. This solution can greatly improve the drawing efficiency, and the method has high versatility and compatibility, can adapt to various clients across platforms, and is less restricted, so that developers can freely operate various clients, which brings a lot of convenience to developers.
[0071] In the method provided in the embodiment of the present invention, the process of converting the drawing configuration parameters according to the API to obtain the drawing instructions matching the client is specifically described as follows:
[0072] Extracting a drawing rule table whose rule type is picture drawing type from the API;
[0073] Comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table;
[0074] For each of the drawing configuration parameters, encapsulate the drawing configuration parameter and the configuration format to obtain a parameter object corresponding to the drawing configuration parameter;
[0075] Generate drawing instructions corresponding to the parameter objects.
[0076] Specifically, the API defines various types of rules, and the picture drawing rule is one of them. Each rule has a specific rule table. The rule type of the picture drawing type also has its corresponding drawing rule table. The drawing rule table defines the configuration format corresponding to each drawing configuration parameter. Therefore, by comparing each drawing configuration parameter with the drawing rule table, the configuration format that each drawing configuration parameter matches in the current client can be determined. This comparison process allows each drawing configuration parameter to be recognized by the current client and can perform drawing operations normally. Then, by encapsulating each drawing configuration parameter with its corresponding configuration format, you can get a parameter object that can be used for drawing, and generate drawing instructions based on the parameter object.
[0077] The above embodiment describes the process of converting the various drawing configuration parameters according to the API in this application to obtain various drawing instructions that match the client. The following is a specific explanation of the steps of parsing each of the drawing instructions in this application to determine each corresponding tool class.
[0078] Determining each configuration field from each of the drawing instructions;
[0079] For each of the configuration fields, the configuration field is parsed to determine whether the configuration field contains only one item;
[0080] If yes, then obtain the digital configuration requirements in the item, and search for the corresponding tool class according to the digital configuration requirements;
[0081] If not, determining the hierarchy of each item and determining the item with the lowest hierarchy from among the items;
[0082] Search for the corresponding tool class according to the item at the lowest level.
[0083] Specifically, each drawing instruction corresponds to a configuration field, which contains information about how to perform specific drawing. At the same time, different configuration fields have different ways of finding tool classes, so it is necessary to distinguish each configuration field by looking at the number of items in the configuration field. It is understandable that a configuration field may contain one or more items. If a configuration field contains only one item, it means that the configuration field is the width or height of the image required by the configuration. If a configuration field contains multiple items, it means that the configuration field is the specific shape or text of the image required by the configuration.
[0084] Then, after parsing, determine the number of items contained in the configuration field. If it contains only one item, obtain the digital configuration requirements in the item, that is, the height number or the width number. For example, according to "height" and "number", find the corresponding tool class, then the tool class is "set the height of the image to 10"; if it contains multiple items, first determine what the items are, such as item 1, item 2, and so on, and then determine the hierarchy of each item respectively. For example, the hierarchy of item 1 is the second level, and the hierarchy of item 2 is the first level. The hierarchy refers to the parameter information based on which the final drawing is based. For example, the items in the configuration field corresponding to a drawing configuration parameter are: type (type), image (special pictures, such as pictures with rounded corners or circles, pictures that can be rotated at any angle, both remote pictures and local pictures are supported) / rect (rectangular pictures) / roundrect (rounded rectangular pictures) / text (drawing text, which can support single-line or multi-line text. If the text exceeds a certain width, it can be replaced by ellipsis), then image / rect / roundrect / Text is the lowest level item, so the corresponding tool class is searched according to the lowest level item, for example, rect, then its corresponding tool class is the rectangle drawing tool. The above items can support setting properties such as image size, position and color, and can achieve various complex image effects to meet the drawing needs in different scenarios.
[0085] The following embodiments describe in detail the process of drawing a picture using each of the tool classes in this application to obtain a target picture.
[0086] Determine the upstream and downstream relationship between every two drawing instructions;
[0087] Based on the upstream and downstream drawing relationship between each two drawing instructions, the corresponding tool classes are sorted;
[0088] According to the order of the sorting, and using each of the tool classes, the picture is drawn to obtain the target picture.
[0089] Specifically, the upstream and downstream relationship means the drawing order of each element in the picture. For example, drawing instruction 1 refers to drawing text, and drawing instruction 2 refers to drawing the picture background. Then the drawing order of drawing instruction 2 is earlier than the drawing order of drawing instruction 1, so drawing instruction 2 is upstream and drawing instruction 1 is downstream. Therefore, the pictures are sorted according to the upstream and downstream relationship, and then the pictures are drawn in order to obtain the target picture, so that the accuracy of the target picture obtained is higher.
[0090] Furthermore, in this method, after the target image is drawn, it also includes:
[0091] Calling a callback function corresponding to the target image;
[0092] Determine a return parameter based on the callback function;
[0093] If the returned parameter is the first preset parameter, it is determined that the target image is drawn successfully;
[0094] If the return parameter is the second preset parameter, it is determined that the target image is the same as the image drawn last time;
[0095] If the returned parameter is the third preset parameter, it is determined that an abnormality occurs in the target image.
[0096] Specifically, in order to monitor the drawing efficiency and drawing results of the target image, the present application pre-sets a callback function. During the drawing process of the target image, the callback function is used to record the drawing status during the drawing process. When the target image is drawn, the callback function can be called to determine the return parameters, and the drawing efficiency and results can be determined based on the return parameters.
[0097] Among them, the first preset parameter, the second preset parameter and the third preset parameter are set, and each preset parameter represents a different drawing result. For example, if the return parameter is the first preset parameter, it is determined that the target image is drawn successfully. If the return parameter is the second preset parameter, it is determined that the target image is the same as the image drawn last time; if the return parameter is the third preset parameter, it is determined that an abnormality occurs in the target image.
[0098] Setting a callback function can be used for subsequent optimization and improvement based on the callback status of the callback function, thereby ensuring a stable and smooth experience for users.
[0099] and Figure 1 Corresponding to the method described above, the embodiment of the present invention also provides a picture drawing device for Figure 1 In the specific implementation of the method, the picture drawing device provided by the embodiment of the present invention can be used in a computer terminal or various mobile devices, combined with Figure 2 , introduce the picture drawing device, such as Figure 2 As shown, the device may include:
[0100] A response module 10 is used to respond to a request instruction for drawing a picture initiated by a user on a client, and extract various drawing configuration parameters from the request instruction;
[0101] An API acquisition module 20, used to acquire the API required by the client;
[0102] A conversion module 30, configured to convert each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client;
[0103] The parsing module 40 is used to parse each of the drawing instructions to determine each corresponding tool class;
[0104] The target image obtaining module 50 is used to use each of the tool classes to draw an image to obtain a target image.
[0105] It can be seen from the above technical solution that the present application extracts various drawing configuration parameters from the request instruction for drawing a picture initiated by the user on the client; obtains the API required by the client; converts each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client; parses each of the drawing instructions to determine each corresponding tool class; and uses each of the tool classes to draw the picture to obtain the target picture. This solution first obtains the drawing configuration parameters required by the user to draw the picture, that is, obtains them from the request instruction initiated by the user, and then needs to obtain the API required by the client. The client API is a rule or regulation unique to the client, indicating that the drawing needs to be performed according to this API. Then, the various drawing configuration parameters can be converted according to this API to ensure that these various drawing configuration parameters can be adapted to the current client. There is no need to re-learn the drawing rules of the current platform as in the prior art. Only adaptation and fusion are required to obtain various drawing instructions, and these various drawing instructions are drawing instructions that the current client can recognize and execute, and the tool class corresponding to the drawing instruction is used to perform the final picture drawing to obtain the target picture. This solution can greatly improve the drawing efficiency, and the method has high versatility and compatibility, can adapt to various clients across platforms, and is less restricted, so that developers can freely operate various clients, which brings a lot of convenience to developers.
[0106] In one example, the conversion module 30 may include:
[0107] An extraction module, used for extracting a drawing rule table whose rule type is a picture drawing type from the API;
[0108] A comparison module, used for comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table;
[0109] A packaging module, used for packaging each of the drawing configuration parameters with the configuration format to obtain a parameter object corresponding to the drawing configuration parameter;
[0110] The drawing instruction generation module is used to generate each drawing instruction corresponding to each of the parameter objects.
[0111] Furthermore, the embodiment of the present application provides a picture drawing device. Optionally, Figure 3 The hardware structure diagram of the picture drawing device is shown in FIG. Figure 3 The hardware structure of the picture drawing device may include: at least one processor 01 , at least one communication interface 02 , at least one memory 03 and at least one communication bus 04 .
[0112] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .
[0113] The processor 01 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0114] The memory 03 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), etc., such as at least one disk memory.
[0115] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to execute the following picture drawing method, including:
[0116] In response to a request instruction for drawing a picture initiated by a user on a client, extract various drawing configuration parameters from the request instruction;
[0117] Obtain the API requested by the client;
[0118] Convert each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client;
[0119] Parsing each of the drawing instructions to determine each corresponding tool class;
[0120] Use each of the tool classes to draw a picture to obtain a target picture.
[0121] Optionally, the detailed functions and extended functions of the program may refer to the description of the picture drawing method in the method embodiment.
[0122] The embodiment of the present application further provides a storage medium, which may store a program suitable for execution by a processor, and when the program is executed, controls the device where the storage medium is located to execute the following picture drawing method, including:
[0123] In response to a request instruction for drawing a picture initiated by a user on a client, extract various drawing configuration parameters from the request instruction;
[0124] Obtain the API requested by the client;
[0125] Convert each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client;
[0126] Parsing each of the drawing instructions to determine each corresponding tool class;
[0127] Use each of the tool classes to draw a picture to obtain a target picture.
[0128] Specifically, the storage medium may be a computer-readable storage medium, and the computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM.
[0129] Optionally, the detailed functions and extended functions of the program may refer to the description of the picture drawing method in the method embodiment.
[0130] In addition, the functional modules in the various embodiments of the present disclosure can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a live broadcast device, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present disclosure.
[0131] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0132] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0133] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for drawing a picture, characterized in that: include: In response to a request instruction for drawing a picture initiated by a user on a client, extract various drawing configuration parameters from the request instruction; Obtain the API requested by the client; Convert each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client; Parsing each of the drawing instructions to determine each corresponding tool class; Use each of the tool classes to draw a picture to obtain a target picture.
2. The method according to claim 1, characterized in that The step of converting the drawing configuration parameters according to the API to obtain drawing instructions matching the client includes: Extracting a drawing rule table whose rule type is picture drawing type from the API; Comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table; For each of the drawing configuration parameters, encapsulate the drawing configuration parameter and the configuration format to obtain a parameter object corresponding to the drawing configuration parameter; Generate drawing instructions corresponding to the parameter objects.
3. The method according to claim 1, characterized in that The parsing of each drawing instruction to determine each corresponding tool class includes: Determining each configuration field from each of the drawing instructions; For each of the configuration fields, the configuration field is parsed to determine whether the configuration field contains only one item; If yes, then obtain the digital configuration requirements in the item, and search for the corresponding tool class according to the digital configuration requirements; If not, determining the hierarchy of each item and determining the item with the lowest hierarchy from among the items; Search for the corresponding tool class according to the item at the lowest level.
4. The method according to claim 1, characterized in that: The method of using each of the tool classes to draw a picture to obtain a target picture includes: Determine the upstream and downstream relationship between every two drawing instructions; Based on the upstream and downstream drawing relationship between each two drawing instructions, the corresponding tool classes are sorted; According to the order of the sorting, and using each of the tool classes, the picture is drawn to obtain the target picture.
5. The method according to claim 1, characterized in that After the target image is drawn, it also includes: Calling a callback function corresponding to the target image; Determine a return parameter based on the callback function; If the returned parameter is the first preset parameter, it is determined that the target image is drawn successfully; If the return parameter is the second preset parameter, it is determined that the target image is the same as the image drawn last time; If the returned parameter is the third preset parameter, it is determined that an abnormality occurs in the target image.
6. The method according to claim 1, characterized in that The drawing configuration parameter is width, height or view.
7. A picture drawing device, characterized in that: include: A response module, used to respond to a request instruction for drawing a picture initiated by a user on a client, and extract various drawing configuration parameters from the request instruction; An API acquisition module, used to acquire the API required by the client; A conversion module, used for converting each of the drawing configuration parameters according to the API to obtain each drawing instruction matching the client; A parsing module, used for parsing each of the drawing instructions to determine each corresponding tool class; The target image obtaining module is used to use each of the tool classes to draw an image to obtain a target image.
8. The device according to claim 7, characterized in that The conversion module comprises: An extraction module, used for extracting a drawing rule table whose rule type is a picture drawing type from the API; A comparison module, used for comparing each of the drawing configuration parameters with the drawing rule table to determine each configuration format corresponding to each of the drawing configuration parameters in the drawing rule table; A packaging module, used for packaging each of the drawing configuration parameters with the configuration format to obtain a parameter object corresponding to the drawing configuration parameter; The drawing instruction generation module is used to generate each drawing instruction corresponding to each of the parameter objects.
9. A picture drawing device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the picture drawing method as described in any one of claims 1-6.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the picture drawing method according to any one of claims 1 to 6 is implemented.
