Graphical auto-lay-out method, system, medium and processor supporting dual mode
By supporting a dual-mode automatic graphic layout method and system, the optimal spacing is dynamically calculated and overlap detection is performed, which solves the problems of low efficiency, poor flexibility and insufficient reliability in the existing technology, and realizes efficient and accurate graphic layout, which is suitable for high-end manufacturing fields such as CNC cutting, graphic printing and electronic design.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN JINGWEI LINE TECH CO LTD
- Filing Date
- 2026-02-27
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies suffer from low efficiency, poor flexibility, insufficient reliability, and low level of intelligence in CNC cutting, graphic printing, and mobile phone film cutting. In particular, it is difficult to achieve automated and accurate graphic layout when there are multiple models and different layout requirements.
This paper provides a method and system for automatic graphic layout that supports dual modes. It can dynamically calculate the optimal spacing in centering mode and center line mode to achieve uniform distribution and alignment of graphics. The system includes receiving layout parameters, parsing graphic data, calculating the optimal spacing, performing overlap detection and outputting layout results. It also supports parametric design and template management.
It significantly improves typesetting efficiency and accuracy, achieves intelligent anti-overlapping of graphics, adapts to different typesetting needs, enhances material utilization and the level of automation in typesetting, and is suitable for processing graphics of multiple sizes and quantities.
Smart Images

