Method, device, electronic device and storage medium for arranging virtual elements
By calculating the centering values of multiple array arrangement methods and automatically selecting the arrangement method with the smallest value, the problem of low efficiency of virtual element arrangement in the existing technology is solved, and the automatic centering arrangement of virtual elements in the display interface is realized.
Patent Information
- Application Number
- CN202210501713.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-09
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-05-09
AI Technical Summary
In the prior art, the centering arrangement of virtual elements requires manual code adjustment in the display interface, resulting in low efficiency and failure to automatically adapt when the interface size or the number of elements changes.
By determining multiple array arrangements, calculating the number of rows and columns, selecting the center value with the smallest value, and automatically outputting the best center arrangement.
The virtual elements are automatically centered on the display interface, which improves the arrangement efficiency and adapts to interface changes.
Smart Images

Figure CN114912054B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of element arrangement, and in particular to a method, device, electronic device and storage medium for virtual element arrangement. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] Currently, most apps and websites use a more or less centered arrangement method to arrange virtual elements, such as text or images, in their display interfaces. However, the centering of virtual elements in current display interfaces is pre-set, meaning the position of each virtual element is simply hard-coded during code writing. This approach only works when the number of virtual elements and the display interface remain unchanged. If the display interface size or the number of virtual elements changes, this code needs to be readjusted, resulting in low efficiency. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method, device, electronic device and storage medium for arranging virtual elements.
[0005] Based on the above objectives, the present application provides a method for arranging virtual elements, including:
[0006] Determining multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements;
[0007] For each centering arrangement, determine the number of rows and columns of the multiple virtual elements on the display interface based on the number of the multiple virtual elements, and determine a centering value for each centering arrangement based on the number of rows and the number of columns;
[0008] A target centering value with the smallest value is determined from all the centering values, and a centering arrangement corresponding to the target centering value is output in the display interface.
[0009] In some embodiments, determining multiple centering arrangements of multiple virtual elements in a display interface specifically includes:
[0010] Obtaining the vertical length and horizontal length of the display interface;
[0011] For each centering arrangement, the vertical position of each virtual element is determined based on the vertical length and the number of arrangement rows; and the horizontal position of each virtual element is determined based on the horizontal length and the number of arrangement columns.
[0012] In some embodiments, determining the vertical position of each virtual element based on the vertical length and the number of rows specifically includes:
[0013] Determining a vertical position of a first target virtual element that is closest to a border of the display interface based on the vertical length and the number of arrangement rows along a vertical direction;
[0014] The vertical positions of the other virtual elements except the first target row virtual element are determined based on the vertical position of the first target row virtual element.
[0015] In some embodiments, the vertical position of the first target virtual element is determined by the following formula:
[0016] Y=y1+0.5*h-0.5*C1*(n1-1);
[0017] Among them, y1 represents the vertical coordinate of the lower left corner of the display interface, Y represents the vertical coordinate of the first target virtual element, h represents the vertical length, n1 represents the number of arrangement rows, and C1 represents the preset row spacing.
[0018] In some embodiments, determining the horizontal position of each virtual element based on the horizontal length and the number of arrangement columns specifically includes:
[0019] Determining a horizontal position of a second target virtual element closest to a border of the display interface based on the horizontal length and the number of arrangement columns in a horizontal direction;
[0020] The horizontal positions of other virtual elements except the second target virtual element are determined based on the horizontal position of the second target virtual element.
[0021] In some embodiments, the horizontal position of the second target virtual element is determined by the following formula:
[0022] X=x1+0.5*w-0.5*C2*(n2-1);
[0023] Among them, x1 represents the horizontal coordinate of the lower left corner of the display interface, X represents the vertical coordinate of the second target virtual element, w represents the horizontal length, n2 represents the number of arrangement columns, and C2 represents the preset column spacing.
[0024] In some embodiments, determining the centering value of each centering arrangement based on the number of arrangement rows and the number of arrangement columns specifically includes:
[0025] Obtaining the vertical length and horizontal length of the display interface;
[0026] The centering value of each centering arrangement mode is determined based on the vertical length, the horizontal length, the number of arrangement rows, and the number of arrangement columns.
[0027] In some embodiments, the centering value is determined by the following formula:
[0028]
[0029] Wherein, S represents the center value, w represents the horizontal length of the display interface, h represents the vertical length of the display interface, n1 represents the number of arrangement rows, and n2 represents the number of arrangement columns.
[0030] In some embodiments, determining a target center value with the minimum value from all the center values specifically includes:
[0031] In response to determining that the horizontal length of the display interface is greater than the vertical length of the display interface, determining the multiple centering arrangements in ascending order of the number of rows of the multiple virtual elements on the display interface;
[0032] Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement;
[0033] In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
[0034] In some embodiments, determining a target center value with the minimum value from all the center values specifically includes:
[0035] In response to determining that the vertical length of the display interface is greater than the horizontal length of the display interface, determining the multiple centering arrangements in ascending order of the number of columns of the multiple virtual elements on the display interface;
[0036] Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement;
[0037] In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
[0038] In some embodiments, determining multiple centering arrangements of multiple virtual elements in a display interface specifically includes:
[0039] For any one of the centered arrangement modes, a first total length of the virtual elements in each column is determined based on the number of arrangement rows and the preset row spacing, and a second total length of the virtual elements in each row is determined based on the number of arrangement columns and the preset column spacing. In response to determining that the first total length is greater than the first preset distance or the second total length is greater than the second preset distance, any one of the centered arrangement modes is excluded.
[0040] Based on the same inventive concept, the exemplary embodiments of the present application further provide a device for arranging virtual elements, including:
[0041] A first determining module determines multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements;
[0042] a second determining module, for each centering arrangement, determining, based on the number of the multiple virtual elements, the number of rows and columns in which the multiple virtual elements are arranged on the display interface, and determining a centering value for each centering arrangement based on the number of rows and columns;
[0043] An output module determines a target centering value with the smallest value from all the centering values, and outputs a centering arrangement corresponding to the target centering value in the display interface.
[0044] Based on the same inventive concept, an exemplary embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable by the processor, wherein the processor implements the method of arranging virtual elements as described above when executing the program.
[0045] Based on the same inventive concept, an exemplary embodiment of the present application further provides a non-transitory computer-readable storage medium, which stores computer instructions for causing a computer to execute the method for arranging virtual elements as described above.
[0046] As can be seen from the above, the method, device, electronic device and storage medium for arranging virtual elements provided in the present application first determine a plurality of centering arrangement modes of multiple virtual elements in a display interface; wherein the plurality of centering arrangement modes are all array arrangement modes; for each centering arrangement mode, the number of arrangement rows and the number of arrangement columns of the multiple virtual elements in the display interface are determined based on the number of the multiple virtual elements, and the centering value of each centering arrangement mode is determined based on the number of arrangement rows and the number of arrangement columns; the target centering value with the smallest value is determined from all the centering values, and the centering arrangement mode corresponding to the target centering value is output in the display interface, so that after the number of virtual elements is determined, a centering arrangement mode can be automatically generated, thereby realizing the automation of the centering arrangement of virtual elements, and further improving the efficiency of the centering arrangement of virtual elements. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in this application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are merely embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0048] Figure 1 A flowchart of a method for arranging virtual elements according to an embodiment of the present application is shown;
[0049] Figure 2 This is a schematic diagram of a first method of centered arrangement of virtual elements in an embodiment of the present application;
[0050] Figure 3 This is a schematic diagram of a second virtual element centering arrangement method according to an embodiment of the present application;
[0051] Figure 4 This is a schematic diagram of a third virtual element centering arrangement method according to an embodiment of the present application;
[0052] Figure 5 This is a schematic diagram of a fourth virtual element centering arrangement method according to an embodiment of the present application;
[0053] Figure 6 This is a schematic diagram of a fifth virtual element centering arrangement method according to an embodiment of the present application;
[0054] Figure 7 A schematic structural diagram of a device for arranging virtual elements according to an embodiment of the present application;
[0055] Figure 8 This is a schematic structural diagram of a specific electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0056] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided solely to enable those skilled in the art to better understand and implement the present application, and are not intended to limit the scope of the present application in any way. Rather, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0057] According to the embodiments of the present application, a method, device, electronic device, and storage medium for arranging virtual elements are proposed.
[0058] It should be understood herein that any number of elements in the drawings is for illustration only and not for limitation, and any naming is only for distinction and does not have any limiting meaning.
[0059] The principles and spirit of the present application are explained in detail below with reference to several representative implementations of the present application. SUMMARY
[0061] In the prior art, the centering arrangement of virtual elements in most display interfaces is pre-set, that is, the position of each element is simply hard-coded when the code is written. This is only suitable when the number of virtual elements and the display interface do not change. When the size of the display interface or the number of virtual elements changes, this part of the code needs to be readjusted, resulting in a rigid and inefficient arrangement of virtual elements in the display interface. To achieve automatic centering of multiple virtual elements in the display interface, it is necessary not only to consider how to arrange all virtual elements in each row, but also how to allocate the number of rows and columns, so that the final centering arrangement is the one that best suits the user's aesthetic taste.
[0062] In order to solve the above problems, the present application provides a method for arranging virtual elements, which specifically includes:
[0063] Determine multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements; for each centering arrangement, determine the number of arrangement rows and the number of arrangement columns of the multiple virtual elements in the display interface based on the number of the multiple virtual elements, and determine the centering value of each centering arrangement based on the number of arrangement rows and the number of arrangement columns; determine a target centering value with the smallest value from all the centering values, and output the centering arrangement corresponding to the target centering value in the display interface, so that after determining the number of virtual elements, the best centering arrangement can be automatically determined, thereby realizing the automation of the centering arrangement of virtual elements, and further improving the efficiency of the centering arrangement of virtual elements.
[0064] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application are described in detail below.
[0065] Overview of application scenarios
[0066] In some specific application scenarios, the virtual element arrangement method of the present application can be applied to various gaming systems, for example, arranging multiple virtual elements in the center of a game interface. It can also be applied to various systems with display interfaces, such as the interface of a touch-screen mobile phone or the arrangement of icons on a display interface on a computer monitor. Optionally, the virtual elements can be icons, patterns, text, virtual models, and other elements that can be displayed on a display interface.
[0067] In some specific application scenarios, the virtual element arrangement method of the present application can be directly applied and run locally, or it can be run on a cloud server. When running on a cloud server, the acquired data to be processed is sent to the cloud server via the network. The server processes the data to be processed using the virtual element arrangement method of the present application and sends the processing results to the local computer via the network.
[0068] The following describes a method for arranging virtual elements according to an exemplary embodiment of the present application, with reference to specific application scenarios. It should be noted that the above application scenarios are merely provided to facilitate understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect. Rather, the embodiments of the present application can be applied to any applicable scenario.
[0069] Exemplary method
[0070] refer to Figure 1 , an embodiment of the present application provides a method for arranging virtual elements, comprising the following steps:
[0071] S101, determining multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements.
[0072] In specific implementation, for multiple virtual elements, there can be multiple centered arrangements in the same display interface. For example, if the number of virtual elements is 4, they can be arranged in a row in the center of the display interface. Figure 2 ; or can be arranged in 2 rows and 2 columns, refer to Figure 3 ; or you can arrange them in 1 column, refer to Figure 4 .in, Figures 2 to 4 The four circles in represent virtual elements, and the rectangular frame represents the current display interface.
[0073] It should be noted that in order to arrange the virtual elements neatly and beautifully in the display interface, and to facilitate finding a certain virtual element from multiple virtual elements, the virtual elements are generally arranged in an array in the display interface, and the array arrangement herein refers to arranging in a row-by-column manner, and the scheme of this embodiment is also based on array arrangement. Alternatively, the sizes of the multiple virtual elements in this embodiment are equal, or the areas occupied by the multiple virtual elements in the display interface are equal.
[0074] In some embodiments, determining multiple centering arrangement manners of the multiple virtual elements in the display interface specifically includes:
[0075] obtaining a vertical length and a horizontal length of the display interface;
[0076] For each centering arrangement manner, determining a vertical position of each virtual element based on the vertical length and the arrangement row number, and determining a horizontal position of the each virtual element based on the horizontal length and the arrangement column number.
[0077] In specific implementation, when determining the multiple centering arrangement manners of the multiple virtual elements in the display interface, the vertical length and the horizontal length of the display interface are first obtained, then the vertical position of each virtual element in each centering arrangement manner is determined according to the arrangement row number of each centering arrangement manner, and the horizontal position of each virtual element in each centering arrangement manner is determined according to the arrangement column number of each centering arrangement manner. It should be noted that the order of distinguishing the horizontal position and the vertical position of each virtual element is not limited herein, and the horizontal position and the vertical position of each virtual element can be determined in any order in specific implementation. For each centering arrangement manner, the arrangement row number or the arrangement column number thereof can be first determined randomly, and then the remaining arrangement row number or arrangement column number is determined according to the first determined arrangement row number or arrangement column number and the number of virtual elements. For example, the arrangement column number of a certain centering arrangement manner is determined as 10 / 2=5 when the arrangement row number of the centering arrangement manner is determined as 2 and the number of virtual elements is 10. Alternatively, when the remaining arrangement row number or arrangement column number determined by a certain arrangement manner is not an integer, the remaining arrangement row number or arrangement column number is determined after being rounded up, for example, the arrangement column number of a certain centering arrangement manner is determined as 3 when the arrangement column number of the centering arrangement manner is determined as 5 / 2=2.5.
[0078] In some embodiments, the vertical position of each virtual element is determined based on the vertical length and the arrangement row number, specifically including:
[0079] determining a vertical position of a first target virtual element closest to a boundary of the display interface in a vertical direction based on the vertical length and the arrangement row number;
[0080] The vertical positions of the other virtual elements except the first target row virtual element are determined based on the vertical position of the first target row virtual element.
[0081] During specific implementation, for each centering arrangement, when determining the vertical position of each virtual element, the vertical position of the first target virtual element that is closest to the border of the display interface can be first determined along the vertical direction, that is, any one of the two virtual elements at the edge of each column of virtual elements. Since the spacing between each virtual element is the same in each centering arrangement, after determining the vertical position of the first target virtual element, the vertical positions of other virtual elements can be determined in turn. Optionally, the vertical position represents the position of each virtual element in the vertical direction of the display interface. Optionally, the vertical position can be represented by the ordinate in the coordinate system, or by the distance from the border of the display interface, which is not limited here.
[0082] It should be noted that the above method of determining the vertical position of each virtual element is only a specific implementation method in this embodiment. Those skilled in the art may also choose other methods to determine the vertical position of each virtual element as needed. For example, the center point of the display interface may be determined first, and then the vertical position of the third target virtual element closest to the center point may be determined. Then, the vertical position of other virtual elements may be determined through the vertical position of the third target virtual element.
[0083] In some embodiments, the vertical position of the first target virtual element is determined by the following formula:
[0084] Y=y1+0.5*h-0.5*C1*(n1-1);
[0085] Among them, y1 represents the vertical coordinate of the lower left corner of the display interface, Y represents the vertical coordinate of the first target virtual element, h represents the vertical length, n1 represents the number of arrangement rows, and C1 represents the preset row spacing.
[0086] It should be noted that y1 represents the vertical coordinate of the lower left corner of the display interface. The vertical coordinate of the lower left corner can be determined based on the position of the origin of the coordinate system determined in the display interface. Optionally, for convenience of calculation, the vertical coordinate of the lower left corner can be used as the origin of the coordinate system. C represents the preset line spacing, and the specific value can be set as needed.
[0087] In some embodiments, determining the horizontal position of each virtual element based on the horizontal length and the number of arrangement columns specifically includes:
[0088] Determining a horizontal position of a second target virtual element closest to a border of the display interface based on the horizontal length and the number of arrangement columns in a horizontal direction;
[0089] The horizontal positions of other virtual elements except the second target virtual element are determined based on the horizontal position of the second target virtual element.
[0090] During specific implementation, for each centering arrangement, when determining the horizontal position of each virtual element, the horizontal position of the second target virtual element that is closest to the border of the display interface can be first determined in the horizontal direction, that is, any one of the two virtual elements at the edge of each row of virtual elements. Since the spacing between each virtual element is the same in each centering arrangement, after determining the vertical position of the second target virtual element, the horizontal positions of other virtual elements can be determined in turn. Optionally, the horizontal position represents the position of each virtual element in the horizontal direction of the display interface. Optionally, the vertical position can be represented by the horizontal coordinate in the coordinate system, or by the distance between each virtual element and the border of the display interface, which is not limited here.
[0091] It should be noted that the first target virtual element and the second target virtual element can be the same virtual element, that is, the virtual element located at the four corners in each centered arrangement. Of course, the first target virtual element and the second target virtual element can be two different virtual elements, which is not limited here.
[0092] In some embodiments, the horizontal position of the second target virtual element is determined by the following formula:
[0093] X=x1+0.5*w-0.5*C2*(n2-1);
[0094] Among them, x1 represents the horizontal coordinate of the lower left corner of the display interface, X represents the vertical coordinate of the second target virtual element, w represents the horizontal length, n2 represents the number of arrangement columns, and C2 represents the preset column spacing.
[0095] It should be noted that, for ease of calculation, the position of the lower left corner of the display interface can be set as the coordinate origin. C2 represents the preset column spacing, and the specific value can be set as needed. Optionally, the preset column spacing and the preset row spacing can be set to the same value or different values, which are not limited here.
[0096] S102: For each centering arrangement, determine the number of rows and columns of the multiple virtual elements on the display interface based on the number of the multiple virtual elements, and determine the centering value of each centering arrangement based on the number of rows and the number of columns.
[0097] During specific implementation, since multiple virtual elements can have multiple centered arrangements in the same display interface, it is necessary to select the best arrangement as the final output result. Taking the above reasons into consideration, the inventors have found through analysis that when the number of virtual elements is determined, no matter which centered arrangement is used, the total area occupied by all virtual elements in the display interface is fixed, that is, in all centered arrangements, the product of rows and columns is a fixed value. On this basis, when the total area of the array formed by all virtual elements is a fixed value, the smaller the difference between rows and columns, the smaller the perimeter of the array formed by all virtual elements. At the same time, since the virtual element arrangements of the present application are all centered arrangements, that is, all virtual elements are arranged around the center point of the display interface, and the smaller the perimeter of the array formed by all virtual elements, the smaller the sum of the distances of all virtual elements in the array to the center point of the display interface, that is, the more concentrated the centered arrangement corresponding to the array is towards the center point. Therefore, before selecting the most centered arrangement from a plurality of centered arrangements, this embodiment first determines the number of arrangement rows and the number of arrangement columns of the multiple virtual elements on the display interface, and determines the centering value of each centered arrangement based on the number of arrangement rows and the number of arrangement columns. Optionally, the centering value can be represented by the absolute value of the difference between the number of arrangement rows and the number of arrangement columns.
[0098] In some embodiments, determining the centering value of each centering arrangement based on the number of arrangement rows and the number of arrangement columns specifically includes:
[0099] Obtaining the vertical length and horizontal length of the display interface;
[0100] The centering value of each centering arrangement mode is determined based on the vertical length, the horizontal length, the number of arrangement rows, and the number of arrangement columns.
[0101] During specific implementation, since the values of the number of arrangement rows and the number of arrangement columns are the same, the centering value is 0. That is, the centering value is the smallest at this time. Therefore, if the centering value is determined only by the difference between the number of arrangement rows and the number of arrangement columns, it is likely that the virtual elements are arranged into a square. However, considering that the display interface in reality is generally rectangular, and the horizontal length and the vertical length have a certain ratio, if all the arrangement results are squares, it does not fully meet the user's aesthetic taste, and not all numbers of virtual elements can be arranged into an m*m array, where m is a positive integer. For example, when the number of virtual elements is 6, it is impossible to arrange the virtual elements into a square array in the center, and if the 2*3 and 3*2 arrangement methods only use the absolute value of the difference between the number of arrangement rows and the number of arrangement columns to determine the centering value at this time, then the output result will not be unique. Therefore, in addition to the number of rows and columns, the vertical and horizontal lengths of the display interface are also needed to further determine the center value at this time. That is, the determined center value must not only consider the difference between the number of rows and columns, but also take into account the aspect ratio of the current display interface. Figure 5 , since the horizontal length of the display interface is greater than the vertical length, it is arranged in a 2*3 pattern. Figure 6 Since the horizontal length of the display interface is smaller than the vertical length, it is arranged in a 3*2 pattern.
[0102] In order to accurately obtain the centering value, in some embodiments, the centering value is determined by the following formula:
[0103]
[0104] Wherein, S represents the center value, w represents the horizontal length of the display interface, h represents the vertical length of the display interface, n1 represents the number of arrangement rows, and n2 represents the number of arrangement columns.
[0105] In some embodiments, the center value may also be determined by the following formula:
[0106]
[0107] Wherein, S represents the center value, w represents the horizontal length of the display interface, h represents the vertical length of the display interface, n1 represents the number of arrangement rows, and n2 represents the number of arrangement columns.
[0108] It should be noted that, in addition to the above two formulas for determining the centering value, those skilled in the art may also determine the centering value through other formulas, which are not limited here.
[0109] S103, determining a target centering value with the smallest value from all the centering values, and outputting a centering arrangement corresponding to the target centering value in the display interface.
[0110] In specific implementation, after determining multiple centering values corresponding to multiple centering arrangements, a target centering value with the smallest value is determined from all the centering values, and the centering arrangement corresponding to the target centering value is output in the display interface.
[0111] In order to improve the efficiency of determining the target center value with the minimum value, in some embodiments, determining the target center value with the minimum value from all the center values specifically includes:
[0112] In response to determining that the horizontal length of the display interface is greater than the vertical length of the display interface, determining the multiple centering arrangements in ascending order of the number of rows of the multiple virtual elements on the display interface;
[0113] Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement;
[0114] In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
[0115] In order to improve the efficiency of determining the target center value with the minimum value, in some embodiments, determining the target center value with the minimum value from all the center values specifically includes:
[0116] In response to determining that the vertical length of the display interface is greater than the horizontal length of the display interface, determining the multiple centering arrangements in ascending order of the number of columns of the multiple virtual elements on the display interface;
[0117] Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement;
[0118] In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
[0119] During specific implementation, after the number of virtual elements is determined, there can still be multiple centering arrangements. In order to select the target centering value with the smallest numerical value, the centering value corresponding to each centering arrangement method is calculated, which is inefficient. In order to improve efficiency, when determining the target centering value, the relationship between the vertical length of the display interface and the horizontal length of the display interface can be determined first. Since when the horizontal length is greater than the vertical length, the arrangement method finally selected is generally that the number of arrangement columns is greater than the number of arrangement rows. At this time, the multiple centering arrangements are determined in order from small to large according to the number of arrangement rows of the multiple virtual elements on the display interface; when it is determined that the centering value corresponding to the current centering arrangement method is greater than the centering value corresponding to the previous centering arrangement method, it means that the centering value corresponding to the previous centering arrangement method is the target centering value with the smallest numerical value. When the horizontal length is smaller than the vertical length, the arrangement method finally selected is generally that the number of arrangement columns is smaller than the number of arrangement rows. The multiple centering arrangement methods are determined in sequence from small to large according to the arrangement number of the multiple virtual elements in the display interface. When it is determined that the centering value corresponding to the current centering arrangement method is greater than the centering value corresponding to the previous centering arrangement method, it means that the centering value corresponding to the previous centering arrangement method is the target centering value with the smallest value, thereby improving the judgment efficiency by at least half.
[0120] In order to prevent the arranged virtual elements from exceeding the display interface or being blocked by the display interface, in some embodiments, multiple centering arrangements of the multiple virtual elements in the display interface are determined, specifically including:
[0121] For any one of the centered arrangement modes, a first total length of the virtual elements in each column is determined based on the number of arrangement rows and the preset row spacing, and a second total length of the virtual elements in each row is determined based on the number of arrangement columns and the preset column spacing. In response to determining that the first total length is greater than the first preset distance or the second total length is greater than the second preset distance, any one of the centered arrangement modes is excluded.
[0122] It should be noted that the first preset distance can be determined by the vertical length of the display interface. Optionally, the first preset distance can be equal to or less than the vertical length of the display interface. The second preset distance can be determined by the horizontal length of the display interface. Optionally, the first preset distance can be equal to or less than the horizontal length of the display interface, thereby ensuring that virtual elements at the extreme edges can be fully displayed.
[0123] The method for arranging virtual elements provided in the present application determines multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements; for each centering arrangement, the number of arrangement rows and the number of arrangement columns of the multiple virtual elements in the display interface are determined based on the number of the multiple virtual elements, and the centering value of each centering arrangement is determined based on the number of arrangement rows and the number of arrangement columns; a target centering value with the smallest value is determined from all the centering values, and a centering arrangement corresponding to the target centering value is output in the display interface, so that after the number of virtual elements is determined, a centering arrangement that conforms to the public aesthetic can be automatically determined, thereby realizing the automation of the centering arrangement of virtual elements and further improving the efficiency of the centering arrangement of virtual elements.
[0124] Exemplary device
[0125] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a device for arranging virtual elements.
[0126] refer to Figure 7 , the device for arranging virtual elements comprises:
[0127] A first determining module 201 determines multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements;
[0128] A second determining module 202 determines, for each centering arrangement, the number of rows and columns of the virtual elements on the display interface based on the number of the virtual elements, and determines a centering value for each centering arrangement based on the number of rows and columns.
[0129] The output module 203 determines a target centering value with the smallest value from all the centering values, and outputs a centering arrangement corresponding to the target centering value in the display interface.
[0130] For the convenience of description, the above devices are described as being divided into various modules according to their functions. Of course, when implementing this application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0131] The apparatus of the above embodiment is used to implement the corresponding virtual element arrangement method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0132] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the method for arranging virtual elements described in any of the above embodiments is implemented.
[0133] Figure 8 10 is a schematic diagram showing a more specific hardware structure of an electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other within the device via the bus 1050.
[0134] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0135] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0136] The input / output interface 1030 is used to connect input / output modules to implement information input and output. The input / output modules can be configured as components within the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.
[0137] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).
[0138] The bus 1050 comprises a pathway for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0139] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.
[0140] The electronic device of the above embodiment is used to implement the corresponding virtual element arrangement method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0141] Exemplary program product
[0142] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the method of virtual element arrangement as described in any of the above embodiments.
[0143] The computer-readable media of this embodiment include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0144] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the method of arranging virtual elements as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0145] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. Within the scope of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0146] In addition, for simplicity of description and discussion, and in order not to make the embodiment of the application difficult to understand, the known power supply / ground connection with integrated circuit (IC) chip and other components may or may not be shown in the accompanying drawings provided. In addition, the device can be shown in the form of a block diagram to avoid making the embodiment of the application difficult to understand, and this also takes into account the following fact, that is, the details of the embodiment of these block diagram devices are highly dependent on the platform to be implemented in the embodiment of the application (that is, these details should be fully within the scope of understanding of those skilled in the art). When specific details (for example, circuit) are set forth to describe exemplary embodiments of the application, it will be apparent to those skilled in the art that the embodiment of the application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0147] Although the present invention has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may utilize the embodiments discussed.
[0148] The embodiments of the present application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of this application.
Claims
1. A method for arranging virtual elements, characterized in that: include: Determining multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements; For each centering arrangement, determine the number of rows and columns of the multiple virtual elements on the display interface based on the number of the multiple virtual elements, and determine a centering value for each centering arrangement based on the number of rows and the number of columns; Determine a target centering value with the smallest value from all the centering values, and output a centering arrangement corresponding to the target centering value on the display interface; Determining the center value of each centering arrangement mode based on the number of arrangement rows and the number of arrangement columns specifically includes: Obtaining the vertical length and horizontal length of the display interface; Determine the centering value of each centering arrangement based on the vertical length, the horizontal length, the number of arrangement rows, and the number of arrangement columns: Wherein, S represents the center value, w represents the horizontal length of the display interface, h represents the vertical length of the display interface, n1 represents the number of arrangement rows, and n2 represents the number of arrangement columns.
2. The method according to claim 1, characterized in that Determine multiple ways to center multiple virtual elements in the display interface, including: Obtaining the vertical length and horizontal length of the display interface; For each centering arrangement, the vertical position of each virtual element is determined based on the vertical length and the number of arrangement rows; and the horizontal position of each virtual element is determined based on the horizontal length and the number of arrangement columns.
3. The method according to claim 2, characterized in that Determining the vertical position of each virtual element based on the vertical length and the number of arrangement rows specifically includes: Determining a vertical position of a first target virtual element that is closest to a border of the display interface based on the vertical length and the number of arrangement rows along a vertical direction; The vertical positions of the other virtual elements except the first target row virtual element are determined based on the vertical position of the first target row virtual element.
4. The method according to claim 3, characterized in that The vertical position of the first target virtual element is determined by the following formula: Y=y1+0.5*h-0.5*C1*(n1-1); Among them, y1 represents the vertical coordinate of the lower left corner of the display interface, Y represents the vertical coordinate of the first target virtual element, h represents the vertical length, n1 represents the number of arrangement rows, and C1 represents the preset row spacing.
5. The method according to claim 2, characterized in that Determining the horizontal position of each virtual element based on the horizontal length and the number of arrangement columns specifically includes: Determining a horizontal position of a second target virtual element closest to a border of the display interface based on the horizontal length and the number of arrangement columns in a horizontal direction; The horizontal positions of other virtual elements except the second target virtual element are determined based on the horizontal position of the second target virtual element.
6. The method according to claim 5, characterized in that The horizontal position of the second target virtual element is determined by the following formula: X=x1+0.5*w-0.5*C2*(n2-1); Among them, x1 represents the horizontal coordinate of the lower left corner of the display interface, X represents the vertical coordinate of the second target virtual element, w represents the horizontal length, n2 represents the number of arrangement columns, and C2 represents the preset column spacing.
7. The method according to claim 1, characterized in that Determining the target center value with the minimum value from all the center values specifically includes: In response to determining that the horizontal length of the display interface is greater than the vertical length of the display interface, determining the multiple centering arrangements in ascending order of the number of rows of the multiple virtual elements on the display interface; Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement; In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
8. The method according to claim 1, characterized in that Determining the target center value with the minimum value from all the center values specifically includes: In response to determining that the vertical length of the display interface is greater than the horizontal length of the display interface, determining the multiple centering arrangements in ascending order of the number of columns of the multiple virtual elements on the display interface; Determine whether the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement; In response to determining that the centering value corresponding to the current centering arrangement is greater than the centering value corresponding to the previous centering arrangement, the centering value corresponding to the previous centering arrangement is determined to be the target centering value.
9. The method according to claim 1, characterized in that Determine multiple ways to center multiple virtual elements in the display interface, including: For any one of the centered arrangement modes, a first total length of the virtual elements in each column is determined based on the number of arrangement rows and the preset row spacing, and a second total length of the virtual elements in each row is determined based on the number of arrangement columns and the preset column spacing. In response to determining that the first total length is greater than the first preset distance or the second total length is greater than the second preset distance, any one of the centered arrangement modes is excluded.
10. A device for arranging virtual elements, characterized in that: include: A first determining module determines multiple centering arrangements of multiple virtual elements in a display interface; wherein the multiple centering arrangements are all array arrangements; a second determining module, for each centering arrangement, determining, based on the number of the multiple virtual elements, the number of rows and columns in which the multiple virtual elements are arranged on the display interface, and determining a centering value for each centering arrangement based on the number of rows and columns; an output module, which determines a target centering value with the smallest value from all the centering values, and outputs a centering arrangement corresponding to the target centering value on the display interface; Determining the center value of each centering arrangement mode based on the number of arrangement rows and the number of arrangement columns specifically includes: Obtaining the vertical length and horizontal length of the display interface; Determine the centering value of each centering arrangement based on the vertical length, the horizontal length, the number of arrangement rows, and the number of arrangement columns: Wherein, S represents the center value, w represents the horizontal length of the display interface, h represents the vertical length of the display interface, n1 represents the number of arrangement rows, and n2 represents the number of arrangement columns.
11. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor implements the method according to any one of claims 1 to 9 when executing the program.
12. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores computer instructions for causing a computer to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Icon arrangement method and system as well as display terminal
CN105955583A
Dynamic layout method and device for interface
CN110597510A