Gradient color background rendering method and device, storage medium and computer equipment
By receiving the parent component's property object, generating and adjusting the style object of the gradient background, the problem of repetitive gradient background code in web development is solved, and the flexibility and scalability are improved.
Patent Information
- Application Number
- CN202411235295.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-11-26
AI Technical Summary
In web development, writing gradient styles directly in HTML or CSS files leads to code duplication, making it difficult to track and manage, and limiting the flexibility and scalability of gradient backgrounds.
By receiving the attribute object passed from the parent component, the rendering parameters are obtained, an initial style object is generated, and adjustments are made based on the visual effect parameters. The slot content is detected, the target style object is updated, and finally returned to the parent component for application.
It avoids code duplication outside the parent component, improves the flexibility and scalability of gradient backgrounds, supports seamless integration of slot content, and simplifies style management.
Smart Images

Figure CN119027356A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a gradient color background rendering method, device, storage medium and computer equipment. Background Art
[0002] In the field of web development, especially when building large applications using modern front-end frameworks such as Vue.js, elegantly managing and applying visual styles of interface elements, such as background gradient effects, is crucial to improving user experience. However, as the scale of the project increases, hard-coding CSS gradient styles directly inside components gradually exposes multiple challenges.
[0003] For example, when multiple elements in a project need to use the same gradient background, if the gradient style is written directly through CSS on each element, it will lead to a lot of code duplication. As the project expands, the gradient styles written directly in HTML or CSS files become difficult to track and manage, resulting in limited flexibility and scalability of the gradient background. Summary of the invention
[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the technical defect that the gradient style directly written in the HTML or CSS file in the prior art is difficult to track and manage, resulting in limited flexibility and scalability of the subsequent gradient color background.
[0005] The present application provides a gradient color background rendering method, the method comprising:
[0006] Receive the property object passed by the parent component, and obtain the rendering parameters of the rendering object in the property object; the rendering parameters include basic gradient parameters and visual effect parameters;
[0007] generating an initial style object of the rendering object according to the basic gradient parameters, and adjusting the style of the initial style object based on the visual effect parameters to obtain a target style object;
[0008] Performing slot detection on the rendering object, and when detecting that the rendering object has slot content, rendering the slot content into the target style object to update the target style object;
[0009] The target style object is returned to the parent component, so that the parent component applies the target style object to the rendering object.
[0010] Optionally, generating the initial style object of the rendering object according to the basic gradient parameters includes:
[0011] Determine a starting color and an ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to a gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation result.
[0012] Optionally, the performing style adjustment on the initial style object based on the visual effect parameter to obtain a target style object includes:
[0013] Determining attribute parameter values corresponding to various visual effect attributes according to the visual effect parameters, and adjusting parameters of various visual effect attributes in the initial style object according to the various attribute parameter values to obtain a target style object;
[0014] Among them, the visual effect attributes include gradient center point, gradient transparency, gradient shape, and gradient animation effect.
[0015] Optionally, determining the attribute parameter value corresponding to each visual effect attribute according to the visual effect parameter includes:
[0016] For each visual effect attribute, determining whether a parameter value of the visual effect attribute exists in the visual effect parameters;
[0017] If yes, obtaining the parameter value of the visual effect attribute from the visual effect parameter as the attribute parameter value corresponding to the visual effect attribute;
[0018] If not, the default value of the visual effect attribute is read as the attribute parameter value corresponding to the visual effect attribute.
[0019] Optionally, the performing slot detection on the rendering object includes:
[0020] Determine whether the rendering object is a custom named slot;
[0021] If so, confirm that the rendering object is a slot object, and obtain the slot content of the slot object;
[0022] If not, it is confirmed that the rendering object is an element object; and the element object does not have slot content.
[0023] Optionally, rendering the slot content into the target style object includes:
[0024] Determine a rendering position and a rendering style of the slot content, and render the slot content into the target style object according to the rendering position and the rendering style.
[0025] The present application also provides a gradient color background rendering device, comprising:
[0026] A parameter acquisition module, used to receive the attribute object passed by the parent component, and obtain the rendering parameters of the rendering object in the attribute object; the rendering parameters include basic gradient parameters and visual effect parameters;
[0027] An object generation module, configured to generate an initial style object of the rendering object according to the basic gradient parameters, and to adjust the style of the initial style object based on the visual effect parameters to obtain a target style object;
[0028] An object updating module, configured to perform slot detection on the rendering object, and when detecting that the rendering object has slot content, render the slot content into the target style object to update the target style object;
[0029] The object application module is used to return the target style object to the parent component, so that the parent component applies the target style object to the rendering object.
[0030] Optionally, the object generation module includes:
[0031] The gradient calculation submodule is used to determine the starting color and the ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to the gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation results.
[0032] The present application also provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the gradient background rendering method as described in any one of the above embodiments.
[0033] The present application also provides a computer device, comprising: one or more processors, and a memory;
[0034] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the gradient color background rendering method described in any one of the above embodiments are performed.
[0035] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0036] The gradient background rendering method, device, storage medium and computer equipment provided by the present application can obtain the rendering parameters of the rendering object in the attribute object after receiving the attribute object passed by the parent component. Here, by implementing the gradient background rendering outside the parent component, the repeated stacking of rendering codes in the parent component can be avoided, and the difficulty of subsequent rendering style management can be reduced; because the rendering parameters include basic gradient parameters and visual effect parameters, the initial style object of the rendering object can be generated according to the basic gradient parameters, and the style of the initial style object is adjusted based on the visual effect parameters to obtain the target style object, so that a rich and diverse visual layout can be provided, thereby enhancing the flexibility and scalability of the gradient background; secondly, the present application can also perform slot detection on the rendering object, and when it is detected that the rendering object has custom slot content, the slot content is rendered into the target style object to update the target style object. The slot mechanism is utilized here, so that the gradient background can be seamlessly integrated with the slot content, further improving the flexibility and scalability of the gradient background. Finally, the target style object can be returned to the parent component so that the parent component applies the target style object to the rendering object; therefore, the present application can abstract the gradient background rendering method and encapsulate it into a reusable component, and apply it to the parent component, so that the updating and adjustment of the rendering style can be completed in a single location, thereby improving the flexibility and scalability of the gradient background. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0038] Figure 1 A schematic diagram of a flow chart of a gradient color background rendering method provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of the structure of a gradient color background rendering device provided in an embodiment of the present application;
[0040] Figure 3 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0042] When multiple elements in a project need to use the same gradient background, writing the gradient style directly through CSS on each element will result in a lot of code duplication. As the project expands, the gradient styles written directly in HTML or CSS files become difficult to track and manage, resulting in limited flexibility and scalability of the gradient background.
[0043] Based on this, this application proposes the following technical solutions, see below for details:
[0044] In one embodiment, Figure 1 As shown, Figure 1 A flowchart of a gradient color background rendering method provided in an embodiment of the present application; the present application provides a gradient color background rendering method, which specifically includes the following:
[0045] S110: Receive the property object passed by the parent component, and obtain rendering parameters of the rendering object in the property object; the rendering parameters include basic gradient parameters and visual effect parameters.
[0046] In this step, when the user needs to render a gradient background for a rendering element in the front-end page, the user can set the rendering parameters corresponding to the rendering element in the computer device, so that the computer device can package the rendering parameters into an attribute object through the parent component, and then pass the attribute object to the rendering component, so that the rendering component can obtain the rendering parameters of the rendering object in the attribute object to realize gradient background rendering outside the parent component, avoid repeated stacking of rendering codes in the parent component, and reduce the difficulty of subsequent gradient style management.
[0047] Among them, the parent component refers to the component responsible for containing or calling other child components in the component-based development architecture. In this application, the rendering component belongs to the child component of the parent component. Therefore, the parent component can pass rendering parameters to the rendering component through the attribute object, and then manage the rendering and behavior of the rendering component. The rendering parameters passed by the parent component here may include basic gradient parameters and visual effect parameters; in detail, the basic gradient parameters are used to define the basic properties of the gradient background, which determines the initial appearance of the gradient. It can include properties such as the starting color, the ending color, and the gradient direction; the visual effect parameters are used to further adjust and optimize the visual effects based on the basic gradient. It can include properties such as the gradient center point, gradient transparency, gradient shape, and gradient animation effects.
[0048] It is understandable that the present application can encapsulate rendering logic and parameters in the rendering component, so that the parent component can focus more on its own logic and state management without having to worry about specific rendering details, and keep the code in the parent component clear and maintainable; if multiple elements in the front-end page need to display the same gradient background, the computer device only needs to pass different parameters to the same rendering component in the corresponding parent component, without having to repeatedly write the same rendering code in the corresponding position of each element in the parent component. In short, the parent component can dynamically generate rendering parameters according to different conditions and pass them to the rendering component, thereby realizing complex rendering logic, improving the flexibility of gradient background rendering, and reducing the difficulty of subsequent gradient style management.
[0049] S120: Generate an initial style object of the rendering object according to the basic gradient parameters, and adjust the style of the initial style object based on the visual effect parameters to obtain a target style object.
[0050] In this step, after obtaining the rendering parameters of the rendering element through step S110, the rendering component can first generate an initial style object of the rendering object according to the basic gradient parameters of the rendering parameters, so as to obtain the initial appearance of the gradient background; then the rendering component can adjust the style of the initial style object based on the visual effect parameters to obtain the target style object to improve the visual effect of the gradient background.
[0051] It is understandable that when rendering a gradient background, the rendering component can first generate an initial style object of the rendering object according to the basic gradient parameters in the received rendering parameters to determine the basic appearance of the gradient background and the path of color change, and obtain an initial gradient background effect. The rendering component can then make further adjustments to this initial style object based on the visual effect parameters, and achieve more refined control over the gradient background by refining the rendering component parameters. The present application can not only provide a basic gradient background effect through a staged rendering process, but also make richer style adjustments on this basis to generate the final target style object; at the same time, this rendering method also improves the flexibility and scalability of the gradient background, so that it can adapt to different design requirements and easily make subsequent adjustments and expansions.
[0052] S130: Performing slot detection on the rendering object, and when detecting that the rendering object has slot content, rendering the slot content into the target style object to update the target style object.
[0053] In this step, after obtaining the target style object of the rendering object through step S120, the rendering component can also perform slot detection on the rendering object, and when it is detected that the rendering object has slot content, the slot content is rendered into the target style object to update the target style object. By using the slot mechanism here, the gradient background can be seamlessly integrated with the slot content, further improving the flexibility and scalability of the gradient background.
[0054] The core idea of the slot is to render the customized slot content to a certain position on the front-end page. The slot content here can be any element or component that the parent component can support, such as text, pictures or other components, so as to achieve more flexible component combination and reuse, thereby improving the flexibility and scalability of the gradient background.
[0055] It is understandable that after generating the target style object of the rendering object, the rendering component can also perform slot detection on the rendering object to identify whether it contains slot content, ensuring that the rendering component can accurately process and render dynamic content from the parent component. Once the presence of slot content in the rendering object is detected, the rendering component can insert the rendering content into the target style object, so that the slot content can be naturally integrated with the background gradient effect to enhance visual coherence. Therefore, through the slot mechanism, the reusability and adaptability of the rendering component can be improved in this application, so that the custom slot content can be integrated into the gradient background according to different needs, further improving the flexibility and scalability of the gradient background.
[0056] S140: Return the target style object to the parent component, so that the parent component applies the target style object to the rendering object.
[0057] In this embodiment, after the rendering component generates the final target style object for the rendering object, the target style object can be returned to the parent component so that the parent component applies the target style object to the rendering object, thereby completing the update and adjustment of the rendering style in a single location, thereby improving the flexibility and scalability of the gradient background.
[0058] It is understandable that when the rendering component calculates and generates the final target style object, it combines all the basic gradient parameters and visual effect parameters to ensure the visual consistency and dynamic effect of the gradient background. The generated target style object contains all the necessary style information, such as gradient color, transparency, gradient direction, and the integration of slot content, forming a complete style definition. The rendering component can then return the generated target style object to the parent component so that the parent component can apply it to the corresponding rendering object, making style management more centralized and efficient. The parent component only needs to process the style update once and apply the updated gradient style to the rendering object without having to repeat adjustments in multiple places; by centrally processing the gradient style in this way, the parent component can easily cope with various design requirements, while achieving more complex and diverse visual effects while reducing management complexity, greatly improving the flexibility and scalability of the gradient background.
[0059] In the above embodiment, after receiving the attribute object passed by the parent component, the rendering parameters of the rendering object in the attribute object can be obtained. Here, by implementing the gradient background rendering outside the parent component, the repeated stacking of rendering codes in the parent component can be avoided, and the difficulty of subsequent rendering style management can be reduced; since the rendering parameters include basic gradient parameters and visual effect parameters, the initial style object of the rendering object can be generated according to the basic gradient parameters, and the style of the initial style object can be adjusted based on the visual effect parameters to obtain the target style object, so that a rich and diverse visual layout can be provided, thereby enhancing the flexibility and scalability of the gradient background; secondly, the present application can also perform slot detection on the rendering object, and when it is detected that the rendering object has custom slot content, the slot content is rendered into the target style object to update the target style object. The slot mechanism is utilized here, so that the gradient background can be seamlessly integrated with the slot content, further improving the flexibility and scalability of the gradient background. Finally, the target style object can be returned to the parent component so that the parent component applies the target style object to the rendering object; therefore, the present application can abstract the gradient background rendering method and encapsulate it into a reusable component, and apply it to the parent component, so that the updating and adjustment of the rendering style can be completed in a single location, thereby improving the flexibility and scalability of the gradient background.
[0060] In one embodiment, generating an initial style object for the rendering object according to the basic gradient parameters in step S120 may include:
[0061] S121: Determine a starting color and an ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to the gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation result.
[0062] In this embodiment, when generating an initial style object for a rendering object, the rendering component may first determine the starting color and the ending color in the basic gradient parameters, then perform a gradient calculation on the starting color and the ending color according to the gradient direction in the basic gradient parameters, and generate the initial style object for the rendering object based on the calculation results, thereby obtaining the initial appearance of the gradient background.
[0063] The start color refers to the color at the beginning of the gradient, which specifies the starting color of the gradient effect; the end color refers to the color at the end of the gradient, which specifies the end color of the gradient effect. The gradient direction determines the path of color change, affecting how the gradient color transitions from the start color to the end color. The gradient direction can be linear, such as from top to bottom or from left to right, or diagonal, such as from top left to bottom right or from top right to bottom left. It can also be a user-defined angle and direction for gradient, which is not limited here.
[0064] It is understandable that the starting color, ending color and gradient direction are the core attributes of the basic gradient parameters. To expand on this, the starting color and ending color define the starting and ending points of the gradient, representing the beginning and ending states of the gradient background; the starting color is usually the initial hue of the gradient, while the ending color is the final hue of the gradient, which together determine the basic visual characteristics of the gradient effect. In addition, through the gradient direction, the method and path of color transition in the gradient background can be clearly guided, thereby ensuring that the gradient effect meets expectations.
[0065] In one embodiment, in step S120, adjusting the style of the initial style object based on the visual effect parameter to obtain the target style object may include:
[0066] S122: Determine attribute parameter values corresponding to various visual effect attributes according to the visual effect parameters, and adjust parameters of various visual effect attributes in the initial style object according to the attribute parameter values to obtain a target style object.
[0067] In this embodiment, when the rendering component adjusts the style of the initial style object, it can first determine the attribute parameter values corresponding to each visual effect attribute based on the visual effect parameters, and adjust the parameters of each visual effect attribute in the initial style object according to the attribute parameter values to obtain the target style object, thereby improving the visual effect of the gradient background.
[0068] Among them, the visual effect attributes include but are not limited to the gradient center point, gradient transparency, gradient shape, and gradient animation effect. To elaborate, the gradient center point refers to the center point between the starting color and the ending color in the gradient color background, which determines the proportion of the two colors in the gradient color background; the gradient transparency refers to the transparency setting of the color in the gradient effect, which determines the degree of transparency change of the color in the gradient; the gradient shape defines the form of the gradient, which determines the distribution pattern of the gradient color; the gradient animation effect refers to adding dynamic effects to the gradient color background to increase the visual sense of dynamics and liveliness.
[0069] It is understandable that the visual effect attribute is composed of multiple attributes, and the rendering component can accurately set or adjust the parameters of each attribute in the visual effect attribute of the initial style object based on the visual effect parameters, such as adjusting the center point position between two colors in the gradient color, adjusting the transparency range of the gradient color, selecting an appropriate gradient shape and animation effect, etc., so as to change the visual effect of the gradient color background. Therefore, the rendering component can adjust the gradient color background of the rendering object in real time according to specific needs, thereby improving the flexibility and scalability of the gradient color background.
[0070] In one embodiment, determining the attribute parameter value corresponding to each visual effect attribute according to the visual effect parameter in step S122 may include:
[0071] S1221: For each visual effect attribute, determine whether a parameter value of the visual effect attribute exists in the visual effect parameters.
[0072] S1222: If yes, obtain the parameter value of the visual effect attribute from the visual effect parameter as the attribute parameter value corresponding to the visual effect attribute.
[0073] S1223: If not, read the default value of the visual effect attribute as the attribute parameter value corresponding to the visual effect attribute.
[0074] In this embodiment, when the rendering component determines the attribute parameter value corresponding to each visual effect attribute, for each visual effect attribute, the rendering component can determine whether there is a parameter value of the visual effect attribute in the visual effect parameters, and then determine the attribute parameter value corresponding to the visual effect attribute in the rendering object based on the judgment result.
[0075] It is understandable that since the visual effect parameters further adjust the visual effect of the gradient background of the rendered object, they are not necessary attributes for generating the target style object. Therefore, the user can set the parameter values of the corresponding visual effect attributes according to actual needs, and then pass them to the rendering component through the parent component, so that the rendering component can adjust the style of the initial style object of the rendered object according to the various parameter values.
[0076] Specifically, for each visual effect attribute, if the parameter value of the visual effect attribute exists in the visual effect parameters, the rendering component can obtain the parameter value of the visual effect attribute from the visual effect parameters, and use it as the attribute parameter value corresponding to the visual effect attribute and make corresponding adjustments to the initial style object; if the parameter value of the visual effect attribute does not exist in the visual effect parameters, the rendering component can read the default value of the visual effect attribute, and use it as the attribute parameter value corresponding to the visual effect attribute. Generally, the default value is the initial value of the initial style object, that is, the rendering object does not need to adjust the parameters of the visual effect attribute in the rendering object.
[0077] In one embodiment, performing slot detection on the rendering object in step S130 may include:
[0078] S131: Determine whether the rendering object is a custom named slot.
[0079] S132: If yes, confirm that the rendering object is a slot object, and obtain the slot content of the slot object.
[0080] S133: If not, confirm that the rendering object is an element object; the element object does not have slot content.
[0081] In this embodiment, when the rendering component performs slot detection on the rendering object, it can first determine whether the rendering object is a custom named slot. If so, it means that the rendering object is a slot object, and the rendering device can obtain the slot content of the slot object; if not, it means that the rendering object is an element object, so there is no slot content in the element object.
[0082] It is understandable that the rendering component can also perform slot detection on the rendering object to determine whether the rendering object contains slot content. Specifically, the purpose of slot detection is to distinguish whether the rendering object is a named slot or an ordinary element object. The named slot here refers to a slot with a name used in the architecture, which allows the parent component to pass content to a specific area of the child component; if the rendering object is detected as a custom named slot, it means that it is a slot object that contains the slot content provided by the parent component. Therefore, the rendering component can extract and render the slot content in the target style object. If the rendering object is not a named slot, it is an ordinary element object, which refers to a standard HTML element or component element that does not contain slot content. Therefore, the rendering component does not need to further render the target style object of the rendering object.
[0083] In one embodiment, rendering the slot content into the target style object in step S130 may include:
[0084] S134: Determine the rendering position and rendering style of the slot content, and render the slot content into the target style object according to the rendering position and rendering style.
[0085] In this embodiment, when rendering the slot content into the target style object, the rendering component may first determine the rendering position and rendering style of the slot content, and then render the slot content into the target style object according to the rendering position and rendering style.
[0086] Specifically, when the rendering component needs to render the slot content into the target style object, it can first parse the slot content from the property object to obtain the rendering position and rendering style. Among them, the rendering position determines the specific display area of the slot content in the target style object, and the rendering style defines the visual representation of the slot content, including font, color, size, alignment and other details. The rendering component then uses the rendering style to accurately insert the slot content into the rendering position in the target style object, so that the slot content can be seamlessly integrated with the target style object and coordinated with the overall visual effect. In this way, the rendering component can flexibly and seamlessly integrate the slot content passed by the parent component into the target style object, further enhancing the customizability and visual consistency of the gradient background.
[0087] The following describes a gradient color background rendering device provided in an embodiment of the present application. The gradient color background rendering device described below and the gradient color background rendering method described above can refer to each other.
[0088] In one embodiment, Figure 2 As shown, Figure 2 A schematic diagram of a gradient color background rendering device provided in an embodiment of the present application; the present application also provides a gradient color background rendering device, including a parameter acquisition module 210, an object generation module 220, an object update module 230 and an object application module 240, specifically including the following:
[0089] The parameter acquisition module 210 is used to receive the attribute object transmitted by the parent component and obtain the rendering parameters of the rendering object in the attribute object; the rendering parameters include basic gradient parameters and visual effect parameters.
[0090] The object generation module 220 is used to generate an initial style object of the rendering object according to the basic gradient parameters, and adjust the style of the initial style object based on the visual effect parameters to obtain a target style object.
[0091] The object updating module 230 is used to perform slot detection on the rendering object, and when it is detected that the rendering object has slot content, render the slot content into the target style object to update the target style object.
[0092] The object application module 240 is used to return the target style object to the parent component, so that the parent component applies the target style object to the rendering object.
[0093] In the above embodiment, after receiving the attribute object passed by the parent component, the rendering parameters of the rendering object in the attribute object can be obtained. Here, by implementing the gradient background rendering outside the parent component, the repeated stacking of rendering codes in the parent component can be avoided, and the difficulty of subsequent rendering style management can be reduced; since the rendering parameters include basic gradient parameters and visual effect parameters, the initial style object of the rendering object can be generated according to the basic gradient parameters, and the style of the initial style object can be adjusted based on the visual effect parameters to obtain the target style object, so that a rich and diverse visual layout can be provided, thereby enhancing the flexibility and scalability of the gradient background; secondly, the present application can also perform slot detection on the rendering object, and when it is detected that the rendering object has custom slot content, the slot content is rendered into the target style object to update the target style object. The slot mechanism is utilized here, so that the gradient background can be seamlessly integrated with the slot content, further improving the flexibility and scalability of the gradient background. Finally, the target style object can be returned to the parent component so that the parent component applies the target style object to the rendering object; therefore, the present application can abstract the gradient background rendering method and encapsulate it into a reusable component, and apply it to the parent component, so that the updating and adjustment of the rendering style can be completed in a single location, thereby improving the flexibility and scalability of the gradient background.
[0094] In one embodiment, the object generation module 210 may include:
[0095] The gradient calculation submodule is used to determine the starting color and the ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to the gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation results.
[0096] In one embodiment, the object generation module 210 may further include:
[0097] A parameter adjustment submodule is used to determine the attribute parameter value corresponding to each visual effect attribute according to the visual effect parameter, and adjust the parameters of each visual effect attribute in the initial style object according to each attribute parameter value to obtain a target style object;
[0098] Among them, the visual effect attributes include gradient center point, gradient transparency, gradient shape, and gradient animation effect.
[0099] In one embodiment, the parameter adjustment submodule may include:
[0100] The parameter value determination unit is used to determine, for each visual effect attribute, whether a parameter value of the visual effect attribute exists in the visual effect parameters.
[0101] The first determining unit is used to obtain, when present, a parameter value of the visual effect attribute from the visual effect parameter as an attribute parameter value corresponding to the visual effect attribute.
[0102] The second determining unit is used to read a default value of the visual effect attribute as an attribute parameter value corresponding to the visual effect attribute when the default value does not exist.
[0103] In one embodiment, the object update module 230 may include:
[0104] The slot judgment submodule is used to determine whether the rendering object is a custom named slot.
[0105] The first confirmation submodule is used to confirm that the rendering object is a slot object when the rendering object is a custom named slot, and obtain the slot content of the slot object.
[0106] The second confirmation submodule is used to confirm that the rendering object is an element object when the rendering object is not a custom named slot; the element object does not have slot content.
[0107] In one embodiment, the object update module 230 may further include:
[0108] The slot content rendering submodule is used to determine the rendering position and rendering style of the slot content, and render the slot content into the target style object according to the rendering position and rendering style.
[0109] In one embodiment, the present application also provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the gradient background rendering method described in any of the above embodiments.
[0110] In one embodiment, the present application also provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the gradient background rendering method as described in any one of the above embodiments.
[0111] Indicatively, Figure 3 As shown, Figure 3 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 3The computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions executable by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the gradient background rendering method of any of the above embodiments.
[0112] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0113] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0114] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0115] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0116] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A gradient color background rendering method, It is characterized in that The method comprises: Receive the property object passed by the parent component, and obtain the rendering parameters of the rendering object in the property object; the rendering parameters include basic gradient parameters and visual effect parameters; generating an initial style object of the rendering object according to the basic gradient parameters, and adjusting the style of the initial style object based on the visual effect parameters to obtain a target style object; Performing slot detection on the rendering object, and when detecting that the rendering object has slot content, rendering the slot content into the target style object to update the target style object; The target style object is returned to the parent component, so that the parent component applies the target style object to the rendering object.
2. The gradient color background rendering method according to claim 1, It is characterized in that The step of generating the initial style object of the rendering object according to the basic gradient parameters includes: Determine a starting color and an ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to a gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation result.
3. The gradient color background rendering method according to claim 1, It is characterized in that The step of adjusting the style of the initial style object based on the visual effect parameter to obtain a target style object includes: Determining attribute parameter values corresponding to various visual effect attributes according to the visual effect parameters, and adjusting parameters of various visual effect attributes in the initial style object according to the various attribute parameter values to obtain a target style object; Among them, the visual effect attributes include gradient center point, gradient transparency, gradient shape, and gradient animation effect.
4. The gradient color background rendering method according to claim 3, It is characterized in that The determining the attribute parameter value corresponding to each visual effect attribute according to the visual effect parameter comprises: For each visual effect attribute, determining whether a parameter value of the visual effect attribute exists in the visual effect parameters; If yes, obtaining the parameter value of the visual effect attribute from the visual effect parameter as the attribute parameter value corresponding to the visual effect attribute; If not, the default value of the visual effect attribute is read as the attribute parameter value corresponding to the visual effect attribute.
5. The gradient color background rendering method according to claim 1, It is characterized in that The performing slot detection on the rendering object comprises: Determine whether the rendering object is a custom named slot; If so, confirm that the rendering object is a slot object, and obtain the slot content of the slot object; If not, it is confirmed that the rendering object is an element object; and the element object does not have slot content.
6. The gradient color background rendering method according to claim 1, It is characterized in that The rendering of the slot content into the target style object includes: Determine a rendering position and a rendering style of the slot content, and render the slot content into the target style object according to the rendering position and the rendering style.
7. A gradient color background rendering device, It is characterized in that include: A parameter acquisition module is used to receive the attribute object passed by the parent component and obtain the rendering parameters of the rendering object in the attribute object; The rendering parameters include basic gradient parameters and visual effect parameters; An object generation module, configured to generate an initial style object of the rendering object according to the basic gradient parameters, and to adjust the style of the initial style object based on the visual effect parameters to obtain a target style object; An object updating module, configured to perform slot detection on the rendering object, and when detecting that the rendering object has slot content, render the slot content into the target style object to update the target style object; The object application module is used to return the target style object to the parent component, so that the parent component applies the target style object to the rendering object.
8. The gradient color background rendering device according to claim 7, It is characterized in that The object generation module comprises: The gradient calculation submodule is used to determine the starting color and the ending color in the basic gradient parameters, and perform gradient calculation on the starting color and the ending color according to the gradient direction in the basic gradient parameters, so as to generate an initial style object of the rendering object according to the calculation results.
9. A storage medium, Features: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the gradient background rendering method as described in any one of claims 1 to 6.
10. A computer device, It is characterized in that include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the gradient background rendering method according to any one of claims 1 to 6 are performed.
