Element position adaptation method and system
By obtaining and calculating the size and position information of the canvas and elements, and automatically adapting the element position, the problem of inconsistent visual effects after the canvas scale changes is solved, and the visual effect consistency of elements is achieved.
Patent Information
- Application Number
- CN202210359440.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-06
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-04-06
AI Technical Summary
The existing canvas scale change ability lacks consistency in the visual effect adaptation of elemental visual effects, resulting in inconsistent elemental visual effects after the canvas scale changes.
By obtaining the size information of the original canvas and the changed canvas and the minimum enclosure box information of the elements, calculating the scaling ratio and relative position information, and automatically adapting the position of the elements in the changed canvas to ensure consistent visual effects.
Automatic adaptation of elements after the canvas scale changes, making the visual effects consistent and improving the user experience.
Smart Images

Figure CN114663286B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an element position adaptation method, a computer-readable storage medium, a computer device, and an element position adaptation system. Background Art
[0002] To improve user convenience when using canvases, many vendors have implemented canvas scaling capabilities. However, existing canvas scaling capabilities are limited to switching the canvas's scale, lacking consistency in visual adaptation across elements on the canvas. This results in inconsistent visual effects after the canvas scale is changed. Summary of the Invention
[0003] The present invention aims to at least partially address one of the technical problems in the aforementioned techniques. To this end, one object of the present invention is to provide an element position adaptation method that automatically adapts elements on a canvas after the canvas scale changes, so that the visual effects of the elements remain consistent after the canvas scale changes.
[0004] A second object of the present invention is to provide a computer-readable storage medium.
[0005] A third object of the present invention is to provide a computer device.
[0006] A fourth objective of the present invention is to provide an element position adaptation system.
[0007] To achieve the above-mentioned purpose, an embodiment of the first aspect of the present invention proposes an element position adaptation method, including the following steps: obtaining first size information of the original first canvas, second size information of the second canvas after the proportion is changed, and minimum bounding box information of the first element in the first canvas; determining the scaling ratio according to the first size information and the second size information, and determining the size of the second element in the second canvas according to the scaling ratio; calculating the relative position information between the first element and the first canvas according to the minimum bounding box information of the first element, and calculating the final position information of the second element in the second canvas according to the relative position information, so as to complete the position adaptation of the second element after the canvas proportion changes.
[0008] According to the element position adaptation method of an embodiment of the present invention, first, the first size information of the original first canvas, the second size information of the second canvas after the scale change, and the minimum bounding box information of the first element in the first canvas are obtained; then, the scaling ratio is determined according to the first size information and the second size information, and the size of the second element in the second canvas is determined according to the scaling ratio; then, the relative position information between the first element and the first canvas is calculated according to the minimum bounding box information of the first element, and the final position information of the second element in the second canvas is calculated according to the relative position information, so as to complete the position adaptation of the second element after the canvas scale changes; thereby, the elements in the canvas are automatically adapted after the canvas scale changes, so that the visual effects of the elements are consistent after the canvas scale changes.
[0009] In addition, the element position adaptation method proposed in the above embodiment of the present invention may also have the following additional technical features:
[0010] Optionally, the size of the second element includes a width value of the second element and a height value of the second element, and the width value of the second element and the height value of the second element are calculated according to the following formula:
[0011] aAspect=aw1 / ah1
[0012] cSizeRadio=cw2 / cw1
[0013] aw2=aw1*cSizeRadio
[0014] ah2=aw2 / aAspect
[0015] Where aAspect represents the minimum aspect ratio of the bounding box of the first element, aw1 represents the minimum width of the bounding box of the first element, ah1 represents the minimum height of the bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length of the short side of the first canvas, cw2 represents the length of the side of the second canvas corresponding to the short side of the first canvas, aw2 represents the minimum width of the bounding box of the second element, and ah2 represents the minimum height of the bounding box of the second element.
[0016] Optionally, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element, where the X-axis direction is the short side direction of the first canvas.
[0017] Optionally, the relative position information includes the X-axis ratio and the Y-axis ratio of the first element, where the X-axis ratio and the Y-axis ratio of the first element are calculated according to the following formulas:
[0018] cxRatio = ax1 / (cw1 - aw1)
[0019] cyRatio = ay1 / (ch1 - ah1)
[0020] Where, cxRatio represents the X-axis ratio of the first element, ax1 represents the X-axis value of the upper left corner point of the minimum bounding box of the first element, cw1 represents the length value of the shorter side of the first canvas, aw1 represents the width value of the minimum bounding box of the first element, cyRatio represents the Y-axis ratio of the first element, ay1 represents the Y-axis value of the upper left corner point of the minimum bounding box of the first element, ch1 represents the length value of the longer side of the first canvas, and ah1 represents the height value of the minimum bounding box of the first element.
[0021] Optionally, the final position information of the second element includes the X-axis value of the upper left corner point of the minimum bounding box of the second element and the Y-axis value of the upper left corner point of the minimum bounding box of the second element;
[0022] Where, calculating the final position information of the second element in the second canvas according to the relative position information includes:
[0023] If 0 < cxRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element as ax2 = cxRatio * (cw2 - aw2), where ax2 represents the X-axis value of the upper left corner point of the minimum bounding box of the second element, cw2 represents the length value of the corresponding side of the second canvas to the shorter side of the first canvas, and aw2 represents the width value of the minimum bounding box of the second element;
[0024] If 1 < cxRatio, indicating that the X-axis of the first element extends beyond the first canvas, then calculate the X-axis overrun ratio axOffsetRadio = (ax1 + aw1 - cw1) / aw1, and calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element according to the X-axis overrun ratio as ax2 = cw2 - (aw2 * (1 - axOffsetRadio));
[0025] If 0 < cyRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the Y-axis value ay2 of the upper left corner point of the minimum bounding box of the second element as ay2 = cyRatio * (ch2 - ah2), where ay2 represents the Y-axis value of the upper left corner point of the minimum bounding box of the second element, ch2 represents the length value of the corresponding side of the second canvas to the longer side of the first canvas, and ah2 represents the length value of the minimum bounding box of the second element;
[0026] If 1 < cyRatio, indicating that the Y-axis of the first element extends beyond the first canvas, then calculate the Y-axis extension ratio ayOffsetRadio of the first element as ayOffsetRadio = (ay1 + ah1 - ch1) / ah1, and calculate the Y-axis value ay2 of the upper left corner point of the minimum bounding box of the second element according to the Y-axis extension ratio as ay2 = ch2 - (ah2 * (1 - ayOffsetRadio)).
[0027] To achieve the above object, an embodiment of the second aspect of the present invention proposes a computer-readable storage medium on which an element position adaptation program is stored. When the element position adaptation program is executed by a processor, the element position adaptation method as described above is implemented.
[0028] According to the computer-readable storage medium of the embodiment of the present invention, by storing the element position adaptation program, when the processor executes the element position adaptation program, the element position adaptation method as described above is implemented, so as to automatically adapt the elements in the canvas after the canvas ratio changes, and make the visual effects of the elements consistent after the canvas ratio changes.
[0029] To achieve the above object, an embodiment of the third aspect of the present invention proposes a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the element position adaptation method as described above is implemented.
[0030] According to the computer device of the embodiment of the present invention, the element position adaptation program is stored by the memory, so that when the processor executes the element position adaptation program, the element position adaptation method as described above is implemented, so as to automatically adapt the elements in the canvas after the canvas ratio changes, and make the visual effects of the elements consistent after the canvas ratio changes.
[0031] To achieve the above object, an embodiment of the fourth aspect of the present invention proposes an element position adaptation system, including: an acquisition module, the acquisition module is used to acquire the first size information of the original first canvas, the second size information of the second canvas after the ratio change, and the minimum bounding box information of the first element in the first canvas; a ratio determination module, the ratio determination module is used to determine the scaling ratio according to the first size information and the second size information, and determine the size of the second element in the second canvas according to the scaling ratio; a position adaptation module, the position adaptation module is used to calculate the relative position information between the first element and the first canvas according to the minimum bounding box information of the first element, and calculate the final position information of the second element in the second canvas according to the relative position information, so as to complete the position adaptation of the second element after the canvas ratio changes.
[0032] According to an embodiment of the present invention, an element position adaptation system is configured to: provide an acquisition module for acquiring first size information of the original first canvas, second size information of the second canvas after the proportion changes, and minimum bounding box information of the first element in the first canvas; a proportion determination module for determining a scaling ratio based on the first size information and the second size information, and determining the size of the second element in the second canvas based on the scaling ratio; a position adaptation module for calculating relative position information between the first element and the first canvas based on the minimum bounding box information of the first element, and calculating final position information of the second element in the second canvas based on the relative position information, so as to complete position adaptation of the second element after the canvas proportion changes; thereby achieving automatic adaptation of elements in the canvas after the canvas proportion changes, so that the visual effects of the elements are consistent after the canvas proportion changes.
[0033] In addition, the element position adaptation system proposed in the above embodiment of the present invention may also have the following additional technical features:
[0034] Optionally, the size of the second element includes a width value of the second element and a height value of the second element, and the width value of the second element and the height value of the second element are calculated according to the following formula:
[0035] aAspect=aw1 / ah1
[0036] cSizeRadio=cw2 / cw1
[0037] aw2=aw1*cSizeRadio
[0038] ah2=aw2 / aAspect
[0039] Where aAspect represents the minimum aspect ratio of the bounding box of the first element, aw1 represents the minimum width of the bounding box of the first element, ah1 represents the minimum height of the bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length of the short side of the first canvas, cw2 represents the length of the side of the second canvas corresponding to the short side of the first canvas, aw2 represents the minimum width of the bounding box of the second element, and ah2 represents the minimum height of the bounding box of the second element.
[0040] Optionally, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element, where the X-axis direction is the short side direction of the first canvas. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 12. A schematic diagram of a flow chart of an element position adaptation method according to an embodiment of the present invention;
[0042] Figure 2 FIG. 4 is a block diagram of an element position adaptation system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following describes embodiments of the present invention in detail, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and are not to be construed as limiting the present invention.
[0044] In the related art, after the scale of the canvas is switched, the visual effect adaptation of the elements on the canvas lacks consistency, and the visual effects of the elements are inconsistent. According to the element position adaptation method of an embodiment of the present invention, first, the first size information of the original first canvas, the second size information of the second canvas after the scale change, and the minimum bounding box information of the first element in the first canvas are obtained; then, the scaling ratio is determined according to the first size information and the second size information, and the size of the second element in the second canvas is determined according to the scaling ratio; then, the relative position information between the first element and the first canvas is calculated according to the minimum bounding box information of the first element, and the final position information of the second element in the second canvas is calculated according to the relative position information to complete the position adaptation of the second element after the canvas scale changes; thereby, the elements in the canvas are automatically adapted after the canvas scale changes, so that the visual effects of the elements are consistent after the canvas scale changes.
[0045] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. Instead, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0046] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0047] Figure 1 FIG. 1 is a flow chart of an element position adaptation method according to an embodiment of the present invention. Figure 1 As shown, the element position adaptation method includes the following steps:
[0048] S101 , obtaining first size information of an original first canvas, second size information of a second canvas after a scale change, and minimum bounding box information of a first element in the first canvas.
[0049] That is, the first size information of the original first canvas is obtained (specifically, the first canvas is a rectangular area, and the first size information may include the width and length of the first canvas. The coordinate origin of the first canvas is located at the upper left corner, and the origin coordinates are (0, 0)); the second size information of the second canvas after the scale is changed (specifically, the second canvas is a rectangular area, and the second size information may include the width and length of the second canvas. There are multiple ways to determine the second canvas; for example, by obtaining the user's drag information on the first canvas to obtain the second canvas; or, obtaining the size information of the second canvas input by the user to determine the second canvas; or, by obtaining the user's click information on a preset template to determine the second canvas); and the minimum bounding box information of the first element in the first canvas; it can be understood that the minimum bounding box of the first element is the minimum rectangular box that can accommodate the first element; and the first element can be text, picture and other information.
[0050] The minimum bounding box information of the first element may include multiple types.
[0051] As an example, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element, where the X-axis direction is the short side direction of the first canvas; that is, the short side direction of the first canvas is defined as the X-axis direction.
[0052] S102: Determine a scaling ratio according to the first size information and the second size information, and determine a size of a second element in the second canvas according to the scaling ratio.
[0053] There are multiple ways to determine the size of the second element in the second canvas according to the scaling ratio.
[0054] In some embodiments, the size of the second element includes a width value of the second element and a height value of the second element, and the width value of the second element and the height value of the second element are calculated according to the following formula:
[0055] aAspect=aw1 / ah1
[0056] cSizeRadio=cw2 / cw1
[0057] aw2=aw1*cSizeRadio
[0058] ah2=aw2 / aAspect
[0059] Where aAspect represents the minimum aspect ratio of the bounding box of the first element, aw1 represents the minimum width of the bounding box of the first element, ah1 represents the minimum height of the bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length of the short side of the first canvas, cw2 represents the length of the side of the second canvas corresponding to the short side of the first canvas, aw2 represents the minimum width of the bounding box of the second element, and ah2 represents the minimum height of the bounding box of the second element.
[0060] S103 , calculating relative position information between the first element and the first canvas based on the minimum bounding box information of the first element, and calculating final position information of the second element in the second canvas based on the relative position information, so as to complete position adaptation of the second element after the canvas scale changes.
[0061] That is, the relative position information between the first element and the first canvas is calculated based on the minimum bounding box information of the first element (for example, the first canvas is gridded to determine the relative position between the first element and the first canvas through the grid information of the first element); then, the final position of the second element in the second canvas is determined based on the relative position information; so that the position of the second element is adaptively configured according to the canvas ratio.
[0062] In some embodiments, the relative position information includes the first element's X-axis ratio and the first element's Y-axis ratio, wherein the first element's X-axis ratio and the first element's Y-axis ratio are calculated according to the following formula:
[0063] cxRatio=ax1 / (cw1-aw1)
[0064] cyRatio=ay1 / (ch1-ah1)
[0065] Where cxRatio represents the X-axis ratio of the first element, ax1 represents the X-axis value of the upper-left corner of the minimum bounding box of the first element, cw1 represents the length of the short side of the first canvas, aw1 represents the width of the minimum bounding box of the first element, cyRatio represents the Y-axis ratio of the first element, ay1 represents the Y-axis value of the upper-left corner of the minimum bounding box of the first element, ch1 represents the length of the long side of the first canvas, and ah1 represents the height of the minimum bounding box of the first element.
[0066] In some embodiments, the final position information of the second element includes an X-axis value of an upper left corner point of a minimum bounding box of the second element and a Y-axis value of an upper left corner point of the minimum bounding box of the second element;
[0067] Calculating the final position information of the second element in the second canvas according to the relative position information includes:
[0068] If 0 < cxRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the X-axis value ax2 of the upper-left corner point of the minimum bounding box of the second element as ax2 = cxRatio * (cw2 - aw2), where ax2 represents the X-axis value of the upper-left corner point of the minimum bounding box of the second element, cw2 represents the length value of the side corresponding to the shorter side of the first canvas in the second canvas, and aw2 represents the width value of the minimum bounding box of the second element;
[0069] If 1 < cxRatio, indicating that the X-axis of the first element extends beyond the first canvas, then calculate the X-axis extension ratio axOffsetRadio = (ax1 + aw1 - cw1) / aw1, and calculate the X-axis value ax2 of the upper-left corner point of the minimum bounding box of the second element according to the X-axis extension ratio as ax2 = cw2 - (aw2 * (1 - axOffsetRadio));
[0070] If 0 < cyRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the Y-axis value ay2 of the upper-left corner point of the minimum bounding box of the second element as ay2 = cyRatio * (ch2 - ah2), where ay2 represents the Y-axis value of the upper-left corner point of the minimum bounding box of the second element, ch2 represents the length value of the side corresponding to the longer side of the first canvas in the second canvas, and ah2 represents the length value of the minimum bounding box of the second element;
[0071] If 1 < cyRatio, indicating that the Y-axis of the first element extends beyond the first canvas, then calculate the Y-axis extension ratio ayOffsetRadio = (ay1 + ah1 - ch1) / ah1, and calculate the Y-axis value ay2 of the upper-left corner point of the minimum bounding box of the second element according to the Y-axis extension ratio as ay2 = ch2 - (ah2 * (1 - ayOffsetRadio)).
[0072] In summary, according to the element position adaptation method of the embodiment of the present invention, first, obtain the first size information of the original first canvas, the second size information of the second canvas after the proportional change, and the minimum bounding box information of the first element in the first canvas; then, determine the scaling ratio according to the first size information and the second size information, and determine the size of the second element in the second canvas according to the scaling ratio; then, calculate the relative position information between the first element and the first canvas according to the minimum bounding box information of the first element, and calculate the final position information of the second element in the second canvas according to the relative position information to complete the position adaptation of the second element after the canvas proportional change; thereby realizing the automatic adaptation of the elements in the canvas after the canvas proportional change, so that the visual effects of the elements are consistent after the canvas proportional change.
[0073] To implement the above embodiment, the present invention provides a computer-readable storage medium on which an element position adaptation program is stored. When the element position adaptation program is executed by a processor, the above element position adaptation method is implemented.
[0074] According to the computer-readable storage medium of an embodiment of the present invention, by storing an element position adaptation program, the processor implements the element position adaptation method as described above when executing the element position adaptation program, thereby automatically adapting the elements in the canvas after the canvas ratio changes, so that the visual effects of the elements are consistent after the canvas ratio changes.
[0075] To implement the above embodiment, an embodiment of the present invention proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned element position adaptation method is implemented.
[0076] According to the computer device of an embodiment of the present invention, the element position adaptation program is stored in the memory, so that when the processor executes the element position adaptation program, the element position adaptation method as described above is implemented, thereby automatically adapting the elements in the canvas after the canvas ratio changes, so that the visual effects of the elements are consistent after the canvas ratio changes.
[0077] In order to implement the above embodiment, the embodiment of the present invention proposes an element position adaptation system, such as Figure 2 As shown, the element position adaptation system includes: an acquisition module 10 , a ratio determination module 20 and a position adaptation module 30 .
[0078] The acquisition module 10 is configured to acquire first size information of the original first canvas, second size information of the second canvas after the proportion is changed, and minimum bounding box information of the first element in the first canvas;
[0079] The ratio determination module 20 is configured to determine a scaling ratio based on the first size information and the second size information, and determine a size of the second element in the second canvas based on the scaling ratio;
[0080] The position adaptation module 30 is used to calculate the relative position information between the first element and the first canvas based on the minimum bounding box information of the first element, and calculate the final position information of the second element in the second canvas based on the relative position information to complete the position adaptation of the second element after the canvas scale changes.
[0081] In some embodiments, the size of the second element includes a width value of the second element and a height value of the second element, and the width value of the second element and the height value of the second element are calculated according to the following formula:
[0082] aAspect=aw1 / ah1
[0083] cSizeRadio=cw2 / cw1
[0084] aw2=aw1*cSizeRadio
[0085] ah2=aw2 / aAspect
[0086] Where aAspect represents the minimum aspect ratio of the bounding box of the first element, aw1 represents the minimum width of the bounding box of the first element, ah1 represents the minimum height of the bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length of the short side of the first canvas, cw2 represents the length of the side of the second canvas corresponding to the short side of the first canvas, aw2 represents the minimum width of the bounding box of the second element, and ah2 represents the minimum height of the bounding box of the second element.
[0087] In some embodiments, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element, where the X-axis direction is the short side direction of the first canvas.
[0088] It should be noted that the above Figure 1 The description of the element position adaptation method in
[15] is also applicable to the element position adaptation system and will not be repeated here.
[0089] In summary, according to an embodiment of the present invention, an element position adaptation system is configured to obtain the first size information of the original first canvas, the second size information of the second canvas after the proportion changes, and the minimum bounding box information of the first element in the first canvas; a proportion determination module is configured to determine the scaling ratio based on the first size information and the second size information, and to determine the size of the second element in the second canvas based on the scaling ratio; a position adaptation module is configured to calculate the relative position information between the first element and the first canvas based on the minimum bounding box information of the first element, and to calculate the final position information of the second element in the second canvas based on the relative position information, so as to complete the position adaptation of the second element after the canvas proportion changes; thereby achieving automatic adaptation of the elements in the canvas after the canvas proportion changes, so that the visual effects of the elements are consistent after the canvas proportion changes.
[0090] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0091] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0094] It should be noted that in the claims, any reference signs placed between parentheses shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third etc. does not indicate any order. These words may be interpreted as names.
[0095] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0096] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
[0097] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, "plurality" means two or more, unless otherwise specifically defined.
[0098] In the present invention, unless otherwise expressly specified or limited, the terms "mounted," "connected," "connect," "fixed," etc. should be understood broadly. For example, they may refer to fixed connection, detachable connection, or integration; mechanical connection or electrical connection; direct connection or indirect connection through an intermediate medium; internal communication between two components or interaction between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.
[0099] In the present invention, unless otherwise expressly specified or limited, when a first feature is "above" or "below" a second feature, it may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediary. Furthermore, when a first feature is "above," "above," or "above" a second feature, it may mean that the first feature is directly above or diagonally above the second feature, or simply means that the first feature is at a higher level than the second feature. When a first feature is "below," "below," or "below" a second feature, it may mean that the first feature is directly below or diagonally below the second feature, or simply means that the first feature is at a lower level than the second feature.
[0100] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the above terms should not be understood as necessarily referring to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0101] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A method for element position adaptation, characterized in that: It includes the following steps: Obtain the first size information of the original first canvas, the second size information of the second canvas after scale change, and the minimum bounding box information of the first element in the first canvas; Determine the scaling ratio according to the first size information and the second size information, and determine the size of the second element in the second canvas according to the scaling ratio; Calculate the relative position information between the first element and the first canvas according to the minimum bounding box information of the first element, and calculate the final position information of the second element in the second canvas according to the relative position information, so as to complete the position adaptation of the second element after the canvas scale change; Among them, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element, and the X-axis direction is the short side direction of the first canvas; Among them, the relative position information includes the X-axis ratio of the first element and the Y-axis ratio of the first element. Among them, the X-axis ratio of the first element and the Y-axis ratio of the first element are calculated according to the following formula: cxRatio = ax1 / (cw1 - aw1) cyRatio = ay1 / (ch1 - ah1) Among them, cxRatio represents the X-axis ratio of the first element, ax1 represents the X-axis value of the upper left corner point of the minimum bounding box of the first element, cw1 represents the length value of the short side of the first canvas, aw1 represents the width value of the minimum bounding box of the first element, cyRatio represents the Y-axis ratio of the first element, ay1 represents the Y-axis value of the upper left corner point of the minimum bounding box of the first element, ch1 represents the length value of the long side of the first canvas, and ah1 represents the height value of the minimum bounding box of the first element; Among them, the final position information of the second element includes the X-axis value of the upper left corner point of the minimum bounding box of the second element and the Y-axis value of the upper left corner point of the minimum bounding box of the second element; Among them, calculating the final position information of the second element in the second canvas according to the relative position information includes: If 0 < cxRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element = cxRatio * (cw2 - aw2), ax2 represents the X-axis value of the upper left corner point of the minimum bounding box of the second element, cw2 represents the length value of the side corresponding to the short side of the first canvas in the second canvas, and aw2 represents the width value of the minimum bounding box of the second element; If 1 < cxRatio, indicating that the X-axis of the first element extends beyond the first canvas, then calculate the X-axis extension ratio axOffsetRadio = (ax1 + aw1 - cw1) / aw1, and calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element = cw2 - (aw2 * (1 - axOffsetRadio)); If 0 < cyRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the Y-axis value ay2 of the upper left corner point of the minimum bounding box of the second element as ay2 = cyRatio * (ch2 - ah2), where ay2 represents the Y-axis value of the upper left corner point of the minimum bounding box of the second element, ch2 represents the length value of the side corresponding to the long side of the first canvas in the second canvas, and ah2 represents the length value of the minimum bounding box of the second element; If 1 < cyRatio, indicating that the Y-axis of the first element extends beyond the first canvas, then calculate the Y-axis extension ratio ayOffsetRadio = (ay1 + ah1 - ch1) / ah1, and calculate the Y-axis value ay2 of the upper left corner point of the minimum bounding box of the second element as ay2 = ch2 - (ah2 * (1 - ayOffsetRadio)) according to the Y-axis extension ratio.
2. The element position adaptation method according to claim 1, characterized in that: The size of the second element includes the width value and the height value of the second element, and the width value and the height value of the second element are calculated according to the following formulas: aAspect = aw1 / ah1 cSizeRadio = cw2 / cw1 aw2 = aw1 * cSizeRadio ah2 = aw2 / aAspect Where, aAspect represents the aspect ratio of the minimum bounding box of the first element, aw1 represents the width value of the minimum bounding box of the first element, ah1 represents the height value of the minimum bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length value of the short side of the first canvas, cw2 represents the length value of the side corresponding to the short side of the first canvas in the second canvas, aw2 represents the width value of the minimum bounding box of the second element, and ah2 represents the height value of the minimum bounding box of the second element.
3. A computer-readable storage medium, characterized in that It stores an element position adaptation program, and when the element position adaptation program is executed by a processor, it implements the element position adaptation method described in any one of claims 1-2.
4. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, it implements the element position adaptation method described in any one of claims 1-2.
5. An element position adaptation system, characterized in that: Including: An acquisition module, which is used to acquire the first size information of the original first canvas, the second size information of the second canvas after the ratio change, and the minimum bounding box information of the first element in the first canvas; A ratio determination module, which is used to determine the scaling ratio according to the first size information and the second size information, and determine the size of the second element in the second canvas according to the scaling ratio; A position adaptation module, which is used to calculate the relative position information between the first element and the first canvas according to the minimum bounding box information of the first element, and calculate the final position information of the second element in the second canvas according to the relative position information, so as to complete the position adaptation of the second element after the canvas ratio change; Among them, the minimum bounding box information of the first element includes the X-axis value of the upper left corner point of the minimum bounding box of the first element, the Y-axis value of the upper left corner point of the minimum bounding box of the first element, the width value of the minimum bounding box of the first element, and the length value of the minimum bounding box of the first element. The X-axis direction is the short side direction of the first canvas; Among them, the relative position information includes the X-axis ratio of the first element and the Y-axis ratio of the first element. Among them, the X-axis ratio of the first element and the Y-axis ratio of the first element are calculated according to the following formula: cxRatio = ax1 / (cw1 - aw1) cyRatio = ay1 / (ch1 - ah1) Among them, cxRatio represents the X-axis ratio of the first element, ax1 represents the X-axis value of the upper left corner point of the minimum bounding box of the first element, cw1 represents the length value of the short side of the first canvas, aw1 represents the width value of the minimum bounding box of the first element, cyRatio represents the Y-axis ratio of the first element, ay1 represents the Y-axis value of the upper left corner point of the minimum bounding box of the first element, ch1 represents the length value of the long side of the first canvas, and ah1 represents the height value of the minimum bounding box of the first element; Among them, the final position information of the second element includes the X-axis value of the upper left corner point of the minimum bounding box of the second element and the Y-axis value of the upper left corner point of the minimum bounding box of the second element; Among them, calculating the final position information of the second element in the second canvas according to the relative position information includes: If 0 < cxRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element as ax2 = cxRatio * (cw2 - aw2), where ax2 represents the X-axis value of the upper left corner point of the minimum bounding box of the second element, cw2 represents the length value of the corresponding side of the second canvas to the short side of the first canvas, and aw2 represents the width value of the minimum bounding box of the second element; If 1 < cxRatio, indicating that the X-axis of the first element extends beyond the first canvas, then calculate the X-axis extension ratio axOffsetRadio = (ax1 + aw1 - cw1) / aw1, and calculate the X-axis value ax2 of the upper left corner point of the minimum bounding box of the second element according to the X-axis extension ratio as ax2 = cw2 - (aw2 * (1 - axOffsetRadio)); If 0 < cyRatio ≤ 1, indicating that the first element is within the first canvas, then calculate the Y-axis value ay2 of the upper left corner point of the minimum bounding box of the second element as ay2 = cyRatio * (ch2 - ah2), where ay2 represents the Y-axis value of the upper left corner point of the minimum bounding box of the second element, ch2 represents the length value of the corresponding side of the second canvas to the long side of the first canvas, and ah2 represents the length value of the minimum bounding box of the second element; If 1 < cyRatio, indicating that the Y-axis of the first element extends beyond the first canvas, then calculate the Y-axis extension ratio of the first element ayOffsetRadio = (ay1 + ah1 - ch1) / ah1, and calculate the Y-axis value of the upper left corner point of the minimum bounding box of the second element according to the Y-axis extension ratio ay2 = ch2 - (ah2 * (1 - ayOffsetRadio)).
6. The element position adaptation system according to claim 5, characterized in that: The size of the second element includes the width value and the height value of the second element. The width value and the height value of the second element are calculated according to the following formulae: aAspect = aw1 / ah1 cSizeRadio = cw2 / cw1 aw2 = aw1 * cSizeRadio ah2 = aw2 / aAspect Where, aAspect represents the aspect ratio of the minimum bounding box of the first element, aw1 represents the width value of the minimum bounding box of the first element, ah1 represents the height value of the minimum bounding box of the first element, cSizeRadio represents the scaling ratio, cw1 represents the length value of the shorter side of the first canvas, cw2 represents the length value of the corresponding side of the second canvas to the shorter side of the first canvas, aw2 represents the width value of the minimum bounding box of the second element, and ah2 represents the height value of the minimum bounding box of the second element.
Citation Information
Patent Citations
Element arrangement method and device, computer readable storage medium and equipment
CN110780872A