Shadow generation method and device and storage medium
By obtaining and utilizing the shadow parameters of the target control and generating diffusely distributed shadows, the problem of single shadow effect in the existing technology is solved, and a more natural and applicable shadow effect is achieved.
Patent Information
- Application Number
- CN202311406150.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art when generating shadows in graphical interfaces, the effect is single, cannot be changed through parameters, and is not suitable for specific scenarios such as controls to generate shadows.
By obtaining the shadow parameters of the target control, a diffusely distributed shadow is generated in the area of the target control based on these parameters. The specific method includes determining a second image, the image includes a shadowed area and a non-shaded area, and the pixel point density of the shadowed area is lower than that of the non-shaded area, and generating a shadow based on this.
It realizes a more natural shadow effect, suitable for controls in different scenes to generate shadows, enhancing the three-dimensional sense of the graphics and information communication ability.
Smart Images

Figure CN119904496A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of display, and in particular to a shadow generation method, device and storage medium. Background Art
[0002] At present, in the field of graphical interface display, shadows are generally added to graphics to provide height information for the content displayed on a two-dimensional plane, which can give the graphics a three-dimensional effect. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a shadow generation method, device and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a shadow generation method is provided, comprising: acquiring shadow parameters of a target control; generating a shadow in an area where the target control is located according to the shadow parameters, wherein the shadow is diffusely distributed.
[0005] In one embodiment, generating a shadow in the area where the target control is located according to the shadow parameters includes: determining a second image based on the target control and the shadow parameters, the second image including a shadow area and a non-shadow area, the pixel density of the shadow area being lower than the pixel density of the non-shadow area; generating a shadow in the area where the target control is located based on the second image.
[0006] In one embodiment, the shadow parameters include a shadow radius, and determining the second image based on the target control and the shadow parameters includes: compressing based on the shadow radius inside the target control to obtain a third image; expanding based on the shadow radius outside the target control to obtain a fourth image; determining a first area between the target control and the third image, and a second area between the target control and the fourth image as areas to be processed corresponding to the target control; performing a coordinate transformation on each pixel point in the area to be processed, and the coordinate transformation is used to transform the coordinates of each pixel point in the first area to within the third image, and transform the coordinates of each pixel point in the second area to outside the fourth image; generating the second image based on each pixel point after the coordinate transformation, wherein each pixel point after the coordinate transformation corresponds to the shadow area in the second image.
[0007] In one embodiment, the coordinate transformation of each pixel point in the area to be processed includes: calculating the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the target control; wherein, the smaller the distance between the first pixel point of the first area and the target control, the larger the first coordinate transformation parameter corresponding to the first pixel point; the larger the distance between the second pixel point of the second area and the target control, the larger the first coordinate transformation parameter corresponding to the second pixel point; based on the first coordinate transformation parameter corresponding to each pixel point, the coordinate transformation of each pixel point is performed.
[0008] In one embodiment, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and the target control, including: in response to the shape of the target control being a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and a center pixel point, and the center pixel point represents the pixel point at the center position of the target control.
[0009] In one embodiment, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and the center pixel point, including: in response to the target control being a shape other than a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and the outline of the target control.
[0010] In one embodiment, the generating of the second image based on each pixel point after coordinate transformation includes: determining a first transparency window from at least one preset transparency window according to the shadow parameters, the transparency window including N×N pixels, each pixel point corresponding to a transparency value, the first transparency window corresponding to a rectangular vertex, and N being a positive integer; determining a first transparency value of each pixel point after coordinate transformation according to the first transparency window; and generating the second image based on the first transparency value.
[0011] In one embodiment, the shadow parameters include a shadow radius, and generating the shadow of the second image based on each pixel after the transformation includes: determining the second transparency value of each pixel after the coordinate transformation according to a preset transparency range and the shadow radius; determining the coefficient value of each pixel after the coordinate transformation according to the distance between each pixel after the coordinate transformation and the center pixel; multiplying the second transparency value and the coefficient value of each pixel after the coordinate transformation to obtain a third transparency value of each pixel after the coordinate transformation; and obtaining the second image based on each pixel after the coordinate transformation whose transparency is the third transparency value.
[0012] In one embodiment, obtaining the shadow of the target control based on the second image includes: obtaining a fifth transparency value, wherein the fifth transparency value is a randomly generated transparency value; replacing the transparency value of a third pixel in the second image with the fifth transparency value; and generating a shadow in the area where the target control is located based on the second image after replacing the transparency value; wherein the third pixel represents any one or more pixel points in the shadow area.
[0013] According to a second aspect of an embodiment of the present disclosure, a shadow generating device is provided, including: an acquisition module for acquiring shadow parameters of a target control; a processing module for generating a shadow in an area where the target control is located according to the shadow parameters, wherein the shadow is diffusely distributed.
[0014] In one embodiment, the processing module uses the shadow parameters in the following manner to generate a shadow in the area where the target control is located: based on the target control and the shadow parameters, a second image is determined, the second image includes a shadow area and a non-shadow area, and the pixel density of the shadow area is lower than the pixel density of the non-shadow area; based on the second image, a shadow is generated in the area where the target control is located.
[0015] In one embodiment, the shadow parameters include a shadow radius, and the processing module determines the second image based on the target control and the shadow parameters in the following manner: compressing the inside of the target control based on the shadow radius to obtain a third image; expanding the outside of the target control based on the shadow radius to obtain a fourth image; determining the first area between the target control and the third image, and the second area between the target control and the fourth image as the area to be processed corresponding to the target control; performing coordinate transformation on each pixel point in the area to be processed, and the coordinate transformation is used to transform the coordinates of each pixel point in the first area to within the third image, and transform the coordinates of each pixel point in the second area to outside the fourth image; generating the second image based on each pixel point after the coordinate transformation, wherein each pixel point after the coordinate transformation corresponds to the shadow area in the second image.
[0016] In one embodiment, the processing module transforms the coordinates of each pixel point in the area to be processed in the following manner: according to the distance between each pixel point and the target control, the first coordinate transformation parameter corresponding to each pixel point is calculated; wherein, the smaller the distance between the first pixel point of the first area and the target control, the larger the first coordinate transformation parameter corresponding to the first pixel point; the larger the distance between the second pixel point of the second area and the target control, the larger the first coordinate transformation parameter corresponding to the second pixel point; based on the first coordinate transformation parameter corresponding to each pixel point, the coordinates of each pixel point are transformed.
[0017] In one embodiment, the processing module calculates the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the target control in the following manner: in response to the shape of the target control being a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated according to the distance between each pixel point and a center pixel point, and the center pixel point represents the pixel point at the center position of the target control.
[0018] In one embodiment, the processing module calculates the first coordinate transformation parameter corresponding to each pixel point based on the distance between each pixel point and the center pixel point in the following manner: in response to the target control being a shape other than a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and the outline of the target control.
[0019] In one embodiment, the processing module generates the second image based on each pixel point after coordinate transformation in the following manner: according to the shadow parameters, determine a first transparency window from at least one preset transparency window, the transparency window includes N×N pixels, each pixel point corresponds to a transparency value, the first transparency window corresponds to a rectangular vertex, and N is a positive integer; according to the first transparency window, determine the first transparency value of each pixel point after coordinate transformation; based on the first transparency value, generate the second image.
[0020] In one embodiment, the shadow parameters include a shadow radius, and the processing module generates the shadow of the second image based on each transformed pixel point in the following manner: determine the second transparency value of each pixel point after the coordinate transformation according to a preset transparency range and the shadow radius; determine the coefficient value of each pixel point after the coordinate transformation according to the distance between each pixel point after the coordinate transformation and the center pixel point; multiply the second transparency value and the coefficient value of each pixel point after the coordinate transformation to obtain a third transparency value of each pixel point after the coordinate transformation; and obtain the second image based on each pixel point after the coordinate transformation whose transparency is the third transparency value.
[0021] In one embodiment, the processing module obtains the shadow of the target control based on the second image in the following manner: obtain a fifth transparency value, where the fifth transparency value is a randomly generated transparency value; replace the transparency value of the third pixel point in the second image with the fifth transparency value; and generate a shadow in the area where the target control is located based on the second image after replacing the transparency value; wherein the third pixel point represents any one or more pixel points in the shadow area.
[0022] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a memory for storing instructions; and a processor for calling the instructions stored in the memory to execute the shadow generation method of the first aspect and any one of the implementations of the first aspect.
[0023] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions are executed by a processor, the shadow generation method in the first aspect or any one of the implementations of the first aspect is executed.
[0024] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: by acquiring the shadow parameters of the target control, a shadow is generated in the area where the target control is located according to the shadow parameters, and the shadow is diffusely distributed to make the effect more natural.
[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0027] Figure 1 The figure is a flow chart of a shadow generating method according to an exemplary embodiment.
[0028] Figure 2 is a schematic diagram of a shadow radius according to an exemplary embodiment.
[0029] Figure 3 The figure is a flow chart of a shadow generating method according to an exemplary embodiment.
[0030] Figure 4 is a flow chart of a second image determination method according to an exemplary embodiment.
[0031] Figure 5 is a schematic diagram of a target control, a third image and a fourth image according to an exemplary embodiment.
[0032] Figure 6 is a flow chart of a coordinate transformation method according to an exemplary embodiment.
[0033] Figure 7 is a flow chart of a second image generating method according to an exemplary embodiment.
[0034] Figure 8 is a schematic diagram of applying a first transparency window according to an exemplary embodiment.
[0035] Fig. 9 The figure is a schematic diagram of a method for determining a transparency value according to an exemplary embodiment.
[0036] Fig.10 is a flow chart of a second image generating method according to an exemplary embodiment.
[0037] Fig.11 is a flow chart of a second image generating method according to an exemplary embodiment.
[0038] Fig.12 The figure is a block diagram of a shadow generating device according to an exemplary embodiment.
[0039] Fig.13 The figure is a block diagram of a shadow generating device according to an exemplary embodiment. DETAILED DESCRIPTION
[0040] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.
[0041] At present, in the field of graphical interface display, shadows are generally added to graphics to provide height information for the content displayed on a two-dimensional plane, which can give the graphics a three-dimensional effect.
[0042] In some embodiments, shadows can be generated in a preset manner in the terminal operating system. However, the effect is often single, and the shadow effect cannot be changed by parameters. It is not applicable to scenes with specific shadows, for example, scenes where shadows are generated for controls. Controls are also called user interface controls, and are used to provide functions of interface elements such as windows, text boxes, buttons, and drop-down menus.
[0043] In some embodiments, shadows can be generated by prefabricated maps. However, the effects of prefabricated maps are also relatively simple, unable to provide rich effects, and cannot be used on controls that require animation and interactive effects, and cannot be rendered in real time, resulting in an inability to smoothly transition shadows.
[0044] In some embodiments, more complex shadows can be obtained through a large amount of calculations. They are mainly used in scenes such as games and virtual reality (VR). They have high requirements on the performance of the device and are not suitable for most terminals.
[0045] Therefore, the present disclosure provides a shadow generation method, which obtains shadow parameters of a target control and generates a shadow in the area where the target control is located according to the shadow parameters. The shadow is diffusely distributed to make the effect more natural.
[0046] The shadow generation method disclosed in the present invention can be applied to a terminal, wherein the terminal can also be referred to as a terminal device, a mobile station (MS), a mobile terminal (MT), etc., which is a device that provides voice and / or data connectivity to a user. For example, the terminal can be a handheld device with a wireless connection function, a vehicle-mounted device, etc. At present, some examples of terminals are: a smart phone (mobile phone), a pocket personal computer (PPC), a handheld computer, a personal digital assistant (PDA), a laptop computer, a tablet computer, a wearable device, or a vehicle-mounted device, etc. In addition, when it is a vehicle to everything (V2X) communication system, the terminal device can also be a vehicle-mounted device. It should be understood that the embodiments of the present disclosure do not limit the specific technology and specific device form adopted by the terminal.
[0047] Figure 1 is a flowchart of a shadow generation method according to an exemplary embodiment. Figure 1 As shown, the shadow generation method includes the following steps.
[0048] In step S11, the shadow parameters of the target control are obtained.
[0049] In one embodiment, the shadow parameters of the target control (view) can be obtained. For example, the shadow parameters can be obtained from an application (application, APP). For example, if the target control is a notification box of an APP, the shadow parameters can be obtained from the APP. For another example, the shadow parameters can also be obtained from the data stored in the terminal, or the shadow parameters can also be obtained from other devices or the cloud. The present disclosure does not limit this. Different target controls correspond to different shadow parameters. Among them, the control can represent the basic building blocks in the user interface of the terminal, for example, it can be a user interface element used in the APP, which can be used for users to interact with the APP. The target control in this embodiment includes any control to generate a shadow, for example, the target control can be a notification box, a sidebar, a button, a text input box, etc. Among them, the sidebar can, for example, display commonly used APPs, recently used APPs, etc. It can be understood that the examples of the above target controls are only exemplary, and the present disclosure does not list them one by one, but is not limited to this.
[0050] In this embodiment, the shadow parameters can be understood as a series of parameters used to generate shadows. For example, the shadow parameters include shadow color, shadow radius, shadow position offset, etc. Among them, the shadow color can be any color that is different from the background color. For example, for a white background, the shadow color can be black. For a black background, the shadow color cannot be black, otherwise the shadow effect cannot be displayed. The shadow radius can be understood as the range of the shadow, and its size is expressed as the number of pixels. For example, Figure 2 is a schematic diagram of a shadow radius according to an exemplary embodiment. Figure 2 As shown in the figure, the blank part represents the target control to generate the shadow, and its size is 4×4 pixels. If the shadow radius is 2, that is, 2 pixels, it is equivalent to drawing two circles of pixels around the target control to generate the shadow, such as Figure 2 The dark part is shown in the figure, and the dark part is the shadow. The target control and the shadow have a total of 8×8 pixels. Figure 2 For example, but Figure 2 This is just one possible situation. For example, the target control to generate the shadow can also be of other shapes. When drawing the shadow of the target control according to the shadow radius, it can include drawing to the periphery or drawing to the inside. This disclosure does not give examples one by one, but it can be understood that it is not limited to Figure 2 The shadow position offset may include, for example, the direction and distance of the shadow offset.
[0051] In step S12, a shadow is generated in the area where the target control is located according to the shadow parameters, and the shadow is diffusely distributed.
[0052] In one embodiment, a shadow may be generated in the area where the target control is located according to the shadow parameters. For example, pixels may be drawn around the target control, or a complete image may be generated and drawn below the target control. The generated shadow is diffusely distributed. The diffuse distribution may be understood as a relatively small density of pixels, that is, the pixels within a certain range are diffused into a larger range. The diffuse distribution of the shadow in this embodiment may also mean that the closer to the edge of the shadow, the greater the density of pixels.
[0053] The present disclosure obtains shadow parameters of a target control, and generates a shadow in the area where the target control is located according to the shadow parameters. The shadow is diffusely distributed to make the effect more natural.
[0054] In some embodiments, Figure 3 is a flowchart of a shadow generation method according to an exemplary embodiment. Figure 3 As shown, the shadow generation method includes the following steps.
[0055] In step S21, based on the target control and the shadow parameters, a second image is determined, wherein the second image includes a shadow area and a non-shadow area, and the pixel density of the shadow area is lower than the pixel density of the non-shadow area.
[0056] In one embodiment, the second image can be determined according to the target control and the shadow parameters. For example, multiple available shadow images can be generated in advance according to the shape of the target control to be shadowed, multiple combinations of shadow parameters, etc., and the shadow images can be stored in the terminal or in the cloud. Among them, the shape of the image to be shadowed can be, for example, a rectangle, a triangle, a five-pointed star, etc., and the present disclosure is only an example and is not limited. Multiple combinations of shadow parameters, such as shadow color A and shadow radius R1, shadow color A and shadow radius R2, shadow color A and shadow radius R2, and other similar combinations, are only examples and are not limited to this. The second image can be determined from multiple shadow images according to the shape of the acquired target control and / or the acquired shadow parameters. For another example, the second image can be generated in real time. That is, each pixel of the second image is determined in real time according to the acquired target control and the acquired shadow parameters, for example, the coordinates of each pixel and the grayscale value of each pixel are determined to obtain the second image.
[0057] In step S22, a shadow is generated in the area where the target control is located based on the second image.
[0058] In one embodiment, the second image may be superimposed below the target control. For example, the second image may be drawn below the target control through a canvas to form a shadow transition between the target control and the background, thereby achieving a suspended three-dimensional effect of the target control. Alternatively, pixel points may be drawn in the area where the target control is located based on the second image.
[0059] The present invention obtains the target control and shadow parameters to determine the second image. The pixel density of the shadow area included in the second image is lower and lower than the pixel density of the non-shadow area, so the effect is more natural. The shadow obtained based on the second image is more natural and the effect is better.
[0060] In some embodiments, Figure 4 FIG. 1 is a flow chart of a second image determination method according to an exemplary embodiment. Figure 4 As shown, the present disclosure provides a method for determining a second image, comprising the following steps.
[0061] In step S31, compression is performed inside the target control based on the shadow radius to obtain a third image.
[0062] In one embodiment, the third image can be obtained by compressing the target control based on the shadow radius. That is, compressing from the edge of the target control inward, and the compression distance is the shadow radius. It can also be understood as intercepting the third image inside the target control. For example, Figure 5 FIG. 1 is a schematic diagram showing a target control, a third image and a fourth image according to an exemplary embodiment. Figure 5 As shown, the square marked as 2 represents the target control, the square marked as 1 represents the third image, the square marked as 3 represents the fourth image, and r represents the shadow radius.
[0063] In step S32, the fourth image is obtained by expanding outside the target control based on the shadow radius.
[0064] In one embodiment, the fourth image can be obtained by expanding outside the target control based on the shadow radius. That is, expanding outward from the edge of the target control, and the expansion distance is the shadow radius. It can also be understood as intercepting the fourth image outside the target control. For example, the fourth image is as follows: Figure 5 As shown in the 3 marked squares.
[0065] In step S33, the first area between the target control and the third image, and the second area between the target control and the fourth image, are determined as the to-be-processed areas corresponding to the target control.
[0066] In one embodiment, the first area between the target control and the third image can be determined as the area to be processed, and the first area can be understood as the inward shadow of the target control to be processed. The second area between the target control and the fourth image can be determined as the area to be processed, and the second area can be understood as the outward shadow of the target control to be processed. Figure 5 The area marked in and filled with diagonal lines, the second area is such as Figure 5 The area marked in and filled with points.
[0067] In step S34, coordinate transformation is performed on each pixel point in the area to be processed. The coordinate transformation is used to transform the coordinates of each pixel point in the first area to within the third image and transform the coordinates of each pixel point in the second area to outside the fourth image.
[0068] In one embodiment, the coordinates of each pixel point in the area to be processed may be transformed. For example, for each pixel point in the first area, after the coordinate transformation, the pixel point may be at the original position or within the third image, that is, diffused into the third image. For each pixel point in the second area, after the coordinate transformation, the pixel point may be at the original position or outside the fourth image, that is, expanded outside the fourth image. The density of each pixel point after the coordinate transformation is smaller, and the shadow area of the final second image is more divergent, that is, the effect is more natural.
[0069] In step S35, a second image is generated based on each pixel point after coordinate transformation, wherein each pixel point after coordinate transformation corresponds to a shadow area in the second image.
[0070] In one embodiment, the second image can be generated based on each pixel after coordinate transformation, that is, the second image includes each pixel in the third image that has not undergone coordinate transformation, and each pixel in the first area and the second area after coordinate transformation, and these pixel points constitute the second image. The pixel points after coordinate transformation are distributed in the third image, the first area, the second area, and the outside of the fourth image, and these parts correspond to the shadow area of the second image, and the other parts correspond to the non-shadow area of the second image.
[0071] The present disclosure performs coordinate transformation on each pixel point in a determined area to be processed, thereby obtaining a second image with a lower pixel density in the shadow area. The shadow of the second image has a diffuse effect and is more natural.
[0072] In some embodiments, Figure 6 FIG. 1 is a flow chart of a coordinate transformation method according to an exemplary embodiment. Figure 6 As shown, the present disclosure provides a method for coordinate transformation, comprising the following steps.
[0073] In step S41, the first coordinate transformation parameter corresponding to each pixel point is calculated according to the distance between each pixel point and the target control.
[0074] In step S42, coordinate transformation is performed on each pixel point based on the first coordinate transformation parameter corresponding to each pixel point.
[0075] In one embodiment, the first coordinate transformation parameter corresponding to each pixel point can be calculated according to the distance between each pixel point and the target control. For example, the first coordinate transformation parameter corresponding to each pixel point can be calculated according to the distance between each pixel point and the center point of the target control, or the first coordinate transformation parameter corresponding to each pixel point can be calculated according to the distance between each pixel point and the outline of the target control. For example, when the target control is a triangle, the outline of the target control represents the three sides of the triangle. The first coordinate transformation parameter can be, for example, a one-dimensional value, assuming A. If the coordinate before the coordinate transformation is (X1, Y1,), then the coordinate after the coordinate transformation is (AX1, AY1). The first coordinate transformation parameter can also be a two-dimensional value, assuming (A, B). If the coordinate before the coordinate transformation is (X1, Y1), then the coordinate after the coordinate transformation is (AX1, BY1). Of course, the present disclosure is only an example, and the coordinates of each pixel point can also be transformed by other forms of first coordinate transformation parameters, which are not limited by the present disclosure.
[0076] In one embodiment, for each pixel point in the first area, the disclosure refers to it as a first pixel point. The smaller the distance between the first pixel point and the target control, the larger the first coordinate transformation parameter corresponding to the first pixel point. For each pixel point in the second area, the disclosure refers to it as a second pixel point. The larger the distance between the second pixel point and the target control, the larger the first coordinate transformation parameter corresponding to the second pixel point. For example, Figure 5 For example, the closer the first pixel point in the first area is to 1, the larger its first coordinate transformation parameter is, and the farther its position after coordinate transformation is from 2, that is, the closer it is to the center of 1, that is, the greater the degree of diffusion. The closer the second pixel point in the second area is to 3, the larger its first coordinate transformation parameter is, and the farther its position after coordinate transformation is from 2, that is, the greater the degree of diffusion.
[0077] The present disclosure determines the first coordinate transformation parameter of the pixel point according to the distance between the pixel point and the target control, so that the farther the pixel point is from the target control, the greater the diffusion degree is, and the effect is more natural.
[0078] In some embodiments, the present disclosure provides a method for calculating coordinate transformation, including: in response to the shape of the target control being a rectangle, calculating the first coordinate transformation parameter corresponding to each pixel point based on the distance between each pixel point and the center pixel point, the center pixel point representing the pixel point at the center position of the target control.
[0079] In one embodiment, when the shape of the target control is a rectangle, the first coordinate transformation parameter corresponding to each pixel point can be calculated according to the distance between each pixel point and the center pixel point of the target control. The center pixel point is the center of the rectangle, which can be understood as the intersection of the diagonal lines of the rectangle. For example, for the first pixel point, the closer it is to the center pixel point, the larger the first coordinate transformation parameter. For the second pixel point, the farther it is from the center pixel point, the larger the first coordinate transformation parameter.
[0080] In one embodiment, the following formula 1 may be referred to to calculate the first coordinate transformation parameter according to the distance between each pixel point and the central pixel point.
[0081]
[0082] Among them, length represents the distance function, that is, taking (X1, Y1) as an example, length(X1, Y1) means adding the square of X1 and the square of X2, and then taking the square root of the sum to get the distance between (X1, Y1) and (0,0). Length((x, y)-centerLoc) means finding the distance between (x, y) and the center pixel. (x, y) represents the coordinates of each pixel, and centerLoc represents the coordinates of the center pixel. halfRect represents half the length of the rectangle side. * represents the multiplication sign. dispersion represents the dispersion parameter. The dispersion parameter can be set according to the actual situation.
[0083] The present disclosure calculates the first coordinate transformation parameter of each pixel point according to the distance from each pixel point to the center point of the rectangle when the shape of the target control is a rectangle, thereby achieving a simpler and more efficient calculation of the first coordinate transformation parameter, thereby more efficiently obtaining the shadow of the target control.
[0084] In some embodiments, the present disclosure provides a method for calculating coordinate transformation, including: in response to a target control being a shape other than a rectangle, calculating a first coordinate transformation parameter corresponding to each pixel point based on the distance between each pixel point and the outline of the target control.
[0085] In one embodiment, when the target control is a shape other than a rectangle, the first coordinate transformation parameter corresponding to each pixel point can be calculated according to the distance between each pixel point and the outline of the target control. For example, when the target control is a triangle, the outline of the target control represents the three sides of the triangle. When the target control is a five-pointed star, the outline of the target control is the two sides on each corner of the five-pointed star. Of course, the triangle and five-pointed star used as examples in this embodiment are only exemplary and not limiting.
[0086] In one embodiment, a second image corresponding to the shape of the target control may be generated according to the outline path of the target control.
[0087] In the present disclosure, when the target control is a shape other than a rectangle, the first coordinate transformation parameter is determined according to the distance between each pixel point and the outline, so as to cope with situations of different shapes.
[0088] In some embodiments, Figure 7 FIG. 1 is a flow chart of a second image generation method according to an exemplary embodiment. Figure 7 As shown, the present disclosure provides a method for generating a second image, comprising the following steps.
[0089] In step S51, a first transparency window is determined from at least one preset transparency window according to shadow parameters, the transparency window includes N×N pixels, each pixel corresponds to a transparency value, the first transparency window corresponds to a rectangular vertex, and N is a positive integer.
[0090] In one embodiment, the first transparency window can be determined from at least one preset transparency window according to the shadow parameter. The shadow parameter can be the shadow radius. The first transparency window can be determined according to the minimum difference between the shadow radius and the window size. For example, assuming that the shadow radius is A, the preset transparency window includes a B×B window and a C×C window. The difference between A and B and the difference between A and C can be calculated respectively. If the difference between A and B is smaller, the B×B window is determined as the first transparency window. Relatively speaking, if the difference between A and C is smaller, the C×C window is determined as the first transparency window. Wherein, × represents a multiplication sign, and the B×B transparency window represents a window of B×B pixels, and each pixel corresponds to a transparency value. For example, for a pixel, there are three channels, namely red (red, R), green (green, G) and blue (blue, B), and the value of each channel determines the color of the pixel. For example, taking the grayscale value of a pixel divided into 256 levels as an example, if the value of each channel is 0, the pixel is black. The transparency value can be used as the fourth channel of the pixel. The transparency value determines the depth of the pixel color. The smaller the transparency value, the lighter the color, and the larger the transparency value, the darker the color. You can achieve a gradient shadow effect by setting the transparency value of each pixel.
[0091] The at least one transparency window preset in this embodiment may include, for example, a 16×16 window, a 32×32 window, etc. Of course, the above is only an example, and the transparency window can be set according to actual conditions, and the present disclosure does not limit it.
[0092] In step S52, a first transparency value of each pixel after coordinate transformation is determined according to the first transparency window.
[0093] In one embodiment, the first transparency window corresponds to the vertex of the rectangle. That is, the vertex with the largest pixel transparency value in the first transparency window is made to correspond to the vertex of the rectangle to obtain the transparency value of each pixel near the vertex. For example, Figure 8 FIG. 1 is a schematic diagram showing a first transparency window application according to an exemplary embodiment. Figure 8 As shown in the figure, the rectangular image on the left represents the target control, and the right represents the second image. In the rectangular image in the middle, except for the darkest part in the middle, the rest of the area is where the pixels are located after the coordinate transformation, and the window superimposed in the lower right corner is the first transparency window. That is, the first transparency window is used to directly determine the transparency value of each pixel after the coordinate transformation near the four vertices. Figure 8 The example here only takes the vertex at the lower right corner as an example. The transparency values of the pixels near the other vertices after the coordinate transformation can refer to this method. For the transparency values of the pixels near the edges of the rectangle after the coordinate transformation, the transparency values of the pixels near the vertices after the coordinate transformation can be referred to. For example, the transparency values of the pixels in the same column are the same. Fig. 9 FIG. 1 is a schematic diagram of a method for determining a transparency value according to an exemplary embodiment. Fig. 9 As shown, a coordinate system can be established with the vertex of the first transparency window as the origin. The transparency value of the pixel in the coordinate system is determined according to the transparency value of the pixel on the coordinate axis. The pixel on the positive half axis of the X axis and the negative half axis of the Y axis are the pixel of the first transparency window. For example, for the pixel A in the first quadrant of the coordinate system, its coordinates are (X1, Y1), and its transparency value is the same as the transparency value of (X1, 0) on the X axis. For the pixel B in the third quadrant of the coordinate system, its coordinates are (X2, Y2), and its transparency value is the same as the transparency value of (0, Y2) on the Y axis. Of course, Fig. 9 The examples shown are merely illustrative and are not intended to be limiting of the present disclosure.
[0094] In step S53, a second image is generated based on the first transparency value.
[0095] In one embodiment, the transparency value of each pixel after the coordinate transformation may be set to the first transparency value to obtain the second image.
[0096] The present disclosure determines the first transparency value of each pixel by determining the first transparency window, which can quickly determine the first transparency value of each pixel and improve efficiency. The first transparency window corresponds to the vertices of the rectangle instead of the entire area to be processed, so it occupies less storage space to save storage resources.
[0097] In some embodiments, Fig.10 FIG. 1 is a flow chart of a second image generation method according to an exemplary embodiment. Fig.10As shown, the present disclosure provides a method for generating a second image, comprising the following steps.
[0098] In step S61, a second transparency value of each pixel after coordinate transformation is determined according to a preset transparency range and a shadow radius.
[0099] In one embodiment, for each pixel point after coordinate transformation, its corresponding transparency value can be calculated for generating a second image. The second transparency value can be determined according to a preset transparency range and shadow radius. If the shadow radius is r, the transparency range is divided into r parts to obtain a second transparency value with a step distribution. For example, if the transparency range is (P, Q), then for the first pixel point after coordinate transformation, the transparency value of the pixel point closest to the center pixel point is P, and the transparency value of the pixel point farthest from the center pixel point is Q. The difference in the second transparency value between adjacent pixels can be referred to as a step amount. The step amount can be generated according to a function (smoothstep) for generating a smooth transition value in a specified orientation. For example, the transparency range and the shadow radius are input into smoothstep to obtain the step amount. Exemplarily, the transparency range can be (0.1, 1), but the present disclosure is not limited to this and can be set according to actual conditions.
[0100] In step S62, the coefficient value of each pixel point after the coordinate transformation is determined according to the distance between each pixel point after the coordinate transformation and the central pixel point.
[0101] In one embodiment, the coefficient value can be determined according to the distance between each pixel point and the central pixel point after the coordinate transformation. The coefficient value is used to adjust the second transparency value. Since the second transparency value is step-like, the shadow area of the obtained second image will have a layered phenomenon, that is, the color depth of the shadow is a step-like transformation phenomenon. The second transparency value can be adjusted by calculating the coefficient value, so that the transparency value of each pixel point is not step-like and is smoother. For example, the coefficient value can be calculated by referring to the following formula 2 and formula 3.
[0102]
[0103] Wherein, distance represents the distance between each pixel point after transformation on the left and the central pixel point, startRadius can be understood as the starting pixel point of the area to be processed, and endRadius can be understood as the ending pixel point of the area to be processed. For example, for the first pixel point in the first area, startRadius represents the pixel point closest to the central pixel point, and endRadius represents the pixel point farthest from the central pixel point. For the second pixel point in the second area, startRadius represents the pixel point farthest from the central pixel point, and endRadius represents the pixel point closest to the central pixel point. Formula 2 is used to normalize the distance between each pixel point and the central pixel point.
[0104]
[0105] Wherein, exp() represents an exponential function with the natural constant e as the base. The magnitude of e is about 2.72. currentPos represents the calculation result in Formula 2, that is, the normalized distance between each pixel and the center pixel. δ represents the adjustment coefficient. For example, it can be 0.5, but this disclosure does not limit it and can be set according to actual conditions.
[0106] In step S63, the second transparency value of each pixel after the coordinate transformation is multiplied by the coefficient value to obtain a third transparency value of each pixel after the coordinate transformation.
[0107] In one embodiment, the second transparency value of each pixel after coordinate transformation and the corresponding coefficient value may be multiplied to obtain a third transparency value. Compared with the second transparency value, the third transparency value is more dispersed rather than stepped, so that the shadow area of the obtained second image has a smoother effect.
[0108] In step S64, a second image is obtained based on each pixel point after coordinate transformation whose transparency is the third transparency value.
[0109] In one embodiment, the second image is obtained based on the pixels in the third image that have not undergone coordinate transformation and the pixels that have undergone coordinate transformation and whose transparency value is the third transparency value. That is, the shadow area included in the second image corresponds to the pixels that have undergone coordinate transformation and whose transparency value is the third transparency value. The non-shadow area included in the second image corresponds to the pixels in the third image that have not undergone coordinate transformation.
[0110] The present disclosure calculates the third transparency value of each pixel point after coordinate transformation in real time. Since the third transparency value is calculated in real time, the result is more flexible and accurate, and the shadow area of the obtained second image has a better effect. Since the third transparency value is the result of multiplying the second transparency value and the coefficient value, the shadow area of the obtained second image is smoother.
[0111] In some embodiments, Fig.11 FIG. 1 is a flow chart of a second image generation method according to an exemplary embodiment. Fig.11 As shown, the present disclosure provides a method for generating a second image, comprising the following steps.
[0112] In step S71, a fifth transparency value is obtained.
[0113] In one embodiment, the fifth transparency value is a randomly generated transparency value. For example, a random number may be generated within a preset transparency range. That is, the generated random number is within the preset transparency range.
[0114] In step S72, the transparency value of the third pixel in the second image is replaced by the fifth transparency value.
[0115] In one embodiment, the transparency value of any one or more pixels in the shadow area of the second image can be replaced with the fifth transparency value. In the present disclosure, any one or more pixels in the shadow area of the second image are referred to as third pixels. It can be understood that noise is added to the shadow area of the second image. If there is still a step distribution phenomenon between adjacent pixels in the shadow area of the second image, the step distribution phenomenon can be eliminated by adding noise, that is, by replacing the transparency value of the pixel with the fifth transparency value.
[0116] In step S73, a shadow is generated in the area where the target control is located based on the second image after the transparency value is replaced.
[0117] In one embodiment, the second image with the replaced transparency value may be superimposed below the target control. The specific implementation and method may refer to the embodiment of step S22 above, and the disclosure will not be repeated here.
[0118] The present disclosure replaces the transparency value of any one or more pixel points in the shadow area of the second image with a randomly generated fifth transparency value, thereby achieving a smoother shadow area of the second image and a better effect.
[0119] Based on the same concept, an embodiment of the present disclosure also provides a shadow generating device.
[0120] It is understandable that the shadow generating device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.
[0121] Fig.12 FIG. 1 is a block diagram of a shadow generating device 100 according to an exemplary embodiment. Fig.12 The device 100 includes: an acquisition module 101 and a processing module 102.
[0122] The acquisition module 101 is used to acquire the shadow parameters of the target control; the processing module 102 is used to generate a shadow in the area where the target control is located according to the shadow parameters, and the shadow is diffusely distributed.
[0123] In one embodiment, the processing module 102 generates a shadow in the area where the target control is located using the shadow parameter in the following manner: based on the target control and the shadow parameter, a second image is determined, the second image includes a shadow area and a non-shadow area, and the pixel density of the shadow area is lower than the pixel density of the non-shadow area. Based on the second image, a shadow is generated in the area where the target control is located.
[0124] In one embodiment, the shadow parameters include a shadow radius, and the processing module 102 determines the second image based on the target control and the shadow parameters in the following manner: compressing the inside of the target control based on the shadow radius to obtain a third image. Expanding the outside of the target control based on the shadow radius to obtain a fourth image. The first area between the target control and the third image, and the second area between the target control and the fourth image, are determined as the area to be processed corresponding to the target control. Coordinate transformation is performed on each pixel point in the area to be processed, and the coordinate transformation is used to transform the coordinates of each pixel point in the first area to within the third image, and transform the coordinates of each pixel point in the second area to outside the fourth image. The second image is generated based on each pixel point after the coordinate transformation, wherein each pixel point after the coordinate transformation corresponds to the shadow area in the second image.
[0125] In one embodiment, the processing module 102 transforms the coordinates of each pixel point in the area to be processed in the following manner: according to the distance between each pixel point and the target control, the first coordinate transformation parameter corresponding to each pixel point is calculated. The smaller the distance between the first pixel point in the first area and the target control, the larger the first coordinate transformation parameter corresponding to the first pixel point. The larger the distance between the second pixel point in the second area and the target control, the larger the first coordinate transformation parameter corresponding to the second pixel point. Based on the first coordinate transformation parameter corresponding to each pixel point, coordinate transformation is performed on each pixel point.
[0126] In one embodiment, the processing module 102 calculates the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the target control in the following manner: in response to the shape of the target control being a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated according to the distance between each pixel point and the center pixel point, and the center pixel point represents the pixel point at the center position of the target control.
[0127] In one embodiment, the processing module 102 calculates the first coordinate transformation parameter corresponding to each pixel point based on the distance between each pixel point and the center pixel point in the following manner: in response to the target control being a shape other than a rectangle, the first coordinate transformation parameter corresponding to each pixel point is calculated based on the distance between each pixel point and the outline of the target control.
[0128] In one embodiment, the processing module 102 generates the second image based on each pixel after the coordinate transformation in the following manner: according to the shadow parameter, a first transparency window is determined from at least one preset transparency window, the transparency window includes N×N pixels, each pixel corresponds to a transparency value, the first transparency window corresponds to a rectangular vertex, and N is a positive integer. According to the first transparency window, a first transparency value of each pixel after the coordinate transformation is determined. Based on the first transparency value, the second image is generated.
[0129] In one embodiment, the shadow parameter includes a shadow radius, and the processing module 102 generates the shadow of the second image based on each pixel after the transformation in the following manner: according to a preset transparency range and a shadow radius, a second transparency value of each pixel after the coordinate transformation is determined. According to the distance between each pixel after the coordinate transformation and the central pixel, a coefficient value of each pixel after the coordinate transformation is determined. The second transparency value of each pixel after the coordinate transformation and the coefficient value are multiplied to obtain a third transparency value of each pixel after the coordinate transformation. Based on each pixel after the coordinate transformation whose transparency is the third transparency value, the second image is obtained.
[0130] In one embodiment, the processing module 102 obtains the shadow of the target control based on the second image in the following manner: obtain a fifth transparency value, where the fifth transparency value is a randomly generated transparency value. Replace the transparency value of the third pixel in the second image with the fifth transparency value. Based on the second image after the transparency value is replaced, generate a shadow in the area where the target control is located. The third pixel represents any one or more pixels in the shadow area.
[0131] Fig.13 is a block diagram of a shadow generating device 200 according to an exemplary embodiment.
[0132] like Fig.13 As shown, apparatus 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .
[0133] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.
[0134] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0135] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.
[0136] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0137] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.
[0138] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0139] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0140] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0141] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0142] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0143] The present disclosure obtains shadow parameters of a target control, and generates a shadow in the area where the target control is located according to the shadow parameters. The shadow is diffusely distributed to make the effect more natural.
[0144] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar thereto. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.
[0145] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.
[0146] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0147] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0148] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
Claims
1. A shadow generation method, characterized in that: include: Get the shadow parameters of the target control; According to the shadow parameters, a shadow is generated in the area where the target control is located, and the shadow is diffusely distributed.
2. The method according to claim 1, characterized in that Generating a shadow in the area where the target control is located according to the shadow parameter includes: Based on the target control and the shadow parameter, determining a second image, wherein the second image includes a shadow area and a non-shadow area, and a pixel density of the shadow area is lower than a pixel density of the non-shadow area; Based on the second image, a shadow is generated in the area where the target control is located.
3. The method according to claim 2, characterized in that The shadow parameter includes a shadow radius, and determining the second image based on the target control and the shadow parameter includes: Compressing inside the target control based on the shadow radius to obtain a third image; Expanding outside the target control based on the shadow radius to obtain a fourth image; Determine a first area between the target control and the third image, and a second area between the target control and the fourth image, as areas to be processed corresponding to the target control; Performing coordinate transformation on each pixel point in the area to be processed, wherein the coordinate transformation is used to transform the coordinates of each pixel point in the first area to within the third image, and transform the coordinates of each pixel point in the second area to outside the fourth image; The second image is generated based on each pixel point after coordinate transformation, wherein each pixel point after coordinate transformation corresponds to a shadow area in the second image.
4. The method according to claim 3, characterized in that The coordinate transformation of each pixel point in the area to be processed includes: Calculate the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the target control; The smaller the distance between the first pixel point of the first area and the target control, the larger the first coordinate transformation parameter corresponding to the first pixel point; The larger the distance between the second pixel point in the second area and the target control is, the larger the first coordinate transformation parameter corresponding to the second pixel point is; Based on the first coordinate transformation parameters corresponding to the pixel points, coordinate transformation is performed on the pixel points.
5. The method according to claim 4, characterized in that The calculating the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the target control includes: In response to the shape of the target control being a rectangle, a first coordinate transformation parameter corresponding to each pixel point is calculated according to the distance between each pixel point and a central pixel point, wherein the central pixel point represents a pixel point at the center position of the target control.
6. The method according to claim 4, characterized in that The calculating the first coordinate transformation parameter corresponding to each pixel point according to the distance between each pixel point and the central pixel point includes: In response to the target control being a shape other than a rectangle, a first coordinate transformation parameter corresponding to each pixel point is calculated according to a distance between each pixel point and a contour of the target control.
7. The method according to claim 5, characterized in that The generating the second image based on each pixel after coordinate transformation includes: According to the shadow parameter, determine a first transparency window from at least one preset transparency window, the transparency window includes N×N pixels, each pixel corresponds to a transparency value, the first transparency window corresponds to a rectangular vertex, and N is a positive integer; Determining a first transparency value of each pixel after coordinate transformation according to the first transparency window; Based on the first transparency value, the second image is generated.
8. The method according to claim 3, characterized in that The shadow parameter includes a shadow radius, and the step of generating the shadow of the second image based on each pixel after the transformation includes: Determining a second transparency value of each pixel after coordinate transformation according to a preset transparency range and the shadow radius; Determine the coefficient value of each pixel point after coordinate transformation according to the distance between each pixel point after coordinate transformation and the central pixel point; Multiplying the second transparency value of each pixel after the coordinate transformation and the coefficient value to obtain a third transparency value of each pixel after the coordinate transformation; The second image is obtained based on each pixel point after coordinate transformation whose transparency is the third transparency value.
9. The method according to claim 2, characterized in that: The obtaining the shadow of the target control based on the second image includes: Acquire a fifth transparency value, where the fifth transparency value is a randomly generated transparency value; Replacing the transparency value of a third pixel in the second image with the fifth transparency value; Based on the second image after replacing the transparency value, generating a shadow in the area where the target control is located; The third pixel point represents any one or more pixel points in the shadow area.
10. A shadow generating device, characterized in that: include: The acquisition module is used to obtain the shadow parameters of the target control; The processing module is used to generate a shadow in the area where the target control is located according to the shadow parameters, and the shadow is diffusely distributed.
11. An electronic device, characterized in that: include: A memory for storing instructions; as well as A processor, configured to call the instructions stored in the memory to execute the method according to any one of claims 1 to 9.
12. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions are executed by the processor, the method according to any one of claims 1 to 9 is executed.