Button picture generation method, system and device
By using an automated method to generate button paintings, virtual buttons are arranged and filled with colors according to physical rules. This solves the problem of low efficiency in manual processing in existing technologies and enables fast and efficient button painting production and self-service customization.
Patent Information
- Application Number
- CN202510866073.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-06-26
AI Technical Summary
In existing technologies, the steps of making the base plate and generating the blueprint for button paintings require manual processing, which is inefficient, cannot be mass-produced, and cannot provide customized tools for end users, resulting in an excessively long production chain.
By receiving user input, the system automatically arranges virtual buttons on a virtual baseboard using preset physical rules, generates a baseboard file that records the button position information, and fills in the color according to the original image to generate an image file of the button painting.
It has achieved automated button painting generation, improving production efficiency from 1-2 days to half an hour, increasing the yield rate to over 90%, supporting user self-service operation, and simplifying the production process.
Smart Images

Figure CN120472043B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer image production, and particularly relates to a button picture generation method, system and device. BACKGROUND
[0002] A button picture is a special artistic form of expression, which is formed by a plurality of customized buttons of different colors and presents a special and three-dimensional beauty. The creation of a button picture is time-consuming and laborious, and requires processing of an original picture, mapping pixels in the picture to corresponding buttons, and generating a corresponding drawing for indicating the positions and color information of the buttons while maintaining the restoration degree as much as possible.
[0003] The production of a button picture includes two main steps of base plate production and drawing generation. In the existing base plate production process, an industrial design software such as Rhino 3D is used for design, a plurality of circular elements of different sizes are placed on a blank base plate according to the size of the base plate, manual adjustment and arrangement are performed to ensure as many elements as possible to be placed to fill the entire base plate and reduce the blank position, and manual fine adjustment is performed to avoid element overlap. The base plate production is a vector file (dxf-graphics interchange file), and the content is the path description of the placed elements. The file is used for subsequent connection with the factory to generate a corresponding base plate.
[0004] Drawing generation plays an important role in the production of a button picture. After the base plate production is completed, color information is obtained from an original picture element by element according to the information (position, size) of the elements in the base plate, and a vector version drawing with color numbers is generated by converting the color information in the original picture into similar colors in a color palette according to a pre-customized printing color palette. The drawing is used for previewing the effect of the button picture and providing a list file of each color button to facilitate the subsequent production process and the generation of a delivery list. In the user experience of the button picture splicing process, the color number and position are given for guidance.
[0005] In the existing scheme, the two steps of base plate production and drawing generation need to be manually processed by artificial, which is low in efficiency, cannot be mass-produced, and cannot provide a customization tool for end users, and the production link is too long. SUMMARY
[0006] The present application provides a button picture generation method, system and device, and provides a scheme for automatically generating interactive animation based on motion capture, which at least solves the problems in the prior art that the two steps of base plate production and drawing generation need to be manually processed by artificial, which is low in efficiency, cannot be mass-produced, and cannot provide a customization tool for end users, and the production link is too long.
[0007] The present application provides a button picture generation method, comprising:
[0008] obtaining a virtual baseboard and virtual buttons of the target button picture in response to receiving the input of the user;
[0009] arranging the virtual buttons in the virtual baseboard based on a preset physical rule, and obtaining a baseboard file recording at least position information of each virtual button;
[0010] color filling the virtual buttons in the baseboard file according to an original image corresponding to the target button picture, and obtaining an image file of the target button picture.
[0011] Optionally, the obtaining of the virtual baseboard and the virtual buttons of the target button picture in response to receiving the input of the user comprises:
[0012] obtaining a shape and a size of the virtual baseboard of the target button picture in response to receiving the input of the user; and / or
[0013] obtaining a size of the virtual buttons of the target button picture and a quantity ratio of virtual buttons of different sizes in response to receiving the input of the user.
[0014] Optionally, the preset physical rule comprises:
[0015] setting a gravity rule for the virtual baseboard and / or the virtual buttons; and / or
[0016] setting a collision rule for the virtual baseboard and / or the virtual buttons.
[0017] Optionally, the arranging of the virtual buttons in the virtual baseboard based on the preset physical rule and the obtaining of the baseboard file recording at least the position information of each virtual button comprises:
[0018] arranging the virtual buttons in the virtual baseboard based on the preset physical rule, and obtaining a blank area according to an arrangement result;
[0019] repeating the above steps for a preset number of times to obtain an arrangement result with a minimum blank area;
[0020] the arrangement result with the minimum blank area, and the obtaining of the baseboard file recording at least the position information of each virtual button.
[0021] Optionally, the color filling of the virtual buttons in the baseboard file according to the original image corresponding to the target button picture and the obtaining of the image file of the target button picture comprises:
[0022] establishing a coordinate mapping between the original image and the baseboard file according to the original image corresponding to the target button picture;
[0023] obtaining an original color corresponding to each virtual button according to the coordinate mapping and the position information of each virtual button.
[0024] According to the original color corresponding to each virtual button, the virtual buttons in the bottom plate file are filled with color to obtain an image file of the target button drawing.
[0025] Optionally, the filling of the virtual buttons in the bottom plate file with color according to the original color corresponding to each virtual button to obtain an image file of the target button drawing comprises:
[0026] After filling the virtual buttons in the bottom plate file with color according to the original color corresponding to each virtual button, original color data is obtained;
[0027] After loading the printing colors in the color plate file and replacing the colors in the original color data with the printing colors, printing color data is obtained;
[0028] According to the printing color data, an image file of the target button drawing is obtained.
[0029] Optionally, the loading of the printing colors in the color plate file and the replacement of the colors in the original color data with the printing colors to obtain printing color data comprises:
[0030] Loading all the printing colors in the color plate file to obtain the RGB components corresponding to each printing color;
[0031] According to the original color data, the closest printing color to each color in the original color data is obtained, and after replacing the corresponding color in the original color data with the printing color, printing color data is obtained.
[0032] Optionally, it further comprises designing the surface of each virtual button in the image file.
[0033] Optionally, it further comprises traversing each virtual button in the image file or the bottom plate file to obtain the type and quantity of the virtual buttons.
[0034] In another aspect, a button drawing generation method further comprises:
[0035] According to the user's input, a Pygame window is configured as a virtual bottom plate and an instance in the Pygame window is configured as a virtual button in Pymunk;
[0036] Based on the preset space gravity of pymunk and the collision rules of the instance, the virtual buttons are freely arranged in the virtual bottom plate by falling, and a bottom plate file recording at least the position information of each virtual button is obtained;
[0037] fill the virtual buttons in the bottom plate file with colors according to the original image corresponding to the target button picture, to obtain an image file of the target button picture.
[0038] fill the virtual buttons in the bottom plate file with colors according to the original image corresponding to the target button picture, to obtain an image file of the target button picture.
[0039] In another aspect, a button picture generation system includes a bottom plate construction module and a button picture configuration module.
[0040] The bottom plate construction module is configured to:
[0041] In response to receiving the input of the user, obtain a virtual bottom plate and virtual buttons of a target button picture;
[0042] arrange the virtual buttons in the virtual bottom plate based on a preset physical rule, to obtain a bottom plate file recording at least position information of each virtual button;
[0043] The button picture configuration module is configured to:
[0044] fill the virtual buttons in the bottom plate file with colors according to the original image corresponding to the target button picture, to obtain an image file of the target button picture.
[0045] In another aspect, an embodiment of the present application further provides a device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the above method.
[0046] In another aspect, an embodiment of the present application further provides a computer readable storage medium storing a computer program, and a processor executing the computer program to implement the above method.
[0047] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0048] The button picture generation method, system and device include obtaining a virtual bottom plate and virtual buttons of a target button picture in response to receiving an input of a user, arranging the virtual buttons in the virtual bottom plate based on a preset physical rule to obtain a bottom plate file recording at least position information of each virtual button, and filling the virtual buttons in the bottom plate file with colors according to an original image corresponding to the target button picture to obtain an image file of the target button picture. At least the problems that in the prior art, two steps of bottom plate manufacturing and drawing generation both need to be manually processed by a person, the efficiency is low, mass production cannot be performed, and a customized tool cannot be provided for an end user, and a manufacturing chain is too long are solved. BRIEF DESCRIPTION OF DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. In all the drawings, similar elements or parts are generally identified by similar reference signs. In the drawings, the elements or parts are not necessarily drawn according to the actual proportions.
[0050] Figure 1 A flowchart of the method for generating a button picture in the present application is shown in the figure.
[0051] Figure 2 A button picture image file display schematic diagram in the present application is shown in the figure.
[0052] Figure 3 A button picture image file display schematic diagram in the present application is shown in the figure.
[0053] Figure 4 A button picture image file display schematic diagram in the present application is shown in the figure.
[0054] Figure 5 A structure schematic diagram of a device in the present application is shown in the figure.
[0055] In the figure, the marks are: 101-processor, 102-communication bus, 103-network interface, 104-user interface, 105-memory.
[0056] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0057] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.
[0058] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0059] Example 1
[0060] like Figure 1 As shown, a method for generating button drawings includes:
[0061] S1. In response to receiving user input, obtain the virtual base and virtual button of the target button drawing.
[0062] User input can be used to set parameters such as the shape, size, or resolution of the virtual base.
[0063] User input can be used to set the proportions of different categories of virtual buttons.
[0064] The shape, size, or resolution of each category of virtual buttons can be preset. Users can directly select the category of virtual buttons or input the shape, size, or resolution of each category of virtual buttons directly.
[0065] Optionally, the shape, size, or resolution of the virtual background of the target button painting can correspond to the shape and size of the target button painting.
[0066] Optionally, the shape, size, or resolution of each category of virtual buttons can correspond to the shape and size of the stock buttons.
[0067] Optionally, the virtual button is configured as an entity that can move within the virtual baseboard window.
[0068] S2. Based on preset physical rules, arrange the virtual buttons in the virtual base plate to obtain a base plate file that records the position information of each virtual button.
[0069] The physical rules can include gravity rules and collision rules, as well as rules for simulating friction and base plate swaying.
[0070] In the above two steps of making the bottom plate, according to the size of the provided bottom plate, the virtual buttons to be filled are randomly placed on the bottom plate by using a physical engine simulation mode, collision detection, gravity simulation, friction simulation and bottom plate shaking simulation are introduced, the virtual buttons are filled as much as possible on the bottom plate, and it is ensured that the virtual buttons do not overlap. After stable placement, the corresponding position information is exported and written into the bottom plate file.
[0071] Optionally, fine adjustment function can also be provided. For the virtual buttons displayed in the interface that are not satisfactory, manual removal or movement operation can be performed by the user to ensure that the layout of the bottom plate is more reasonable.
[0072] The above method can quickly complete the work of making the bottom plate.
[0073] S3, according to the original image corresponding to the target button drawing, the virtual buttons in the bottom plate file are color filled to obtain the image file of the target button drawing.
[0074] The bottom plate file contains the position information of all virtual buttons, that is, the position of the button to be placed in the button drawing and the size of the button. According to the original image input by the user, such as hand-drawn picture, photo, etc., the virtual buttons in the bottom plate file are color filled to obtain the image file of the target button drawing.
[0075] For each virtual button, a certain range of colors is taken out in the position corresponding to the original image, and the average value is taken to obtain the color that the virtual button needs to display in the corresponding position.
[0076] Optionally, in order to generate an interactive preview effect, a 3D model of the virtual button can also be loaded through the interface provided by Three.js and Web GL API, and rendered to the Canvas of the webpage, supporting user drag, zoom, rotation operation, adding spotlight effect, parallel light and environment light effect, using Physically Based Rendering technology to increase the realism of rendering. Support users to export the effect diagram one key, improve the convenience of use.
[0077] After the image file or the bottom plate file is generated, all elements are traversed by the program, and the number of various types of entity buttons required is counted according to the type of the virtual button, and a bill of materials file is generated.
[0078] After using the new technical means, the efficiency of picture conversion is greatly improved, which changes the previous situation that each picture needs manual adjustment. It takes 1-2 days to make a work, which is shortened to within half an hour. At the same time, the yield of finished products is improved, and the accuracy of the work is greatly improved after using the algorithm. The data error of the bottom plate file is minimized, and the yield is improved to more than 90%.
[0079] The technology also makes it possible to be deployed. Previously, the production of button art paintings can only be submitted by customers through pictures, and professional operators need to process for a long time. Finally, the effect picture and finished product can be obtained. After using the technology, through the deployment in the webpage and the applet, the user can completely operate by himself, and the submission of the picture, the preview of the effect and the order can be completed in one station.
[0080] Embodiment 2
[0081] The embodiment is a button picture generation method based on the embodiment 1, comprising:
[0082] S1, in response to receiving the input of the user, obtaining the virtual base plate and the virtual button of the target button picture.
[0083] Optionally, in response to receiving the input of the user, obtaining the virtual base plate and the virtual button of the target button picture, comprising:
[0084] in response to receiving the input of the user, obtaining the shape and size of the virtual base plate of the target button picture; and / or
[0085] in response to receiving the input of the user, obtaining the size of the virtual button of the target button picture and the quantity ratio of the virtual buttons of different sizes.
[0086] Optionally, the virtual base plate can be a regular pattern or a custom pattern, but generally consistent with the shape of the original image corresponding to the target button picture.
[0087] Optionally, in Pymunk, the Pygame window is configured as the virtual base plate and the instance in the Pygame window is configured as the virtual button according to the input of the user.
[0088] S2, based on the preset physical rules, the virtual buttons are arranged in the virtual base plate, and a base plate file recording the position information of each virtual button is obtained.
[0089] Optionally, the preset physical rules comprise:
[0090] setting the gravity rule for the virtual base plate and / or the virtual button; and / or
[0091] setting the collision rule for the virtual base plate and / or the virtual button; and / or
[0092] setting the friction rule for the virtual base plate and / or the virtual button.
[0093] Optionally, the process of arranging the virtual buttons in the virtual baseboard based on the preset physical rules can be repeated multiple times, and the arrangement scheme of the virtual buttons that best meets the expectation is selected as the final result, and the baseboard file recording at least the position information of each virtual button is obtained according to the final result. The result that best meets the expectation can be manually selected by the user, or can be a result that meets the preset condition.
[0094] Optionally, the process of arranging the virtual buttons in the virtual baseboard based on the preset physical rules, and obtaining the baseboard file recording at least the position information of each virtual button, comprises:
[0095] Arranging the virtual buttons in the virtual baseboard based on the preset physical rules, and obtaining the blank area according to the arrangement result;
[0096] Repeating the above steps for a preset number of times to obtain an arrangement result with the smallest blank area;
[0097] The arrangement result with the smallest blank area, and obtaining the baseboard file recording at least the position information of each virtual button.
[0098] Optionally, the method of arranging the virtual buttons in the virtual baseboard based on the preset physical rules is to randomly place the circular elements to be filled on the baseboard in a simulated manner using a physical engine, introduce collision detection, gravity simulation, friction simulation, and baseboard shaking simulation, fill the elements to the bottom as much as possible, and ensure that the elements do not overlap. After the placement is stable, the corresponding position information is exported and written into the baseboard file. A fine adjustment function is provided, and for elements displayed in the interface that are not satisfactory, manual removal or movement operation can be performed to ensure that the baseboard layout is reasonable.
[0099] Optionally, when the original image corresponding to the target button drawing is a custom graphic, the original image can be completed to a regular image, and a regular virtual baseboard is set according to the shape of the regular image completed from the original image.
[0100] Optionally, when the original image corresponding to the target button drawing is a custom graphic, a virtual baseboard that can completely cover the original image can be set according to the shape of the original image, and the virtual baseboard is a regular graphic. After arranging the virtual buttons in the virtual baseboard based on the preset physical rules, a sliding window is set using the shape of the original image, and the sliding window is used to slide in the virtual baseboard to obtain the arrangement scheme of the virtual buttons that best meets the expectation as the final result, and the baseboard file recording at least the position information of each virtual button is obtained according to the final result.
[0101] Optionally, the baseboard file can be an SVG file, a CSV file, or any file that can store entity position information. The baseboard file records the coordinate data of each virtual button on the virtual baseboard.
[0102] S3, color filling the virtual buttons in the base plate file according to the original image corresponding to the target button drawing, to obtain the image file of the target button drawing.
[0103] Optionally, the color filling the virtual buttons in the base plate file according to the original image corresponding to the target button drawing, to obtain the image file of the target button drawing, comprises:
[0104] According to the original image corresponding to the target button drawing, the coordinate mapping of the original image and the base plate file is established;
[0105] According to the coordinate mapping and the position information of each virtual button, the original color corresponding to each virtual button is obtained;
[0106] According to the original color corresponding to each virtual button, the virtual buttons in the base plate file are color filled, to obtain the image file of the target button drawing.
[0107] Optionally, the color filling the virtual buttons in the base plate file according to the original color corresponding to each virtual button, to obtain the image file of the target button drawing, comprises:
[0108] According to the original color corresponding to each virtual button, the virtual buttons in the base plate file are color filled, to obtain the original color data;
[0109] Loading the printing color in the color plate file, and replacing the color in the original color data with the printing color to obtain the printing color data;
[0110] According to the printing color data, the image file of the target button drawing is obtained.
[0111] Optionally, loading the printing color in the color plate file, and replacing the color in the original color data with the printing color to obtain the printing color data, comprises:
[0112] Loading all the printing colors in the color plate file, to obtain the RGB component corresponding to each printing color;
[0113] According to the original color data, the printing color data is obtained by replacing the corresponding color in the original color data with the closest printing color of each color in the original color data.
[0114] Optionally, the image file can be an SVG file, a CSV file, or other files that can store entity position information and color information. The image file records the coordinate data of each virtual button on the virtual base plate and the color data of each virtual button.
[0115] Optionally, it further comprises designing the surface of each virtual button in the image file.
[0116] Optionally, the surface design of each virtual button in the image file includes material design, texture design, etc.
[0117] Optionally, it further includes traversing each virtual button in the image file to obtain the type and quantity of the virtual button.
[0118] Optionally, the image file can also be rendered and the corresponding picture can be exported.
[0119] Embodiment 3
[0120] A button picture generation method further includes:
[0121] configuring a Pygame window as a virtual base plate and configuring instances in the Pygame window as virtual buttons in Pymunk according to user input;
[0122] making the virtual buttons freely fall and arrange in the virtual base plate based on preset pymunk space gravity and instance collision rules to obtain a base plate file recording at least position information of each virtual button;
[0123] color filling the virtual buttons in the base plate file according to an original image corresponding to a target button picture to obtain a base plate file recording at least position information and color information of each virtual button;
[0124] obtaining a vector file of the target button picture according to the base plate file recording at least position information and color information of each virtual button.
[0125] Optionally, configuring a Pygame window as a virtual base plate and configuring instances in the Pygame window as virtual buttons in Pymunk according to user input includes:
[0126] configuring the shape and size of the Pygame window in Pymunk according to user input to obtain a virtual base plate of the target button picture; and / or
[0127] configuring the size of the instance and the proportion of the number of instances of different sizes in the Pygame window according to user input to obtain the virtual button.
[0128] Optionally, making the virtual buttons freely fall and arrange in the virtual base plate based on preset pymunk space gravity and instance collision rules to obtain a base plate file recording at least position information of each virtual button includes:
[0129] making the virtual buttons arrange in the virtual base plate based on preset physical rules, and obtaining a blank area according to the arrangement result; the blank area is equal to the area of the virtual base plate minus the area of all virtual buttons;
[0130] Repeat the above steps according to the preset number of times to obtain the arrangement result with the minimum blank area;
[0131] The arrangement result with the minimum blank area is obtained, and a bottom plate file recording position information of each virtual button is obtained.
[0132] Optionally, according to the bottom plate file recording position information and color information of each virtual button, a vector file of the target button drawing is obtained, including:
[0133] According to the original image corresponding to the target button drawing, a coordinate mapping between the original image and the bottom plate file is established;
[0134] According to the coordinate mapping and the position information of each virtual button, the original color corresponding to each virtual button is obtained;
[0135] According to the original color corresponding to each virtual button, the virtual button in the bottom plate file is filled with color to obtain the vector file of the target button drawing.
[0136] Optionally, according to the original color corresponding to each virtual button, the virtual button in the bottom plate file is filled with color to obtain the vector file of the target button drawing, including:
[0137] According to the original color corresponding to each virtual button, the virtual button in the bottom plate file is filled with color to obtain the original color data;
[0138] The printing color in the color plate file is loaded, and the color in the original color data is replaced by using the printing color to obtain printing color data;
[0139] According to the printing color data, the vector file of the target button drawing is obtained.
[0140] Optionally, the printing color in the color plate file is loaded, and the color in the original color data is replaced by using the printing color to obtain printing color data, including:
[0141] All printing colors in the color plate file are loaded to obtain the RGB component corresponding to each printing color;
[0142] According to the original color data, the closest printing color to each color in the original color data is obtained, and the corresponding color in the original color data is replaced by using the printing color to obtain the printing color data.
[0143] Optionally, it further includes designing the surface of each virtual button in the vector file.
[0144] Optionally, it further includes traversing each virtual button in the vector file or the bottom plate file to obtain the type and quantity of the virtual button.
[0145] Embodiment 4
[0146] As Figures 2 to 4 shown, the embodiment is an optional example, a button drawing generation method, comprising:
[0147] Use Pymunk for simulation processing, create a Pygame window as a virtual baseboard according to the user input baseboard size, such as 600x900, 900x600, 600x900, A4 horizontal graph or A4 vertical graph, create small virtual buttons and large virtual button instances according to a certain ratio such as 1:3, set the size of the rigid body according to the size of the virtual button. Place it in the Pygame window, set the space gravity of pymunk to (0, 900) to make the virtual button instance fall freely. The virtual button instance after falling is subjected to collision detection, which will have a small displacement based on collision detection, similar to the real collision effect. When the speed of all virtual button instances is less than the critical value, it is considered that the current simulation has stabilized. This simulation ends. Calculate the area of the blank, subtract the area of all virtual buttons in the virtual baseboard from the area of the virtual baseboard. To ensure the minimum remaining area, set the maximum number of iterations, such as 10 times, and through multiple simulations, obtain the optimal solution. After all simulations are completed, write the information of the virtual button instance of the optimal solution to the baseboard file, and the baseboard file uses the csv format, each line is a description of a circle, such as x corresponds to x coordinate, y corresponds to y coordinate, radius corresponds to radius, specifically like (100, 50, 5.9) indicates that at the canvas coordinate (x = 100, y = 50), a virtual button with a radius of 5.9 needs to be placed.
[0148] After the baseboard file is generated, select a picture according to the user's input, traverse all data records in the baseboard file, and take out the position description of each virtual button, including x coordinate, y coordinate, and radius. Based on the x coordinate, y coordinate, and radius information, get the corresponding pixel color information, that is, the RGBA value, in the corresponding position in the picture, mark the RGBA value as the original color, and obtain the original color data of all virtual buttons. Load all printing colors in the color palette file, find the printing color closest to the original color of each virtual button, and use it as the final color displayed by the virtual button at the corresponding position. Obtain the printing color data. Finally, according to the printing color data, obtain the image file of the target button drawing. Generally, the image file of the target button drawing is an SVG file, which includes the x coordinate, y coordinate, radius, and color data of each virtual button.
[0149] Specifically, the effect of importing the image file into the web page for display is as Figure 2 shown.
[0150] The specific color replacement process is: loading all the printing colors. Take out the corresponding RGB component of each color. Use the KDTree in the Python Scipy library to build a K-dimensional tree. Pass in the original color, and find the nearest value of the corresponding RGB component. Replace the original color with the nearest value in the printing color printing color. The color replacement process is completed.
[0151] Optionally, use the Python script to traverse the elements in the drawing SVG file, merge the virtual buttons of the same type, and generate a corresponding material delivery list file. Each line records a specific color and the number of buttons required. The delivery list file can be used as a reference for subsequent product production and packaging.
[0152] Optionally, the 3D model file of the virtual button can also be imported into the Threejs page environment, and loaded using SVGLoader in Threejs. After the SVG file is loaded, traverse each virtual button element in it, create a corresponding 3D object, and set the color using the information in the drawing.
[0153] Specifically, the effect of importing the virtual button 3D model file into the Threejs page environment is as shown in Figure 3 .
[0154] Optionally, Physically Based Rendering technology can also be used for setting. The specific properties include:
[0155] Set roughness to control the microscopic roughness of the material surface;
[0156] Set metalness to define whether the material is metal. Metal surfaces are mainly characterized by high reflectivity, and non-metal surfaces are mainly characterized by diffuse reflection;
[0157] Set the parallel light directional light, ambient light, and according to the size of the picture, set multiple spotlights on the top, add environmental texture maps, increase the realism of rendering, add orbit control, and users can rotate, zoom, move, and other operations on the canvas. Combined with the multi-scene map, simulate the real display effect;
[0158] Set the color of the button to be presented by the fill color attribute in the SVG file.
[0159] Specifically, the image after setting using the Physically Based Rendering technology is as shown in Figure 4 .
[0160] Optionally, a color selection component can also be added to freely switch the color of the base plate or select the original image mat bottom effect.
[0161] Optionally, after adjusting the effect, use the multi-target rendering method to export the high-resolution rendering effect to a picture and download it. The final rendering effect of the effect picture and the physical product is highly consistent, which can quickly help users set and select custom content and maximize efficiency.
[0162] Specifically, an example of an SVG file
[0163] XML
[0164] <svg width="420" height="594" xmlns="http: / / www.w3.org / 2000 / svg">
[0165] <g> <circle cx="190.14" cy="559.68" r="7.8" stroke-width="1" fill="#003a40">< / circle>
[0166] < / g> <g> <circle cx="240.58" cy="557.93" r="7.8" stroke-width="1" fill="#003a40">< / circle>
[0167] < / g> <g> <circle cx="205.7" cy="561.81" r="7.8" stroke-width="1" fill="#efedde">< / circle>
[0168] < / g> < / svg>
[0169] Wherein svg width="420" height="594" is the size of the virtual base plate, which is 420*594, circle is a virtual button, cx="190.14" represents the x coordinate is 190.14, cy="559.68" represents the y coordinate is 559.68, r="7.8" represents the radius of the virtual button is 7.8, stroke-width="1" represents the line width is 1, and fill="#003a40" represents the color is #003a40.
[0170] Embodiment 5
[0171] A button picture generation system includes a base plate construction module and a button picture configuration module.
[0172] The base plate construction module is configured to:
[0173] In response to receiving the input of the user, obtain the virtual base plate and the virtual button of the target button picture;
[0174] Arrange the virtual buttons in the virtual base plate based on a preset physical rule, and obtain a base plate file recording at least the position information of each virtual button;
[0175] The button picture configuration module is configured to:
[0176] According to the original image corresponding to the target button picture, color fill the virtual buttons in the base plate file, and obtain an image file of the target button picture.
[0177] Optionally, in response to receiving the input of the user, obtaining the virtual base plate and the virtual button of the target button picture includes:
[0178] In response to receiving the input of the user, obtaining the shape and size of the virtual base plate of the target button picture; and / or
[0179] In response to receiving the input of the user, the size of the virtual button of the target button drawing and the proportion of the number of virtual buttons of different sizes are obtained.
[0180] Optionally, the preset physical rules include:
[0181] Setting a gravity rule for the virtual base plate and / or the virtual button; and / or
[0182] Setting a collision rule for the virtual base plate and / or the virtual button.
[0183] Optionally, the virtual buttons are arranged in the virtual base plate based on the preset physical rules, and a base plate file recording at least the position information of each virtual button is obtained, including:
[0184] The virtual buttons are arranged in the virtual base plate based on the preset physical rules, and a blank area is obtained according to the arrangement result;
[0185] The above steps are repeated for a preset number of times to obtain an arrangement result with the smallest blank area;
[0186] The arrangement result with the smallest blank area, and a base plate file recording at least the position information of each virtual button is obtained.
[0187] Optionally, the virtual buttons in the base plate file are color filled according to the original image corresponding to the target button drawing, and an image file of the target button drawing is obtained, including:
[0188] The coordinate mapping between the original image and the base plate file is established according to the original image corresponding to the target button drawing;
[0189] The original color corresponding to each virtual button is obtained according to the coordinate mapping and the position information of each virtual button;
[0190] The virtual buttons in the base plate file are color filled according to the original color corresponding to each virtual button, and an image file of the target button drawing is obtained.
[0191] Optionally, the virtual buttons in the base plate file are color filled according to the original color corresponding to each virtual button, and an image file of the target button drawing is obtained, including:
[0192] The original color data is obtained after the virtual buttons in the base plate file are color filled according to the original color corresponding to each virtual button;
[0193] The printing color data is obtained after the color in the original color data is replaced using the printing color loaded from the color palette file;
[0194] The image file of the target button drawing is obtained according to the printing color data.
[0195] Optionally, load the printing colors from the color swatch file, and replace the colors in the original color data with the printing colors to obtain the printing color data, including:
[0196] Load all printing colors from the color swatch file and obtain the RGB components corresponding to each printing color;
[0197] Based on the original color data, obtain the closest printing color for each color in the original color data, and then replace the corresponding color in the original color data with this printing color to obtain the printing color data.
[0198] Optionally, it also includes designing the surface of each virtual button in the image file.
[0199] Optionally, it also includes iterating through each virtual button in the image file to obtain the type and quantity of the virtual buttons.
[0200] Example 6
[0201] This embodiment provides a device including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement any of the methods described above.
[0202] Specifically, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of this application. The device is an electronic device and may include: a processor 101, such as a central processing unit (CPU), a communication bus 102, a user interface 104, a network interface 103, and a memory 105. The communication bus 102 is used to realize the connection and communication between these components. The user interface 104 may include a display screen and an input unit such as a keyboard. Optionally, the user interface 104 may also include a standard wired interface and a wireless interface. The network interface 103 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 105 may be a storage device independent of the aforementioned processor 101. The memory 105 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as at least one disk storage device. The processor 101 may be a general-purpose processor, including a central processing unit, a network processor, etc., or it may be a digital signal processor, an application-specific integrated circuit, a field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component.
[0203] Those skilled in the art can understand that the structure shown in the Figure 5 embodiments does not constitute a limitation on electronic devices, and can include more or fewer components than shown, or combine certain components, or arrange different components.
[0204] As shown in Figure 5 , the memory 105 as a storage medium can include an operating system, a network communication module, a user interface module, and an application program for implementing the button picture generation method.
[0205] In the electronic device shown in Figure 5 , the network interface 103 is mainly used for data communication with a network server; the user interface 104 is mainly used for data interaction with a user; the processor 101 and the memory 105 in the present application can be arranged in the electronic device, and the electronic device calls the application program stored in the memory 105 for implementing the button picture generation method by the processor 101 to implement the above method.
[0206] Embodiment 7
[0207] The embodiment provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and a processor executes the computer program to implement any of the above methods.
[0208] In some embodiments, the computer readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or various devices including one or any combination of the above memories. The computer can be various computing devices including smart terminals and servers.
[0209] In the above embodiments of the present disclosure, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0210] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented by other ways. Among them, the device embodiments described above are only schematic, for example, the division of units can be a logical function division, and actual implementation can have another division way, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between units or modules, which can be electrical or other forms.
[0211] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0212] In addition, each functional unit in various embodiments of the present disclosure can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0213] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable nonvolatile storage medium. Based on this understanding, the technical scheme of the present disclosure or the part that contributes to the prior art or the whole or part of the technical scheme can be embodied in the form of a software product. The computer software product is stored in a nonvolatile storage medium, including a plurality of instructions for causing an apparatus (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the various embodiments of the present disclosure. The aforementioned nonvolatile storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0214] The above is only the preferred embodiment of the present disclosure, and it should be noted that for those skilled in the art, without departing from the principles of the present disclosure, several improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present disclosure.
Claims
1. A method for generating button paintings, characterized in that, include: In response to receiving user input, obtain the virtual base and virtual button for the target button drawing; The virtual buttons to be filled are randomly placed on the virtual base plate. At least one of collision detection, gravity simulation, friction simulation and base plate shaking simulation are introduced to fill the virtual buttons on the virtual base plate and ensure that the virtual buttons do not overlap. A base plate file with at least the position information of each virtual button is obtained. Based on the original image corresponding to the target button drawing, establish a coordinate mapping between the original image and the base plate file; Based on the coordinate mapping and the position information of each virtual button, the original color corresponding to each virtual button is obtained; The virtual buttons in the base file are filled with color according to the original color corresponding to each virtual button to obtain the image file of the target button drawing.
2. The button painting generation method according to claim 1, characterized in that, The step of responding to received user input and obtaining the virtual base and virtual button of the target button drawing includes: In response to receiving user input, obtain the shape and size of the virtual base of the target button drawing; and / or In response to receiving user input, the dimensions of the virtual buttons in the target button drawing and the proportion of virtual buttons of different sizes are obtained.
3. The button painting generation method according to claim 1, characterized in that, The process involves randomly placing virtual buttons to be filled onto a virtual base plate, incorporating at least one of collision detection, gravity simulation, friction simulation, and base plate wobbling simulation to fill the virtual buttons onto the virtual base plate, ensuring that the virtual buttons do not overlap, and obtaining a base plate file that records the position information of each virtual button, including: The virtual buttons to be filled are randomly placed on the virtual base plate. At least one of collision detection, gravity simulation, friction simulation and base plate shaking simulation are introduced to fill the virtual buttons on the virtual base plate, ensuring that the virtual buttons do not overlap. The blank area is obtained according to the arrangement result. Repeat the above steps a preset number of times to obtain the arrangement result with the smallest blank area; The arrangement with the smallest blank area yields a base plate file that records at least the position information of each virtual button.
4. The button painting generation method according to claim 1, characterized in that, The step of filling the virtual buttons in the base file with colors according to the original colors corresponding to each virtual button to obtain the image file of the target button drawing includes: The original color data is obtained by color-filling the virtual buttons in the base plate file according to the original color corresponding to each virtual button. The printing colors are loaded from the color swatch file, and the original colors are replaced with the printing colors to obtain the printing color data. Based on the printing color data, obtain the image file of the target button painting.
5. The button painting generation method according to claim 4, characterized in that, The printing colors in the loaded color palette file are used to replace the colors in the original color data to obtain printing color data, including: Load all printing colors from the color swatch file and obtain the RGB components corresponding to each printing color; Based on the original color data, obtain the printing color that is closest to each color in the original color data, and replace the corresponding color in the original color data with the printing color to obtain the printing color data.
6. The button painting generation method according to claim 1, characterized in that, It also includes designing the surface of each virtual button in the image file.
7. The button painting generation method according to claim 1, characterized in that, It also includes iterating through each virtual button in the image file or base file to obtain the type and quantity of the virtual buttons.
8. A method for generating button paintings, characterized in that, Also includes: In Pymunk, configure the Pygame window as a virtual base and configure instances in the Pygame window as virtual buttons based on user input; Based on the preset spatial gravity of pymunk and the collision rules of the instance, the virtual buttons are allowed to fall freely and be arranged in the virtual base plate, thereby obtaining a base plate file that records at least the position information of each virtual button. Based on the original image corresponding to the target button drawing, establish a coordinate mapping between the original image and the base plate file; Based on the coordinate mapping and the position information of each virtual button, the original color corresponding to each virtual button is obtained; The virtual buttons in the base plate file are filled with color according to the original color corresponding to each virtual button, so as to obtain a base plate file that records at least the position information and color information of each virtual button. Based on the base file containing at least the position and color information of each virtual button, obtain the vector file of the target button drawing.
9. A button painting generation system, characterized in that, Includes a base plate construction module and a button painting configuration module; The base plate construction module is configured as follows: In response to receiving user input, obtain the virtual base and virtual button for the target button drawing; The virtual buttons to be filled are randomly placed on the virtual base plate. At least one of collision detection, gravity simulation, friction simulation and base plate shaking simulation are introduced to fill the virtual buttons on the virtual base plate and ensure that the virtual buttons do not overlap. A base plate file with at least the position information of each virtual button is obtained. The button art configuration module is configured as follows: Based on the original image corresponding to the target button drawing, establish a coordinate mapping between the original image and the base plate file; Based on the coordinate mapping and the position information of each virtual button, the original color corresponding to each virtual button is obtained; The virtual buttons in the base file are filled with color according to the original color corresponding to each virtual button to obtain the image file of the target button drawing.
10. A device, characterized in that, The device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1-7.
11. A device, characterized in that, The device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to claim 8.
Citation Information
Patent Citations
Method of digital design generation
CA2986327A1
Method of building physical experiment according to hand-painted pattern
CN106710318A