Graphic Element Position Adjustment Method and Device, Electronic Device, Computer Readable Medium
The method and apparatus enhance graphic element positioning in graphic editors by calculating position offsets and dynamic reference lines, addressing inefficiencies in existing reference alignment systems and improving user experience and development efficiency.
Patent Information
- Application Number
- CN202111299622.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-04
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-11-04
AI Technical Summary
In the prior art, the development of reference adsorption function in the graphics editor is poor in versatility, and it is necessary to cooperate with business modules and drag components, resulting in poor development efficiency and user experience of reference lines.
By obtaining the initial and current position of the actuator, the initial and pre-moving position data of the element to be moved, the position offset and the predicted displacement change amount are calculated, and the dynamic and static reference line lists are generated. Based on these data, the adjustment position of the element to be moved is determined to realize the independent reference adsorption function.
It realizes the quick access to the reference adsorption function without considering business logic, improving the development efficiency and user experience of reference lines.
Smart Images

Figure CN114020182B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, specifically to fields such as computer vision, and particularly to a method and apparatus for adjusting the position of a graphic element, an electronic device, a computer-readable medium, and a computer program product. Background Art
[0002] A reference line is usually used to achieve quick alignment or reference during the dragging of a layer in a graphic editor.
[0003] The functions of the reference line include reference adsorption. Reference adsorption means that a graphic element in a graphic editor automatically moves to the position corresponding to the reference point when approaching the reference point corresponding to the reference line. In the development of the conventional reference adsorption function, it is often necessary to cooperate with the data of the current business module and the dragging component to complete the reference adsorption function of the reference line, and the generality is poor. Summary of the Invention
[0004] Embodiments of the present disclosure provide a method and apparatus for adjusting the position of a graphic element, an electronic device, a computer-readable medium, and a computer program product.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for adjusting the position of a graphic element. The method includes: when moving a graphic element to be moved, obtaining the initial position, current position of an actuator, the initial position of the graphic element to be moved, and the position data before movement; calculating a position offset of the actuator based on the initial position and the current position of the actuator; determining a predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved; determining a dynamic reference line list of the graphic element to be moved based on the position data before movement, where the dynamic reference line list is the reference line of the graphic element to be moved obtained through the position data before movement; determining an adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjusting the graphic element to be moved to the adjustment position.
[0006] In some embodiments, the determining the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved includes: adding the position offset to the initial position of the graphic element to be moved, subtracting the position value corresponding to the position data before movement, to obtain the predicted displacement change amount of the graphic element to be moved.
[0007] In some embodiments, the determining the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement includes: calculating an adjustment offset based on the dynamic reference line list and the predicted displacement change amount; calculating the adjustment position based on the adjustment offset and the position data before movement.
[0008] In some embodiments, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; and in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than a preset adsorption distance value, taking the predicted displacement change amount as the adjustment offset.
[0009] In some embodiments, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; and in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is less than or equal to a preset adsorption distance value, obtaining the adjustment offset based on the distance value between the dynamic reference line and the static reference line.
[0010] In some embodiments, the above method further includes: matching the static reference line list and the dynamic reference line list to obtain a matching reference line; and displaying the matching reference line.
[0011] In a second aspect, an embodiment of the present disclosure provides a graphic element position adjustment device, which includes: an acquisition unit configured to acquire the initial position, the current position of the actuator, the initial position of the graphic element to be moved, and the position data before movement when moving the graphic element to be moved; a calculation unit configured to calculate the position offset of the actuator based on the initial position and the current position of the actuator; a distance determination unit configured to determine the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved; a list determination unit configured to determine the dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved, the dynamic reference line list being the reference line of the graphic element to be moved obtained through the position data before movement; and an adjustment unit configured to determine the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjust the graphic element to be moved to the adjustment position.
[0012] In some embodiments, the above distance determination unit is further configured to add the position offset to the initial position of the graphic element to be moved, subtract the position value corresponding to the position data before movement, and obtain the predicted displacement change amount of the graphic element to be moved.
[0013] In some embodiments, the above-mentioned adjustment unit includes: an offset calculation module configured to calculate an adjustment offset based on a dynamic reference line list and a predicted displacement change amount; a position calculation module configured to calculate an adjusted position based on the adjustment offset and the pre-movement position data.
[0014] In some embodiments, the above-mentioned offset calculation module includes: a generation sub-module configured to generate a static reference line list based on all graphic elements in the static layer of the graphic editor; a selection sub-module configured to respectively select the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; an as sub-module configured to, in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than a preset adsorption distance value, use the predicted displacement change amount as the adjustment offset.
[0015] In some embodiments, the above-mentioned offset calculation module includes: a generation sub-module configured to generate a static reference line list based on all graphic elements in the static layer of the graphic editor; a selection sub-module configured to respectively select the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; an offset sub-module configured to, in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is less than or equal to a preset adsorption distance value, obtain an adjustment offset based on the distance value between the dynamic reference line and the static reference line.
[0016] In some embodiments, the above-mentioned device further includes: a matching unit configured to match the static reference line list and the dynamic reference line list to obtain a matching reference line; a display unit configured to display the matching reference line.
[0017] In a third aspect, an embodiment of the present disclosure provides an electronic device, which includes: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the first aspect.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, it implements the method described in any implementation manner of the first aspect.
[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method described in any implementation manner of the first aspect.
[0020] The method and device for adjusting the position of a graphic element provided by an embodiment of the present disclosure first obtain the initial position, current position of an actuator, the initial position of the graphic element to be moved, and the position data before movement when moving the graphic element to be moved; secondly, calculate the position offset of the actuator based on the initial position and the current position of the actuator; thirdly, determine the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved; fourthly, determine the dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved; finally, determine the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjust the graphic element to be moved to the adjustment position. Thus, based on the position offset of the actuator, the initial position of the graphic element to be moved, and the position data before movement of the graphic element to be moved, the adjustment position of the graphic element to be moved is obtained, realizing the reference adsorption function of separating the reference line alone. Without considering its own business logic, different systems or technologies can quickly access the reference adsorption function, and thus, based on the parameter passing requirements of the reference adsorption function, the reference line data can be quickly obtained, improving the development efficiency of the reference line and the user experience. Description of the Drawings
[0021] Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments read with reference to the accompanying drawings.
[0022] Figure 1 is an exemplary system architecture diagram to which an embodiment of the present disclosure can be applied;
[0023] Figure 2 is a flowchart of an embodiment of the method for adjusting the position of a graphic element according to the present disclosure;
[0024] Figure 3 is a schematic structural diagram of adjusting the offset according to the present disclosure;
[0025] Figure 4 is a flowchart of another embodiment of the method for adjusting the position of a graphic element according to the present disclosure;
[0026] Figure 5 is a schematic structural diagram of an embodiment of the device for adjusting the position of a graphic element according to the present disclosure;
[0027] Figure 6 is a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. Detailed Embodiments
[0028] The present disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. Additionally, it should be noted that for ease of description, only the parts related to the relevant invention are shown in the drawings.
[0029] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The present disclosure will be described in detail below with reference to the drawings and embodiments.
[0030] Figure 1 An exemplary system architecture 100 to which the graphic element position adjustment method of the present disclosure can be applied is shown.
[0031] As Figure 1 shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, and generally may include wireless communication links and the like.
[0032] The terminal devices 101, 102, 103 interact with the server 105 through the network 104 to receive or send messages and the like. Various communication client applications may be installed on the terminal devices 101, 102, 103, such as instant messaging tools, email clients, etc.
[0033] The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be drawing devices with communication and control functions. The above-mentioned drawing devices can communicate with the server 105. When the terminal devices 101, 102, 103 are software, they can be installed in the above-mentioned terminals. It can be implemented as multiple software or software modules (such as software or software modules for providing distributed reconciliation services), or can be implemented as a single software or software module. No specific limitation is made here.
[0034] The server 105 may be a server that provides various services, such as a drawing server that provides support for the drawing systems on the terminal devices 101, 102, 103. The drawing server can analyze and process the relevant information of each terminal in the network, and feedback the processing results (such as the adjusted positions of the graphic elements to be moved, etc.) to the terminal devices.
[0035] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the server is software, it can be implemented as multiple software or software modules (such as software or software modules for providing distributed services), or as a single software or software module. No specific limitation is made here.
[0036] It should be noted that the method for adjusting the position of graphic elements provided by the embodiments of the present disclosure is generally executed by the server 105.
[0037] As Figure 2 , a flowchart 200 of an embodiment of the method for adjusting the position of graphic elements according to the present disclosure is shown. The method for adjusting the position of graphic elements includes the following steps:
[0038] Step 201, when moving the graphic element to be moved, obtain the initial position, current position of the actuator, the initial position of the graphic element to be moved, and the position data before movement.
[0039] In this embodiment, the actuator is a device for moving the graphic element to be moved in a graphic editor. For example, the mouse for moving a rectangular graphic element. When moving the graphic element to be moved through the actuator, the actuator first moves from the initial position to the current position. The graphic element to be moved may directly move the same distance as the actuator, or when the automatic adsorption function in the image editor is enabled, if the automatic adsorption condition is met, the graphic element to be moved automatically moves to the target point closest to the graphic element to be moved. The target point can be at the reference line closest to the graphic element to be moved or at the graphic element closest to the graphic element to be moved.
[0040] In this embodiment, the initial position of the graphic element to be moved is the initial position before the graphic element to be moved is affected by the adsorption function of the graphic editor and before one or more movements are performed. The position before movement of the graphic element to be moved is the position of the graphic element to be moved when the execution entity is performing the current movement operation. When the graphic element to be moved has not moved at all, the position before movement of the graphic element to be moved is equal to the initial position of the graphic element to be moved; when the graphic element to be moved has been moved multiple times before performing the current movement, the position before movement of the graphic element to be moved is not equal to the initial position of the graphic element to be moved.
[0041] In this embodiment, the pre-movement position data of the to-be-moved graphic element may include: the position value of the to-be-moved graphic element before movement and the attribute value of the to-be-moved graphic element, and the attribute value of the to-be-moved graphic element can be used to determine the reference line of the to-be-moved graphic element. The attribute value may include: the shape of the to-be-moved graphic element, the length value, width value, line parameters, etc. of the to-be-moved graphic element, where the line parameters are used to characterize the positional relationship between all the reference lines of the to-be-moved graphic element. For example, if the line parameter is 0.5, the vertical distance between any two reference lines of the to-be-moved graphic element needs to be greater than 0.5. For another example, if the pre-movement position data of a to-be-moved graphic element is B1(40, 40, 50, 50), then the position value of the to-be-moved graphic element is (40, 40), the length of the to-be-moved graphic element is 50 cm, and the width of the to-be-moved graphic element is 50 cm.
[0042] In this embodiment, the execution entity of the graphic element position adjustment method (such as Figure 1 the server shown) can obtain the initial position, current position of the actuator, the initial position of the to-be-moved graphic element, and the pre-movement position data in various ways. For example, the execution entity can obtain the initial position, current position of the actuator, the initial position of the to-be-moved graphic element, and the pre-movement position data stored therein from the terminal (such as Figure 1 the terminals 101, 102, 103 shown) through a wired connection method or a wireless connection method. For another example, the user can collect the initial position, current position of the actuator, the initial position of the to-be-moved graphic element, and the pre-movement position data through the terminal (such as Figure 1 the terminals 101, 102 shown). In this way, the execution entity can receive the data collected by the terminal and store these data locally.
[0043] Step 202: Calculate the position offset of the actuator based on the initial position and the current position of the actuator.
[0044] In this embodiment, the position offset of the actuator refers to the displacement of the actuator from the initial position to the current position. For example, if the coordinates of the initial position of the actuator are A1(x, y) and the current position is the coordinates D(x, y), the position offset E(Dx - A1x, Dy - A1y) is calculated according to the coordinates A1(x, y) and the coordinates D(x, y), abbreviated as: E(x, y).
[0045] Step 203: Determine the predicted displacement change amount of the to-be-moved graphic element based on the position offset, the pre-movement position data, and the initial position of the to-be-moved graphic element.
[0046] In this embodiment, the predicted displacement change amount is used to characterize the maximum displacement to be moved when the to-be-moved graphic element is dragged alone by the actuator. The predicted displacement change amount is also the displacement amount that the actuator can act on the to-be-moved graphic element when the adsorption function is enabled in the editor and the to-be-moved graphic element is affected by the adsorption function.
[0047] In some alternative implementation manners of this embodiment, determining the predicted displacement change amount of the to-be-moved graphic element based on the position offset, the position data before movement, and the initial position of the to-be-moved graphic element includes: adding the position offset to the initial position of the to-be-moved graphic element, and subtracting the position value corresponding to the position data before movement to obtain the predicted displacement change amount of the to-be-moved graphic element.
[0048] In this embodiment, the position value corresponding to the position data before movement is the position value corresponding to the to-be-moved graphic element affected by the adsorption function of the editor.
[0049] Specifically, the position data before movement is B1(x, y, w, h), the initial position of the to-be-moved graphic element is M(x, y), and the predicted displacement change amount O(Ex + Mx – B1x, Ey + My – B1y), abbreviated as: O(x, y), can be calculated according to E(x, y) and B1(x, y, w, h), M(x, y).
[0050] In this alternative implementation manner, adding the position offset to the initial position of the to-be-moved graphic element and subtracting the position value corresponding to the position data before movement can effectively predict the maximum displacement that the to-be-moved graphic element can move to under the influence of the adsorption function of the editor, providing a reliable basis for obtaining the predicted displacement change amount.
[0051] Optionally, determining the predicted displacement change amount of the to-be-moved graphic element based on the position offset, the position data before movement, and the initial position of the to-be-moved graphic element includes:
[0052] Determining the position before movement of the to-be-moved graphic element from the position data before movement; subtracting the position before movement of the to-be-moved graphic element from the initial position of the to-be-moved graphic element to obtain the movement distance of the to-be-moved graphic element; adding the movement distance to the position offset to obtain the predicted displacement change amount.
[0053] Optionally, determining the predicted displacement change amount of the to-be-moved graphic element based on the position offset, the position data before movement, and the initial position of the to-be-moved graphic element includes:
[0054] Determining the position before movement of the to-be-moved graphic element from the position data before movement; subtracting the position before movement from the initial position of the to-be-moved graphic element to obtain a displacement difference, and multiplying the displacement difference by the current position of the actuator after dividing by the position offset, so as to estimate and obtain the predicted displacement change amount.
[0055] Step 204, determining the dynamic reference line list of the to-be-moved graphic element based on the position data before movement of the to-be-moved graphic element.
[0056] In this embodiment, after the adsorption function of the graphics editor for editing the to-be-moved primitive is turned on, the reference lines of each primitive in the graphics editor can be calculated, and the reference lines can be determined based on the reference line calculation rules preset in the graphics editor. Among them, the reference line calculation rules can be: calculating horizontal alignment, calculating vertical alignment, calculating the center line, etc. Among them, the dynamic reference line list is the reference line of the to-be-moved primitive obtained from the pre-movement position data.
[0057] For example, the data A(x, y, w, h) of a primitive is (0, 0, 100, 100), and the reference lines obtained through the reference line calculation rules include: A1 horizontal line, A2 horizontal line, B1 vertical line, B2 vertical line.
[0058] In this embodiment, the to-be-moved primitive is the primitive that needs to be moved. Through the reference line calculation rules, all the reference lines of the to-be-moved primitive can be obtained; and during the movement of the to-be-moved primitive, all the reference lines corresponding to the to-be-moved primitive can also be calculated in real time, all the reference lines corresponding to the to-be-moved primitive.
[0059] Step 205: Based on the dynamic reference line list, the predicted displacement change amount, and the pre-movement position data, determine the adjustment position, and adjust the to-be-moved primitive to the adjustment position.
[0060] In this embodiment, the adjustment position is the position where the to-be-moved primitive actually needs to move. This adjustment position is the position obtained based on the pre-movement position in the predicted displacement change amount and the pre-movement position data after excluding the adsorption influence of the dynamic reference line list on the to-be-moved primitive.
[0061] In some optional implementation manners of this embodiment, the above determining the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the pre-movement position data includes: calculating an adjustment offset based on the dynamic reference line list and the predicted displacement change amount; calculating the adjustment position based on the adjustment offset and the pre-movement position data.
[0062] In this optional implementation manner, the adjustment offset is the amount that the to-be-moved primitive needs to offset when it is at the position corresponding to the pre-movement position data.
[0063] In this optional implementation manner, by calculating the adjustment offset through the predicted displacement change amount and the pre-movement position data, and then obtaining the adjustment position from the adjustment offset, the calculation of the adjustment position can be simply and conveniently realized, improving the accuracy of the movement of the to-be-moved primitive.
[0064] Optionally, after obtaining the adjustment position, adjustment data can be calculated based on the adjustment position (that is, adding the attribute value of the to-be-moved primitive on the basis of the adjustment position), and the adjustment data can be used as the new pre-movement position data, thereby providing a basis for the next adjustment of the to-be-moved primitive.
[0065] In another alternative implementation of this embodiment, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; and in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than the preset adsorption distance value, taking the predicted displacement change amount as the adjustment offset.
[0066] In this alternative implementation, the layer where the graphic element to be moved is located is a dynamic layer, which is the layer where the execution subject is currently operating, and the layers other than the dynamic layer in the graphic editor are all static layers. The reference lines of each graphic element can be obtained based on all the graphic elements in the static layer of the graphic editor, and the reference lines of all the graphic elements in all the static layers are combined to obtain the static reference line list. Specifically, as shown in Table 1 and Table 2, Table 1 is the data of the graphic elements in the static layer, and Table 2 is the static reference line list L.
[0067] Table 1
[0068] Layer ID Coordinates Width and Height A 0,0 100,100 B 40,40 50,50
[0069] Table 2
[0070] Guide ID Type Offset Coordinates Belonging Layer ID A1 horizontal 0 A A2 horizontal 100 A A3 vertical 0 A A4 vertical 100 A B1 horizontal 40 B B2 horizontal 90 B B3 vertical 40 B B4 vertical 90 B
[0071] As Figure 3 shown, according to the moving direction of O(x, y), match the two closest reference lines F1 (the dynamic reference line in the dynamic reference line list L1) and N1 (the static reference line in the dynamic reference line list L) to the static reference line list L in this moving direction from the dynamic reference line list L1, and the position corresponding to the predicted displacement change amount is Figure 3 the position corresponding to F2 in. The distance between F1 and N1 is P, the distance between F2 and F1 is M, M corresponds to O(x, y), and M can be Ox or Oy.
[0072] If the absolute value of the difference between P - Ox or P - Oy is greater than the preset adsorption distance value (that is, the graphic element to be moved will not be affected by the adsorption force of the reference line), then directly take O(x, y) as the adjustment offset without processing.
[0073] In this alternative implementation, by obtaining the closest static reference line and static reference line to the graphic element to be moved, it can be determined whether the predicted displacement change amount is affected by the adsorption force of the reference line, so as to effectively determine the adjustment offset of the graphic element to be moved.
[0074] Optionally, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; in response to determining that the absolute value of the sum of the dynamic reference line minus the static reference line coordinates and the predicted displacement change amount is greater than a preset adsorption distance value, taking the predicted displacement change amount as the adjustment offset.
[0075] In this optional manner, if the absolute value of the difference between N1 and (F1 + Ox) or (F1 + Oy) is greater than the preset adsorption distance value, then O(x, y) is directly taken as the adjustment offset without processing.
[0076] In some optional implementation manners of this embodiment, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is less than or equal to the preset adsorption distance value, obtaining the adjustment offset based on the distance value between the dynamic reference line and the static reference line.
[0077] In this optional implementation manner, if the absolute value of the difference between P and Ox or P and Oy is less than or equal to the preset adsorption distance value (that is, the graphic element to be moved is affected by the adsorption force of the reference line), then the adjustment offset is obtained based on P. For example, the adjustment offset is T(N1x - F1x, N1y - F1y). It should be noted that: the adsorption has a direction. If there is no adsorption in one direction and there is adsorption in the other direction, then only the adjustment offset in the direction with adsorption is calculated. For example, if the graphic element to be moved only adsorbs the vertical reference line, then the adjustment offset is T(N1x - F1x, Oy).
[0078] In this optional implementation manner, by obtaining the closest static reference line and dynamic reference line to the graphic element to be moved, the distance value corresponding to the influence of the predicted displacement change amount by the adsorption force of the reference line is determined, thereby effectively determining the adjustment offset of the graphic element to be moved.
[0079] Optionally, calculating the adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: generating a static reference line list based on all the graphic elements in the static layer of the graphic editor; respectively selecting the dynamic reference line and the static reference line closest to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount; in response to determining that the absolute value of the sum of the coordinates of the dynamic reference line minus the static reference line and the predicted displacement change amount is less than or equal to the preset adsorption distance value, obtaining the adjustment offset based on the distance value between the dynamic reference line and the static reference line.
[0080] In this optional method, if the absolute value of the difference between N1 and (F1 + Ox) or (F1 + Oy) is less than or equal to the preset adsorption distance value, the adjustment offset is obtained based on P. For example, the adjustment offset is T(N1x - F1x, N1y - F1y). It should be noted that adsorption has a direction. If there is no adsorption in one direction and adsorption in the other direction, only the adjustment offset in the direction with adsorption is calculated. For example, if the graphic element to be moved only adsorbs the vertical reference line, the adjustment offset is T(N1x - F1x, Oy).
[0081] The graphic element position adjustment method provided by the embodiments of the present disclosure first obtains the initial position, current position, initial position of the graphic element to be moved, and position data before movement of the actuator when moving the graphic element to be moved; secondly, calculates the position offset of the actuator based on the initial position and current position of the actuator; thirdly, determines the predicted displacement change amount of the graphic element to be moved based on the position offset, position data before movement, and initial position of the graphic element to be moved; fourthly, determines the dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved; finally, determines the adjustment position based on the dynamic reference line list, predicted displacement change amount, and position data before movement, and adjusts the graphic element to be moved to the adjustment position. Thus, based on the position offset of the actuator, the initial position of the graphic element to be moved, and the position data before movement of the graphic element to be moved, the adjustment position of the graphic element to be moved is obtained, realizing the reference adsorption function of separately splitting out the reference line. Without considering its own business logic, different systems or technologies can quickly access the reference adsorption function, so that based on the parameter passing requirements of the reference adsorption function, the reference line data can be quickly obtained, improving the development efficiency of the reference line and the user experience.
[0082] In this embodiment, after generating a static reference line list for all graphic elements in the static layer based on the graphic editor, the static reference line list and the dynamic reference line list can be matched to obtain matching reference lines; the matching reference lines are displayed. In this embodiment, the matching reference lines are obtained by comparing the reference lines in the static reference line list with the reference lines in the dynamic reference line list one by one for similarity. In response to determining that the similarity between two reference lines is greater than the similarity threshold (e.g., 90%), any one of the two reference lines is used as a matching reference line. Please refer to Figure 4 , which shows the flowchart 400 of another embodiment of the graphic element position adjustment method provided by the present disclosure. The graphic element position adjustment method may include the following steps:
[0083] Step 401, when moving a graphic element to be moved, obtain the initial position, current position of the actuator, the initial position of the graphic element to be moved, and the position data before movement.
[0084] Step 402, calculate the position offset of the actuator based on the initial position and the current position of the actuator.
[0085] Step 403, determine the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved.
[0086] Step 404, determine the dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved.
[0087] It should be understood that the operations and features in the above steps 401 - 404 respectively correspond to the operations and features in steps 101 - 104. Therefore, the descriptions of the operations and features in the above steps 101 - 104 also apply to steps 401 - 404 and will not be repeated here.
[0088] Step 405, generate a static reference line list based on all graphic elements in the static layer of the graphic editor.
[0089] In this embodiment, the layer where the graphic element to be moved is located is a dynamic layer, and the layers other than the dynamic layer in the graphic editor are all static layers. The reference lines of each graphic element can be obtained based on all graphic elements in the static layer of the graphic editor, and the reference lines of all graphic elements in all static layers are combined to obtain a static reference line list, as specifically shown in Table 1 and Table 2. Table 1 is the data of the graphic elements in the static layer, and Table 2 is the static reference line list L.
[0090] As shown in Table 3 is the data of the graphic element to be moved in the dynamic layer, and Table 4 is the dynamic reference line list L1.
[0091] Table 3
[0092] Layer ID Coordinates Width and Height C 50,50 50,50
[0093] Table 4
[0094]
[0095]
[0096] Step 406: Match the static reference line list and the dynamic reference line list to obtain the matching reference line.
[0097] In this embodiment, after matching L1 and L, matching data is obtained and the matching data is returned. The matching reference line can be drawn through the matching data. For example, when matching the reference lines in Table 2 and Table 4, C2 and A2, C4 and A4 can be matched. Then, C2 and C4 can be used as the matching reference line, or A2 and A4 can be used as the matching reference line.
[0098] Step 407: Display the matching reference line.
[0099] In this embodiment, the matching reference line can be a static reference line in the static reference line list or a dynamic reference line in the dynamic reference line list, and the matching reference line can be displayed after moving the to-be-moved graphic element and after moving the to-be-moved graphic element.
[0100] Step 408: Based on the dragging direction corresponding to the predicted displacement change amount, respectively select the dynamic reference line and the static reference line closest to the to-be-moved graphic element from the dynamic reference line list and the static reference line list.
[0101] Step 409: In response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than the preset adsorption distance value, use the predicted displacement change amount as the adjustment offset.
[0102] Step 410: Based on the adjustment offset and the position data before movement, calculate the adjusted position and adjust the to-be-moved graphic element to the adjusted position.
[0103] In an example, the predicted displacement change amount of a to-be-moved graphic element is O(3, 3), and the position data before movement is B1(34, 17, 100, 100). Based on the data before movement, the dynamic reference line list is shown in Table 5. By matching the static reference line list in Table 2, the two reference lines B3 and F3 with the closest distance can be obtained. The sum of F3 and Ox is 37. At this time, the difference 40 - 37 < 5 (the preset adsorption distance value), meeting the adsorption requirement. At this time, the adjustment offset obtained is T(40 - 34, 3), that is, T(6, 3).
[0104] Table 5
[0105]
[0106]
[0107] Using the graphic element position adjustment method provided in this embodiment to obtain the reference line module, only the basic data and coordinate information required by the reference line module need to be given to complete the reference line matching and the calculation of the adjusted position. That is, two initial information, namely the initial position of the actuator and the initial position of the graphic element to be moved, are given to the reference line module, and subsequently, only the current coordinates of the actuator and the current position of the graphic element to be moved are required to complete the calculation of the adjusted position.
[0108] In the process of adjusting the graphic element to be moved, the graphic element position adjustment method provided in this embodiment matches the static reference line list with the dynamic reference line list to obtain the matching reference line, and displays the matching reference line, which can display in real time the matching reference line of the graphic element to be moved when moving and matching with the static reference lines of the static layer, providing a reliable hint for the user to draw a graph.
[0109] Further referring to Figure 5 , as an implementation of the methods shown in the above figures, an embodiment of a graphic element position adjustment device is provided in the present disclosure. This device embodiment corresponds to Figure 2 the method embodiment shown, and this device can be specifically applied to various electronic devices.
[0110] As Figure 5 shown, an embodiment of the present disclosure provides a graphic element position adjustment device 500. The device 500 includes: an acquisition unit 501, a calculation unit 502, a distance determination unit 503, a list determination unit 504, and an adjustment unit 505. Among them, the above acquisition unit 501 can be configured to acquire the initial position, current position, initial position of the graphic element to be moved, and the position data before movement when moving the graphic element to be moved. The above calculation unit 502 can be configured to calculate the position offset of the actuator based on the initial position and the current position of the actuator. The above distance determination unit 503 can be configured to determine the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved. The above list determination unit 504 can be configured to determine the dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved. The dynamic reference line list is the reference line of the graphic element to be moved obtained through the position data before movement. The above adjustment unit 505 can be configured to determine the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjust the graphic element to be moved to the adjustment position.
[0111] In this embodiment, in the graphic element position adjustment device 500, the specific processing of the acquisition unit 501, the calculation unit 502, the distance determination unit 503, the list determination unit 504, and the adjustment unit 505 and the technical effects brought thereby can be respectively referred to Figure 2 Steps 201, 202, 203, 204, and 205 in the corresponding embodiment.
[0112] In some embodiments, the above distance determination unit 503 is further configured to add the position offset to the initial position of the graphic element to be moved, subtract the position value corresponding to the position data before movement, and obtain the predicted displacement change amount of the graphic element to be moved.
[0113] In some embodiments, the above adjustment unit 505 includes: an offset calculation module (not shown in the figure), a position calculation module (not shown in the figure). Among them, the above offset calculation module can be configured to calculate the adjustment offset based on the dynamic reference line list and the predicted displacement change amount. The above position calculation module can be configured to calculate the adjusted position based on the adjustment offset and the position data before movement.
[0114] In some embodiments, the above offset calculation module includes: a generation sub-module (not shown in the figure), a selection sub-module (not shown in the figure), and a serving as sub-module (not shown in the figure). Among them, the above generation sub-module can be configured to generate a static reference line list based on all graphic elements in the static layer of the graphic editor. The above selection sub-module can be configured to respectively select the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount. The above serving as sub-module can be configured to, in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than the preset adsorption distance value, use the predicted displacement change amount as the adjustment offset.
[0115] In some embodiments, the above offset calculation module includes: a generation sub-module (not shown in the figure), a selection sub-module (not shown in the figure), and an offset sub-module (not shown in the figure). Among them, the above generation sub-module can be configured to generate a static reference line list based on all graphic elements in the static layer of the graphic editor. The above selection sub-module can be configured to respectively select the closest dynamic reference line and static reference line to the graphic element to be moved from the dynamic reference line list and the static reference line list based on the dragging direction corresponding to the predicted displacement change amount. The above offset sub-module can be configured to, in response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is less than or equal to the preset adsorption distance value, obtain the adjustment offset based on the distance value between the dynamic reference line and the static reference line.
[0116] In some embodiments, the above-mentioned device 500 further includes: a matching unit (not shown in the figure), and a display unit (not shown in the figure). The above-mentioned matching unit can be configured to match the static reference line list and the dynamic reference line list to obtain the matching reference line. The above-mentioned display unit can be configured to display the matching reference line.
[0117] For the primitive position adjustment device provided by the embodiments of the present disclosure, first, when the acquisition unit 501 moves the primitive to be moved, it acquires the initial position, the current position of the actuator, the initial position of the primitive to be moved, and the position data before movement; second, the calculation unit 502 calculates the position offset of the actuator based on the initial position and the current position of the actuator; third, the distance determination unit 503 determines the predicted displacement change amount of the primitive to be moved based on the position offset, the position data before movement, and the initial position of the primitive to be moved; fourth, the list determination unit 504 determines the dynamic reference line list of the primitive to be moved based on the position data before movement of the primitive to be moved; finally, the adjustment unit 505 determines the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjusts the primitive to be moved to the adjustment position. Thus, based on the position offset of the actuator, the initial position of the primitive to be moved, and the position data before movement of the primitive to be moved, the adjustment position of the primitive to be moved is obtained, realizing the reference adsorption function of separately splitting out the reference line. Without considering its own business logic, different systems or technologies can quickly access the reference adsorption function. Thus, based on the parameter passing requirements of the reference adsorption function, the reference line data can be quickly obtained, improving the reference line development efficiency and user experience.
[0118] The following refers to Figure 6 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure.
[0119] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0120] Typically, the following devices can be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices can be implemented or had. Figure 6 Each block shown in can represent one device or, as required, multiple devices.
[0121] Specifically, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program contains program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the methods of the embodiments of the present disclosure are performed.
[0122] It should be noted that the computer-readable medium in the embodiments of the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0123] The above computer-readable medium can be included in the above server; or it can exist separately without being assembled into the server. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the server, the server is caused to: when moving a to-be-moved primitive, obtain the initial position, current position of the actuator, the initial position of the to-be-moved primitive, and the position data before movement; calculate the position offset of the actuator based on the initial position and current position of the actuator; determine the predicted displacement change amount of the to-be-moved primitive based on the position offset, the position data before movement, and the initial position of the to-be-moved primitive; determine the dynamic reference line list of the to-be-moved primitive based on the position data before movement of the to-be-moved primitive; determine the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjust the to-be-moved primitive to the adjustment position.
[0124] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0125] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0126] The units involved in the embodiments described in the present disclosure may be implemented in software or in hardware. The described units may also be provided in a processor. For example, it may be described as a processor including an acquisition unit, a calculation unit, a distance determination unit, a list determination unit, and an adjustment unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases. For example, the data acquisition unit may also be described as a unit "configured to acquire the initial position, current position of the actuator, the initial position of the to-be-moved primitive, and the position data before movement when moving the to-be-moved primitive".
[0127] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with (but not limited to) the technical features with similar functions disclosed in the embodiments of the present disclosure.
Claims
1. A method for adjusting the position of a graphic element, the method comprising: When moving a graphic element to be moved, obtaining the initial position, the current position of an actuator in a graphic editor, the initial position of the graphic element to be moved, and the position data before movement; Calculating a position offset of the actuator based on the initial position and the current position of the actuator; Determining a predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved; wherein the predicted displacement change amount is used to characterize the displacement amount of the actuator acting on the graphic element to be moved when the adsorption function is turned on in the graphic editor and the graphic element to be moved is affected by the adsorption function; Determining a dynamic reference line list of the graphic element to be moved based on the position data before movement of the graphic element to be moved, the dynamic reference line list being the reference line of the graphic element to be moved obtained through the position data before movement; Determining an adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjusting the graphic element to be moved to the adjustment position.
2. The method according to claim 1, wherein The determining the predicted displacement change amount of the graphic element to be moved based on the position offset, the position data before movement, and the initial position of the graphic element to be moved includes: Adding the position offset to the initial position of the graphic element to be moved, and subtracting the position value corresponding to the position data before movement to obtain the predicted displacement change amount of the graphic element to be moved.
3. The method according to claim 1, wherein The determining the adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement includes: Calculating an adjustment offset based on the dynamic reference line list and the predicted displacement change amount; Calculating an adjustment position based on the adjustment offset and the position data before movement.
4. The method according to claim 3, wherein The calculating an adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: Generating a static reference line list based on all graphic elements in the static layer of the graphic editor; Selecting the dynamic reference line and the static reference line closest to the graphic element to be moved from the dynamic reference line list and the static reference line list respectively based on the dragging direction corresponding to the predicted displacement change amount; In response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is greater than a preset adsorption distance value, using the predicted displacement change amount as the adjustment offset.
5. The method according to claim 3, wherein, The calculating an adjustment offset based on the dynamic reference line list and the predicted displacement change amount includes: Generating a static reference line list based on all graphic elements in the static layer of the graphic editor; Selecting the dynamic reference line and the static reference line closest to the graphic element to be moved from the dynamic reference line list and the static reference line list respectively based on the dragging direction corresponding to the predicted displacement change amount; In response to determining that the absolute value of the difference between the distance between the dynamic reference line and the static reference line and the predicted displacement change amount is less than or equal to a preset adsorption distance value, an adjustment offset amount is obtained based on the distance value between the dynamic reference line and the static reference line.
6. The method according to claim 4 or 5, wherein the method further comprises: matching the static reference line list and the dynamic reference line list to obtain a matching reference line; displaying the matching reference line.
7. A primitive position adjustment device, the device comprising: an acquisition unit configured to acquire the initial position, the current position of an actuator in a graphic editor, the initial position of the primitive to be moved, and the position data before movement when moving the primitive to be moved; a calculation unit configured to calculate a position offset amount of the actuator based on the initial position and the current position of the actuator; a distance determination unit configured to determine a predicted displacement change amount of the primitive to be moved based on the position offset amount, the position data before movement, and the initial position of the primitive to be moved; wherein the predicted displacement change amount is used to characterize the displacement amount of the actuator acting on the primitive to be moved when the adsorption function is turned on in the graphic editor and the primitive to be moved is affected by the adsorption function; a list determination unit configured to determine a dynamic reference line list of the primitive to be moved based on the position data before movement of the primitive to be moved, the dynamic reference line list being the reference line of the primitive to be moved obtained through the position data before movement; an adjustment unit configured to determine an adjustment position based on the dynamic reference line list, the predicted displacement change amount, and the position data before movement, and adjust the primitive to be moved to the adjustment position.
8. The apparatus according to claim 7, wherein, The distance determination unit is further configured to add the position offset amount to the initial position of the primitive to be moved, subtract the position value corresponding to the position data before movement, and obtain the predicted displacement change amount of the primitive to be moved.
9. The apparatus according to claim 7, wherein, The adjustment unit includes: an offset calculation module configured to calculate an adjustment offset amount based on the dynamic reference line list and the predicted displacement change amount; a position calculation module configured to calculate an adjustment position based on the adjustment offset amount and the position data before movement.
10. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon; when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.
11. A computer-readable medium having a computer program stored thereon, wherein, The program, when executed by a processor, implements the method according to any one of claims 1-6.
12. A computer program product, comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Image position adjusting method and device
CN105892869A
Sticker processing method and device
CN113496533A