Figure CN122115629A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of mobile phone film cutting and layout, and in particular to a method, system, medium, and processor for automatic graphic layout that supports dual modes. Background Technology
[0002] In industrial applications such as CNC cutting, graphic printing, and mobile phone screen protector cutting, it is often necessary to arrange multiple graphics on materials of fixed dimensions (such as films or sheets). Traditional layout methods mainly rely on manual operation or the use of fixed templates, which have obvious drawbacks: Inefficient: Manually adjusting the position, spacing, and alignment of each graphic is time-consuming and difficult to handle large batches of tasks.
[0003] Poor flexibility: Fixed templates cannot adapt to different combinations of graphics with different models, quantities and layout requirements, resulting in low material utilization or inability to meet special alignment requirements (such as arrangement along a specific baseline).
[0004] Insufficient reliability: The lack of an automated overlap detection mechanism makes it easy for processing errors, material waste, or even equipment damage to occur due to pattern interference.
[0005] Low level of intelligence: Existing solutions are mostly designed for a single typesetting mode (such as only supporting overall centering), and cannot intelligently switch between multiple typesetting models and optimize different layout strategies within the same system.
[0006] Therefore, there is an urgent need for a technical solution that can automatically adapt to different typesetting needs, intelligently prevent graphic overlap, and significantly improve typesetting efficiency and accuracy.
[0007] Therefore, there is a need for a dual-mode automatic graphic layout method, system, media, and processor. Summary of the Invention
[0008] To address the issues of poor flexibility and insufficient reliability in existing technologies, this invention provides a dual-mode automatic graphic layout method, system, medium, and processor. It supports both center-aligned and center-line-aligned layout modes, enabling intelligent distribution and alignment of graphics within a defined area, effectively preventing overlap and improving layout efficiency and accuracy. The specific technical solution is as follows: Firstly, a method for automatic graphic layout supporting dual modes is provided, comprising: S1: receiving input layout parameters, wherein the layout parameters include at least a graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics, and surrounding white space; the layout mode identifier includes centering mode or center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates; S2: parsing the graphic dataset to obtain the height and width dimensions of each graphic; S3: executing the following layout process according to the layout mode identifier: S31: if it is centering mode, then according to the layout area size, the total number of graphics, the dimensions of each graphic, and the minimum spacing between graphics... The system dynamically calculates the optimal spacing of graphics in the horizontal and vertical directions, including the spacing around the edges and the margins. It then arranges the graphics by accumulating the graphic size and optimal spacing in rows and columns, automatically determining area boundaries for row / column wrapping. Finally, it generates and outputs graphic position data that ensures all graphics are evenly centered within the layout area. S32: In centerline mode, it calculates the coordinates of the four corner points of each graphic after aligning its center with the centerline based on the layout area size, centerline coordinates, minimum spacing between graphics, margins around the edges, and the size of each graphic, then performs overlap detection. If there is no overlap, it arranges the graphics along the length direction by sequentially accumulating the graphic length and the set minimum spacing, generating and outputting graphic position data for all graphics aligned with the centerline. S4: Outputs the layout result.
[0009] Furthermore, in step S31, the optimal spacing of the graphics in the horizontal and vertical directions is calculated by: under the premise that all graphics are placed within the layout area and comply with the minimum spacing and white space constraints, solving for the maximum uniform spacing that makes the graphics as a whole centered.
[0010] Furthermore, in step S31, the step of accumulating graphic size and optimal spacing by row / column and automatically determining area boundaries to perform row / column breaks includes the following steps: accumulating graphic size and optimal spacing by row and automatically determining area boundaries to perform row breaks; or accumulating graphic size and optimal spacing by column and automatically determining area boundaries to perform column breaks.
[0011] Furthermore, the step of accumulating graphic dimensions and optimal spacing line by line for layout, and automatically determining the area boundary for line breaks, includes the following steps: S311: Accumulate graphic width and optimal horizontal spacing line by line for layout, and determine whether the current accumulated width exceeds the layout area width; S312: If it does not exceed, continue accumulating; if it exceeds, perform line break processing, during which the graphic height and vertical spacing are accumulated, and the horizontal accumulated width is reset to zero and the process returns to step S311.
[0012] Furthermore, the step of arranging the graphic dimensions by column accumulation and the optimal spacing, and automatically determining the area boundary to perform column switching, includes the following steps: S313: Arranging the graphic height by sequential accumulation and the optimal vertical spacing, and determining whether the current accumulated height exceeds the length of the layout area; S314: If the value is not exceeded, continue to accumulate; if the value is exceeded, switch columns. When switching columns, accumulate the graphic width and horizontal spacing, reset the vertical height to zero, and return to step S313.
[0013] Furthermore, when accumulating the graphic width and horizontal spacing, it is determined whether the current accumulated width exceeds the layout area width; if the accumulated width does not exceed the layout area width, the iteration returns to step S313; if the accumulated width exceeds the layout area width, the layout is terminated and the layout graphic position data is output.
[0014] Furthermore, in step S32, when arranging the graphics along the length direction by sequentially accumulating the graphic length and setting a minimum interval, it is necessary to determine in real time whether the current accumulated length exceeds the total length of the layout area; if it does not exceed the area length, return to step S32 to continue accumulating and arranging; if it exceeds the area length, complete the entire layout process and output the final position data of all graphics.
[0015] Secondly, a dual-mode automatic graphic layout system is provided, applied to the aforementioned dual-mode automatic graphic layout, comprising: a receiving module for receiving input layout parameters, wherein the layout parameters include at least a graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics, and surrounding white space; the layout mode identifier includes a centering mode or a center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates; a parsing module for parsing the graphic dataset to obtain the height and width dimensions of each graphic; and a layout module for executing the following layout process according to the layout mode identifier: S31: In centering mode, the optimal spacing of graphics in the horizontal and vertical directions is dynamically calculated based on the layout area size, the total number of graphics, the size of each graphic, the minimum spacing between graphics, and the surrounding white space. The graphic size and optimal spacing are accumulated row by row / column for layout, and the area boundaries are automatically determined for row / column wrapping. Graphic position data that makes all graphics evenly distributed in the center of the layout area is generated and output. S32: In centerline mode, the coordinates of the four corner points of each graphic after the center is aligned with the centerline are calculated based on the layout area size, centerline position coordinates, minimum spacing between graphics, surrounding white space, and the size of each graphic. Then, overlap detection is performed. If there is no overlap, the graphic length and the set minimum spacing are accumulated sequentially along the length direction to generate and output graphic position data of all graphics aligned with the centerline. Output module, which is used to output the layout result.
[0016] Thirdly, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the above-described dual-mode automatic graphic layout method.
[0017] Fourthly, a processor is provided for running a program, wherein the program executes the dual-mode automatic graphic layout method described above.
[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Dual-mode layout mechanism: Supports two layout modes: center alignment and center line alignment, to adapt to different application scenarios.
[0019] 2. Dynamic Spacing Calculation: The system automatically calculates the optimal spacing based on the number of graphics, their size, and the margin distance to ensure centered and uniform distribution.
[0020] 3. Intelligent anti-overlap mechanism: Real-time detection and avoidance of graphic overlap during typesetting, improving typesetting quality; high typesetting accuracy, good consistency, uniform graphic distribution, and no overlap.
[0021] 4. Parametric-driven: All layouts are parametrically designed, supporting flexible expansion and customization.
[0022] 5. Improve typesetting efficiency and automation, and significantly reduce manual intervention.
[0023] 6. Supports batch processing of graphics of multiple sizes and quantities, with strong compatibility.
[0024] 7. Applicable to high-end manufacturing and design fields such as CNC cutting, graphic printing, and electronic design, with strong versatility and expandability. Attached Figure Description
[0025] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0026] Figure 1 A flowchart illustrating a dual-mode automatic graphic layout method; Figure 2 A comparison chart showing the effects of two automatic graphic layout methods; Figure 3 This is a schematic diagram of a dual-mode automatic graphic layout system. Detailed Implementation
[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] It should be understood that, when used in this application, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.
[0029] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0030] It should also be further understood that the term “and / or” as used in this application refers to any combination of one or more of the associated listed items, as well as all possible combinations, and includes such combinations.
[0031] Example 1 like Figure 1 , Figure 2 The diagram shows a flowchart of a dual-mode automatic graphic layout method, which includes the following steps: S1: Receive input layout parameters, which include at least the graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics and surrounding white space; the layout mode identifier includes centering mode or center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates (e.g., 110, 220).
[0032] Furthermore, the centering layout achieves uniform distribution and centered arrangement of graphics within a specified area by automatically calculating the spacing between graphics, while ensuring that there is no overlap between graphics.
[0033] Furthermore, the median line layout aims to use the user-specified median line as a reference, precisely aligning the centers of each graphic to the median line for arrangement, and ensuring that there is no overlap between the graphics.
[0034] Furthermore, the layout area size is set to 340. 500.
[0035] S2: Parse the graphic dataset to obtain graphic size information such as the height and width of each graphic.
[0036] S3: Execute the following typesetting process based on the typesetting mode identifier: S31: If the centering mode is selected, the optimal spacing of the graphics in the horizontal and vertical directions is dynamically calculated based on the layout area size, the total number of graphics, the size of each graphic, the minimum spacing between graphics, and the surrounding white space to ensure that the graphics are centered and evenly distributed. The graphic size and the optimal spacing are accumulated by row / column for layout, and the area boundaries are automatically determined to perform row / column wrapping. Graphic position data that makes all graphics evenly distributed and centered within the layout area is generated and output. In specific implementation, the optimal spacing of the dynamically calculated graphics in the horizontal and vertical directions includes: under the premise that all graphics are placed within the layout area and comply with the minimum spacing and white space constraints, solving for the maximum uniform spacing that centers the graphics as a whole, as shown in the following formula: ; ; ; ; in, The optimal spacing in the horizontal direction; Number of graphics per row; Number of figures in each column; This refers to the width of the layout area; Leave white space around the edges; The width of the i-th graphic; The minimum interval between graphics; The optimal spacing in the vertical direction; This is the height of the layout area; This represents the maximum height of the graphic in column j. This is the height of the layout area.
[0037] In specific implementation, the step of accumulating graphic sizes by row / column and setting up optimal spacing, and automatically determining area boundaries to perform row / column wrapping, includes: The layout is based on the cumulative graphic size and optimal spacing, and the area boundaries are automatically determined for line breaks; or The layout is based on the cumulative graphic size and optimal spacing of each column, and the area boundaries are automatically determined to switch columns.
[0038] In practice, the step of accumulating graphic sizes and optimal spacing by line for layout, and automatically determining area boundaries for line breaks, includes the following steps: S311: Arrange the graphic width and the optimal horizontal spacing sequentially, and determine whether the current accumulated width exceeds the width of the layout area; S312: If the value is not exceeded, continue to accumulate; if the value is exceeded, perform a line break. When performing a line break, accumulate the graphic height and vertical spacing, reset the accumulated horizontal width to zero, and return to step S311.
[0039] Furthermore, when accumulating the graphic height and vertical spacing, it is determined whether the current accumulated height exceeds the length of the layout area; if the accumulated height does not exceed the length of the layout area, the iteration returns to step S311; if the accumulated height exceeds the length of the layout area, the layout is terminated and the layout graphic position data is output.
[0040] In practice, the step of accumulating graphic dimensions and optimal spacing by column for layout, and automatically determining area boundaries to perform column switching, includes the following steps: S313: Arrange the graphic by sequentially accumulating its height (or length) and the optimal vertical spacing (or vertical spacing), and determine whether the current accumulated height exceeds the length of the layout area; S314: If the value is not exceeded, continue to accumulate; if the value is exceeded, switch columns. When switching columns, accumulate the graphic width and horizontal spacing, reset the vertical height to zero, and return to step S313.
[0041] Furthermore, when accumulating the graphic width and horizontal spacing, it is determined whether the current accumulated width exceeds the layout area width; if the accumulated width does not exceed the layout area width, the iteration returns to step S313; if the accumulated width exceeds the layout area width, the layout is terminated and the layout graphic position data is output.
[0042] S32: If it is in center line mode, calculate the coordinates of the four corner points of each graphic after the center of each graphic is aligned with the center line based on the layout area size, center line position coordinates, minimum interval between graphics, white space around the edges, and the size of each graphic, and then perform overlap detection; if there is no overlap, layout is performed along the length direction by sequentially accumulating the graphic length and the set minimum interval, generating and outputting graphic position data of all graphics aligned with the center line.
[0043] Furthermore, when arranging the graphics along the length direction by sequentially accumulating the graphic length and setting a minimum interval, it is necessary to determine in real time whether the current accumulated length exceeds the total length of the layout area; if it does not exceed the area length, return to step S32 to continue accumulating and arranging; if it exceeds the area length, complete the entire layout process and output the final position data of all graphics.
[0044] Furthermore, the overlap detection refers to using an axis-aligned bounding box collision detection algorithm to determine whether the bounding rectangles of any two shapes intersect. For any two shapes A and B, the coordinate range of their axis-aligned bounding boxes (AABB) is calculated respectively: The bounding box extent of graphic AA: ; ; The bounding box extent of graphic B: ; ; in, For graphics The center coordinates; For graphics Width and height; For graphics The center coordinates; For graphics Width and height.
[0045] Two figures do not overlap if any of the following conditions are met. ; ; Otherwise, the two figures overlap.
[0046] Furthermore, if the overlap detection result indicates that overlap exists, the typesetting process will be terminated and an error message will be output.
[0047] S4: Output the layout result.
[0048] Furthermore, the method also includes: S5: Provides parameter template management functionality, allowing users to save and recall preset layout parameter combinations. Furthermore, the following alternative solutions are proposed to improve automation levels: S51: Unified parameter setting scheme: Unified management of input parameters (such as margin distance, spacing threshold) and layout method (centering / median line) required for typesetting, which takes effect globally after one setting, avoiding repeated input.
[0049] S52: Template-based setup: Commonly used "parameter combinations + layout methods" are predefined as fixed templates, and users can directly select templates for layout; at the same time, it supports setting default templates to further reduce operation steps.
[0050] S53: Cloud-based parameter distribution solution: Layout parameters, layout methods, template schemes, etc. are stored on a cloud server. The user terminal obtains the data by calling the server interface, realizing "one-time cloud setting, global synchronization and use across multiple terminals".
[0051] The above-mentioned alternatives can significantly reduce manual intervention, while improving the consistency of typesetting parameters and enhancing the versatility and scalability of this application in different devices and scenarios.
[0052] In some implementations, this solution can also be used for layout of roll materials, as follows: the layout does not require inputting the film height, but rather directly inputting how many to cut, and the system will automatically calculate how to arrange them.
[0053] Four pieces of information are required: 1. The total number of pieces to be cut (e.g., 10 pieces).
[0054] 2. Width of the roll material (e.g., 600mm).
[0055] 3. Graphic data (from the graphic dimensions; for example, width 120mm × height 50mm).
[0056] 4. Spacing (e.g., 2mm).
[0057] The system will automatically fill the roll width horizontally, and then continue arranging it in the next row until the required quantity is reached.
[0058] The system will output: the total number of rows and columns (e.g., 3 rows x 4 columns; additionally, the 10th item is placed in the 3rd row and 2nd column; the 3rd row can also be placed after the current row is cut, for a total of 12 items); and the total length of roll material required (cumulative along the height, including spacing). Example: The roll is 600mm wide, the graphic is 120×50mm, the spacing is 2mm, and 10 pieces need to be cut.
[0059] A row can hold a maximum of 600 ÷ (120 + 2) ≈ 4 characters.
[0060] Arrange in 3 rows: 4 in each of the first 2 rows (8 in total), and 2 in the 3rd row.
[0061] Required length = 3 rows × (50mm graphic height + 2mm spacing) + last row spacing → Actual length calculated based on the full row height is 3 × 52 + 2 = 158mm.
[0062] Understandably, there's no need to consider the length of the roll material; simply specify the "number of cuts," and the system will automatically calculate the optimal layout and the minimum required material length, making it particularly suitable for efficient batch cutting of continuous roll materials.
[0063] Example 2 like Figure 3 The diagram shows a structural schematic of a dual-mode automatic graphic layout system, applied to the aforementioned dual-mode automatic graphic layout, including: A receiving module is used to receive input layout parameters, which include at least the graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics and surrounding white space; the layout mode identifier includes centering mode or center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates. The parsing module is used to parse the graphic dataset and obtain the height and width dimensions of each graphic. The typesetting module is used to execute the following typesetting process based on the typesetting mode identifier: S31: If it is in centering mode, then based on the layout area size, the total number of graphics, the size of each graphic, the minimum spacing between graphics and the surrounding white space, dynamically calculate the optimal spacing of the graphics in the horizontal and vertical directions; arrange the graphics by accumulating the graphic size and the optimal spacing by row / column, and automatically determine the area boundary to perform row / column wrapping; generate and output graphic position data that makes all graphics evenly distributed in the center within the layout area. S32: If it is in center line mode, calculate the coordinates of the four corner points of each graphic after the center of each graphic is aligned with the center line based on the layout area size, center line position coordinates, minimum interval between graphics, white space around the edges, and the size of each graphic, and then perform overlap detection; if there is no overlap, layout along the length direction by sequentially accumulating the graphic length and the set minimum interval, generating and outputting graphic position data of all graphics aligned with the center line; The output module is used to output the layout results.
[0064] Example 3 A computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform the above-described dual-mode automatic graphic layout method.
[0065] Example 4 A processor for running a program, wherein the program executes the dual-mode automatic graphic layout method described above.
[0066] The beneficial effects of the technical solution in this application are as follows: 1. Dual-mode layout mechanism: Supports two layout modes: centering and center line, to adapt to the layout needs of different application scenarios (such as symmetrical layout of multiple graphics).
[0067] 2. Dynamic Spacing Calculation: The system automatically calculates the optimal spacing based on the number of graphics, their size, and the margin distance to ensure centered and uniform distribution.
[0068] 3. Intelligent anti-overlap mechanism: Real-time detection and prevention of graphic overlap during typesetting, improving typesetting quality.
[0069] 4. Parametric-driven: All layout parameters (such as margin distance, center line position, and spacing threshold) are parametrically designed, allowing for flexible modification or addition of parameters according to subsequent needs, adapting to more personalized layout scenarios, and supporting flexible expansion and customization.
[0070] This application discloses a dual-mode automatic graphic layout method, system, medium, and processor, relating to the field of mobile phone film cutting and layout. The method includes: receiving layout parameters including a graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics, and surrounding white space; executing a centering mode or median line mode layout process according to the layout mode identifier; dynamically calculating the optimal spacing in centering mode, accumulating graphic size and spacing by row / column for layout, and automatically wrapping rows / columns to achieve uniformly centered graphic distribution; aligning the centers of each graphic to a specified median line in median line mode, performing overlap detection, and accumulating layout along the length direction. This application supports intelligent switching between dual modes, possesses dynamic spacing calculation and intelligent anti-overlap mechanisms, significantly improving layout efficiency, accuracy, and automation level, and is suitable for industrial applications such as CNC cutting and graphic printing.
[0071] Those skilled in the art will recognize that the units of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the invention.
[0072] In the embodiments provided by the present invention, it should be understood that the division of units is only a logical functional division. In actual implementation, there may be other division methods, such as multiple units can be combined into one unit, one unit can be split into multiple units, or some features can be ignored.
[0073] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0074] If the integrated unit is implemented as a software functional unit 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 invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of this application.
Claims
1. A method for automatic graphic layout supporting dual modes, characterized in that, include: S1: Receive input layout parameters, which include at least the graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics and surrounding white space; the layout mode identifier includes centering mode or center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates; S2: Parse the graphic dataset to obtain the height and width dimensions of each graphic; S3: Execute the following typesetting process based on the typesetting mode identifier: S31: If it is in centering mode, then based on the layout area size, the total number of graphics, the size of each graphic, the minimum spacing between graphics and the surrounding white space, dynamically calculate the optimal spacing of the graphics in the horizontal and vertical directions; arrange the graphics by accumulating the graphic size and the optimal spacing by row / column, and automatically determine the area boundary to perform row / column wrapping; generate and output graphic position data that makes all graphics evenly distributed in the center within the layout area. S32: If it is in center line mode, calculate the coordinates of the four corner points of each graphic after the center of each graphic is aligned with the center line based on the layout area size, center line position coordinates, minimum interval between graphics, white space around the edges, and the size of each graphic, and then perform overlap detection; if there is no overlap, layout along the length direction by sequentially accumulating the graphic length and the set minimum interval, generating and outputting graphic position data of all graphics aligned with the center line; S4: Output the layout result.
2. The automatic graphic layout method supporting dual modes according to claim 1, characterized in that, In step S31, the optimal spacing of the graphics in the horizontal and vertical directions is calculated by solving the maximum uniform spacing that makes the graphics centered, provided that all graphics are placed within the layout area and comply with the minimum spacing and white space constraints.
3. The automatic graphic layout method supporting dual modes according to claim 1, characterized in that, In step S31, the step of accumulating graphic dimensions by row / column and setting up the layout with optimal spacing, and automatically determining area boundaries to perform row / column wrapping, includes the following steps: The layout is based on the cumulative graphic size and optimal spacing, and the area boundaries are automatically determined for line breaks; or The layout is based on the cumulative graphic size and optimal spacing of each column, and the area boundaries are automatically determined to switch columns.
4. The automatic graphic layout method supporting dual modes according to claim 3, characterized in that, The process of accumulating graphic sizes and optimal spacing by line, and automatically determining area boundaries for line breaks, includes the following steps: S311: Arrange the graphic width and the optimal horizontal spacing sequentially, and determine whether the current accumulated width exceeds the width of the layout area; S312: If the value is not exceeded, continue to accumulate; if the value is exceeded, perform a line break. When performing a line break, accumulate the graphic height and vertical spacing, reset the accumulated horizontal width to zero, and return to step S311.
5. The automatic graphic layout method supporting dual modes according to claim 3, characterized in that, The process of arranging graphics by column accumulation and optimal spacing, and automatically determining area boundaries to switch columns, includes the following steps: S313: Arrange the graphic by sequentially accumulating its height and the optimal vertical spacing, and determine whether the current accumulated height exceeds the length of the layout area; S314: If the value is not exceeded, continue to accumulate; if the value is exceeded, switch columns. When switching columns, accumulate the graphic width and horizontal spacing, reset the vertical height to zero, and return to step S313.
6. The automatic graphic layout method supporting dual modes according to claim 5, characterized in that, When accumulating the graphic width and horizontal spacing, it is determined whether the current accumulated width exceeds the layout area width; if the accumulated width does not exceed the layout area width, the iteration returns to step S313; if the accumulated width exceeds the layout area width, the layout is terminated and the layout graphic position data is output.
7. The automatic graphic layout method supporting dual modes according to claim 1, characterized in that, In step S32, when arranging the graphics along the length direction by sequentially accumulating the graphic length and setting a minimum interval, it is necessary to determine in real time whether the current accumulated length exceeds the total length of the layout area; if it does not exceed the area length, return to step S32 to continue accumulating and arranging; if it exceeds the area length, complete the entire layout process and output the final position data of all graphics.
8. A dual-mode automatic graphic layout system, characterized in that, The automatic graphic layout supporting dual modes as described in any one of claims 1 to 7 includes: A receiving module is used to receive input layout parameters, which include at least the graphic dataset, layout area size, layout mode identifier and corresponding mode parameters, minimum spacing between graphics and surrounding white space; the layout mode identifier includes centering mode or center line mode; the mode parameter corresponding to the centering mode is the total number of graphics; the mode parameter corresponding to the center line mode is the center line position coordinates. The parsing module is used to parse the graphic dataset and obtain the height and width dimensions of each graphic. The typesetting module is used to execute the following typesetting process based on the typesetting mode identifier: S31: If it is in centering mode, then based on the layout area size, the total number of graphics, the size of each graphic, the minimum spacing between graphics and the surrounding white space, dynamically calculate the optimal spacing of the graphics in the horizontal and vertical directions; arrange the graphics by accumulating the graphic size and the optimal spacing by row / column, and automatically determine the area boundary to perform row / column wrapping; generate and output graphic position data that makes all graphics evenly distributed in the center within the layout area. S32: If it is in center line mode, calculate the coordinates of the four corner points of each graphic after the center of each graphic is aligned with the center line based on the layout area size, center line position coordinates, minimum interval between graphics, white space around the edges, and the size of each graphic, and then perform overlap detection; if there is no overlap, layout along the length direction by sequentially accumulating the graphic length and the set minimum interval, generating and outputting graphic position data of all graphics aligned with the center line; The output module is used to output the layout results.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the dual-mode automatic graphic layout method according to any one of claims 1 to 7.
10. A processor, characterized in that, The processor is used to run a program, wherein the program executes the dual-mode automatic graphic layout method according to any one of claims 1 to 7.