A method, device, equipment and storage medium for realizing text gradient effect
By providing text gradient effect implementation methods and devices in the system, the problem that the existing TextView component cannot achieve complex text gradient effects is solved, and rich text gradient effect display in short videos is realized to meet diverse display needs.
Patent Information
- Application Number
- CN202011038832.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-28
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-09-28
AI Technical Summary
The TextView component that comes with existing systems (such as Android and iOS) cannot achieve complex text gradient effects and cannot meet the text display needs added to short videos.
Provides a method and device for realizing a text gradient effect, including a text receiving module, an effect determining module and a gradient processing module. By receiving the text to be processed, the gradient processing method is determined based on the set text gradient effect, and overall or branch gradient processing is performed, and Displays the processed text in a gradient text box.
It achieves richer text gradient effects, meets the diverse needs for text display effects in short videos, provides a choice of overall and branch gradient effects, and enhances the aesthetics of text display.
Smart Images

Figure CN112329386B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of text display technology, and in particular to a method, device, equipment and storage medium for realizing a text gradient effect. Background Art
[0002] With the development of the Internet, short video applications are becoming more and more popular. When making short videos, people often add lyrics, subtitles, cover titles and other texts to the videos, and when adding texts, they hope that the texts can show different display effects.
[0003] In practical applications, text gradient effect is a common text display effect. However, the TextView (a view used to display text in the system) that comes with the current system (Android, iOS, etc.) can only achieve simple text display effects and cannot meet the display requirements for text gradient. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, device and storage medium for implementing a text gradient effect, so as to provide a richer text gradient effect.
[0005] In a first aspect, an embodiment of the present application provides a method for realizing a text gradient effect, comprising:
[0006] Receive the text to be processed input into the gradient text box;
[0007] Determine a corresponding gradient processing method based on a set text gradient effect, wherein the text gradient effect includes an overall gradient effect and a line gradient effect;
[0008] Performing text gradient processing on the text to be processed based on the gradient processing method to obtain a gradient effect text corresponding to the text gradient effect;
[0009] The gradient effect text is displayed in the gradient text box.
[0010] In a second aspect, an embodiment of the present application provides a device for implementing a text gradient effect, including a text receiving module, an effect determining module, a gradient processing module, and a text display module, wherein:
[0011] A text receiving module, used for receiving the text to be processed input into the gradient text box;
[0012] An effect determination module, used to determine a corresponding gradient processing method based on a set text gradient effect, wherein the text gradient effect includes an overall gradient effect and a line gradient effect;
[0013] A gradient processing module, used for performing text gradient processing on the text to be processed based on the gradient processing method, so as to obtain a gradient effect text corresponding to the text gradient effect;
[0014] A text display module is used to display the gradient effect text in the gradient text box.
[0015] In a third aspect, an embodiment of the present application provides a computer device, including: a memory and one or more processors;
[0016] The memory is used to store one or more programs;
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the text gradient effect implementation method as described in the first aspect.
[0018] In a fourth aspect, an embodiment of the present application provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the method for realizing a text gradient effect as described in the first aspect.
[0019] The embodiment of the present application determines the gradient processing method for the text to be processed based on the set text gradient effect, and performs text gradient processing on the text to be processed according to the gradient processing method to obtain gradient effect text corresponding to the text gradient effect, and displays the gradient effect text in a gradient text box. In addition, the text gradient effect can be set to an overall gradient effect or a line gradient effect according to the text effect requirements to meet the needs of richer text gradient effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flow chart of a method for realizing a text gradient effect provided by an embodiment of the present application;
[0021] Figure 2 is a schematic diagram of an effect display interface provided in an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of displaying a text with a gradient effect provided by an embodiment of the present application;
[0023] Figure 4 is a flow chart of another method for realizing a text gradient effect provided by an embodiment of the present application;
[0024] Figure 5 It is a schematic diagram of an overall horizontal gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0025] Figure 6 It is a schematic diagram of an overall vertical gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0026] Figure 7 It is a schematic diagram of an overall diagonal gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0027] Figure 8 It is a schematic diagram of a text with a gradient effect corresponding to an overall horizontal mirror image gradient provided in an embodiment of the present application;
[0028] Fig. 9 is a flow chart of another method for realizing a text gradient effect provided by an embodiment of the present application;
[0029] Fig.10 It is a schematic diagram of a text with a gradient effect corresponding to a repeated gradient effect in lines provided in an embodiment of the present application;
[0030] Fig.11 It is a schematic diagram of a line-by-line diagonal gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0031] Fig.12 It is a schematic diagram of a line-by-line vertical mirror gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0032] Fig.13 It is a schematic diagram of a line-by-line horizontal mirror gradient effect corresponding to a gradient effect text provided in an embodiment of the present application;
[0033] Fig.14 It is a structural schematic diagram of a device for realizing a text gradient effect provided in an embodiment of the present application;
[0034] Fig.15 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0036] Figure 1 A flowchart of a method for realizing a text gradient effect provided in an embodiment of the present application is given. The method for realizing a text gradient effect provided in an embodiment of the present application can be executed by a text gradient effect realization device, which can be realized by hardware and / or software and integrated in a computer device.
[0037] The following description is made by taking the text gradient effect realization device executing the text gradient effect realization method as an example. Figure 1 , the method for realizing the text gradient effect includes:
[0038] S101: receiving text to be processed input into a gradient text box.
[0039] For example, a gradient text box can be added to the effect display interface provided by a computer device such as a mobile phone or a tablet computer, and text can be input by clicking on the gradient text box, or the text in the gradient text box can be edited. After the text input or editing is completed, the text input into the gradient text box is received and used as the text to be processed. The text to be processed can be understood as the text that needs to be processed by the text gradient.
[0040] The gradient text box may be added to the effect display interface after receiving and confirming the text to be processed, or the gradient text box may be added to the effect display interface and then the text to be processed may be input by clicking the gradient text box.
[0041] Optionally, before entering the text to be processed into the gradient text box, prompt text is displayed in the gradient text box based on the set text gradient display effect, for example, the prompt text "Click to enter text" is displayed based on the overall gradient effect or the line gradient effect, and after clicking the gradient text box to enter the text to be processed, the text input interface is entered (for example, a virtual keyboard is called for text input), and the display of the prompt text is canceled.
[0042] Figure 2 This is a schematic diagram of an effect display interface provided in an embodiment of the present application. Taking the video recording application as an example, start the video recording application and enter the video recording page. After completing the video recording, enter the effect display interface (the effect display interface can be entered through the cover setting button or the subtitle setting button, which is used to set the display effect of the text displayed in the cover or subtitle respectively). In this embodiment, the effect display interface is an interactive interface for setting the display effect on the corresponding video frame. Figure 2 As shown, a gradient text box is added to the effect display interface (the position corresponding to "Click to enter text" in the figure), and a prompt text of "Click to enter text" is displayed in the gradient text box. By clicking the prompt text, you can enter the text input interface to enter the text to be processed into the gradient text box.
[0043] Optionally, when the text to be processed is received or an update of the text to be processed is detected, the TextView component is called through the View.onDraw instruction to perform the next text drawing operation.
[0044] S102: Determine a corresponding gradient processing method based on a set text gradient effect, where the text gradient effect includes an overall gradient effect and a line gradient effect.
[0045] The overall gradient effect can be understood as the gradient effect corresponding to taking the entire text to be processed as the gradient processing object, and the corresponding gradient processing method is to perform text gradient processing on the text to be processed as a whole. The gradient processing can be horizontal gradient processing, vertical gradient processing, diagonal gradient processing, mirror gradient processing, etc.
[0046] The line-by-line gradient effect can be understood as the gradient effect corresponding to treating different lines of text to be processed as gradient processing objects separately. The corresponding gradient processing method is to divide the text to be processed into lines, and then perform text gradient processing on each line of text separately. The processing result shows that the gradient effects between different lines of text are different. Optionally, the line-by-line division of the text to be processed can be single-line division or multi-line division, and different gradient effects can be set for texts in different lines.
[0047] In this embodiment, the set text gradient effect can be a default text gradient effect, or a text gradient effect determined according to a switching operation or a selection operation on the text gradient effect. For example, selection buttons corresponding to different text gradient effects are provided in the effect display interface, and after clicking the corresponding selection button, the corresponding text gradient effect is the set text gradient effect.
[0048] Furthermore, different text gradient effects correspond to different gradient processing methods and gradient text boxes, and the corresponding gradient processing method can be determined according to the set text gradient effect.
[0049] For example, when entering the effect display interface, a gradient text box is added to the effect display interface according to the default text gradient effect, the text to be processed input into the gradient text box is received, and the text gradient effect corresponding to the gradient text box is determined, and then the corresponding gradient processing method is determined. When a switching operation or a selection operation is detected, the corresponding gradient text box is switched, and the text gradient effect corresponding to the gradient text box is determined, and then the corresponding gradient processing method is determined.
[0050] S103: performing text gradient processing on the text to be processed based on the gradient processing method to obtain a gradient effect text corresponding to the text gradient effect.
[0051] Exemplarily, after receiving the text to be processed and determining the gradient processing method, the text to be processed is subjected to text gradient processing based on the determined gradient processing method, and a gradient effect text corresponding to the set text gradient effect is obtained.
[0052] For example, for an overall gradient effect, the gradient effect of the corresponding gradient effect text is continuous as a whole; for a line gradient effect, the gradient effect of the corresponding gradient effect text is independent between adjacent lines.
[0053] S104: Displaying the gradient effect text in the gradient text box.
[0054] Exemplarily, after the gradient effect text is obtained, the gradient effect text is displayed in a corresponding gradient text box.
[0055] Optionally, a delete button or a zoom button can be added to the gradient text box to perform a delete operation or a zoom operation on the gradient text box. After the gradient text box is zoomed, the resized text to be processed is subjected to text gradient processing to obtain a gradient effect text of a corresponding size and displayed in the gradient text box. In addition, the position of the gradient text box in the effect display interface can be moved in response to a drag operation on the gradient text box.
[0056] Figure 3 A schematic diagram of a display of a text with a gradient effect provided in an embodiment of the present application. Figure 3 As described, after obtaining the gradient effect text, the gradient effect text is displayed on the effect display interface. The gradient effect displayed by the gradient effect text in the figure is an overall horizontal gradient, that is, the text color gradually changes in the horizontal direction. A delete button and a zoom button are added to the upper left corner and the lower right corner of the corresponding gradient text box, which are used to delete and zoom the gradient text box. When the text gradient effect is set and the corresponding video is played, the gradient effect text will be displayed in the video frame corresponding to the video screen, but the text box, the delete button and the zoom button will not be displayed.
[0057] As described above, the gradient processing method for the text to be processed is determined based on the set text gradient effect, and the text gradient processing is performed on the text to be processed according to the gradient processing method to obtain a gradient effect text corresponding to the text gradient effect, and the gradient effect text is displayed in a gradient text box. In addition, the text gradient effect can be set to an overall gradient effect or a line gradient effect according to the text effect requirements to meet the needs of richer text gradient effects.
[0058] Based on the above embodiments, Figure 4 This is a flowchart of another method for implementing a text gradient effect provided in an embodiment of the present application. This method for implementing a text gradient effect is a specific implementation of the above-mentioned method for implementing a text gradient effect. Figure 4 , the method for realizing the text gradient effect includes:
[0059] S201: receiving text to be processed input into a gradient text box.
[0060] S202: Determine an overall gradient processing method for the text to be processed based on the overall gradient effect.
[0061] The present application embodiment takes the overall gradient effect as an example to describe the set text gradient effect. For example, when entering the effect display interface, the default text gradient effect is the overall gradient effect, or the overall gradient effect is determined by switching or selecting the text gradient effect.
[0062] The overall gradient effect includes at least one of an overall horizontal gradient effect, an overall vertical gradient effect, an overall diagonal gradient effect and an overall mirror gradient effect, and different overall gradient effects correspond to different overall gradient processing methods.
[0063] For example, for the overall horizontal gradient effect, the corresponding color gradient direction is horizontal along the text direction; for the overall vertical gradient effect, the corresponding color gradient direction is vertical along the text direction; for the overall diagonal gradient effect, the corresponding color gradient direction is diagonal along the text direction; for the overall mirror gradient effect, the corresponding text color is a mirror-symmetrical gradient.
[0064] S203: Setting a linear gradient shader constructor according to the overall gradient processing method.
[0065] Specifically, after determining the overall gradient processing method for the text to be processed, a linear gradient shader (LinearGradient, a linear gradient shader in the Android system) is called according to the overall gradient processing method, and a constructor in the linear gradient shader is set. The constructor includes at least one of a drawing start point, a drawing end point, a color array, a gradient ratio, and an edge fill mode.
[0066] The constructor provided in the embodiment of the present application is: LinearGradient(float x0, float y0, floatx1, float y1, int[]colors, loat[]positions, TileMode tile). Wherein float x0 and floaty0 are the horizontal and vertical coordinates of the starting point of the gradient drawing. Considering that the starting point of the drawing in this embodiment starts from the upper left corner of the view (TextView, a view used to display text in the Android system), this embodiment generally sets the horizontal and vertical coordinates to x0=0f and y0=0f. float x1 and float y1 are the horizontal and vertical coordinates of the end point of the gradient drawing. int[]colors is a color array. For example, when it is set to three color arrays of red, green and blue, the color array is set to colors={Color.RED, Color.GREEN, Color.BLUE}. loat[]positions is used to set the gradient ratio of each color. If the gradient ratio of each color is the same, it can be set to empty. TileMode tile is used to set the edge fill mode. The edge fill mode in the system corresponds to Shader.TileMode. TileMode has three types: edge copy (CLAMP), repeat (REPEAT) and mirror (MIRROR). For example, if the edge fill mode is set to Shader.TileMode.CLAMP, the edge fill mode is edge copy.
[0067] Specifically, for different overall gradient effects, the setting of the constructor should follow the following principles:
[0068] Based on the overall horizontal gradient effect, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the upper right corner of the overall text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are Wt and 0f respectively, where Wt is the text width, which can be detected by the text layout tool (StaticLayout, a text layout tool in the Android system, which can be used for text measurement);
[0069] Based on the overall vertical gradient effect, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the lower left corner of the overall text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are 0f and Ht respectively, where Ht is the text height, which can be detected by the text layout tool;
[0070] Based on the overall diagonal gradient effect, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the lower right corner of the overall text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are Wt and Ht respectively;
[0071] Based on the overall mirror gradient effect, the color array in the constructor is set symmetrically, for example, the color array is set to colors = [A, B, C, D, E, D, C, B, A], and the drawing start point and the drawing end point are consistent with the settings of the overall horizontal gradient effect or the overall vertical gradient effect to achieve an overall horizontal mirror gradient or an overall vertical mirror gradient.
[0072] S204: Setting a text brush according to the linear gradient shader.
[0073] Specifically, set the linear gradient shader with set construction parameters to the text brush (TextPaint, the text brush of the Android system, which supports text drawing function). For example, set the linear gradient shader to the text brush based on mPaint.setShader(LinearGradient). In this way, when executing Draw below, the brush with Shader effect is used. The color will be obtained from the Shader during drawing, that is, the Shader needs to tell the text brush the color value of a certain place.
[0074] S205: Drawing the text to be processed on a canvas based on the text brush according to a text layout tool to obtain a gradient effect text corresponding to the overall gradient effect.
[0075] Specifically, after setting the text brush according to the linear gradient shader, the text layout tool (StaticLayout) of the text is obtained, and the text brush is set to the text layout tool. Based on the Staticlayout.Draw(Canvas) instruction, the text layout tool draws the text to be processed on the canvas based on the text brush, thereby obtaining the gradient effect text corresponding to the overall gradient effect.
[0076] Figure 5 This is a schematic diagram of an overall horizontal gradient effect corresponding to a gradient effect text provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, the drawing starting point and the drawing end point are the upper left corner and the upper right corner of the text to be processed, respectively, and the gradient colors in the figure change from red to blue and then from blue to green from left to right.
[0077] Figure 6 This is a schematic diagram of an overall vertical gradient effect corresponding to a gradient effect text provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, the drawing starting point and the drawing end point are the upper left corner and the lower left corner of the text to be processed, respectively, and the gradient colors in the figure change from red to blue and then from blue to green from top to bottom.
[0078] Figure 7 This is a schematic diagram of an overall diagonal gradient effect corresponding to a gradient effect text provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, the drawing starting point and the drawing end point are the upper left corner and the lower right corner of the text to be processed, respectively, and the gradient colors in the figure change from red to blue from the upper left corner to the lower right corner, and then from blue to green.
[0079] Figure 8 This is a schematic diagram of an overall horizontal mirrored gradient corresponding to a gradient effect text provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN, Color.BLUE, Color.RED}, the drawing starting point and the drawing end point are the upper left corner and the upper right corner of the text to be processed, respectively, and the gradient colors in the figure change from red to blue, from blue to green, from green to blue, and then from blue to red from left to right.
[0080] S206: Displaying the gradient effect text in the gradient text box.
[0081] As described above, after receiving the text to be processed, a linear gradient shader is set based on the corresponding overall gradient processing method, and then a text brush is set according to the linear gradient shader. The text layout tool then draws the text to be processed on the canvas based on the text brush to obtain a gradient effect text corresponding to the overall gradient effect, thereby achieving a richer overall gradient effect.
[0082] Based on the above embodiments, Fig. 9 This is a flowchart of another method for implementing a text gradient effect provided in an embodiment of the present application. This method for implementing a text gradient effect is a specific implementation of the above-mentioned method for implementing a text gradient effect. Fig. 9 , the method for realizing the text gradient effect includes:
[0083] S301: receiving text to be processed input into a gradient text box.
[0084] S302: Determine a line-by-line gradient processing method for the text to be processed based on the line-by-line gradient effect.
[0085] The present application embodiment takes the line gradient effect as the set text gradient effect as an example for description. For example, when entering the effect display interface, the default text gradient effect is the line gradient effect, or the line gradient effect is determined by switching or selecting the text gradient effect.
[0086] Among them, the branch gradient effect includes at least one of a branch repeated gradient effect, a branch diagonal gradient effect, a branch longitudinal mirror gradient effect and a branch transverse mirror gradient effect, and different branch gradient effects correspond to different branch gradient processing methods.
[0087] For example, for the line-by-line repeated gradient effect, the color gradient direction of each line-by-line text is along the longitudinal direction of the text; for the line-by-line diagonal gradient effect, the color gradient direction of each line-by-line text is along the diagonal direction of the corresponding line-by-line text; for the line-by-line longitudinal mirror gradient effect, the color gradient direction of each line-by-line text is along the longitudinal direction of the text, and the color array of adjacent line-by-line text is opposite to the color array of adjacent line-by-line text; for the line-by-line transverse mirror gradient, the color gradient direction of each line-by-line text is along the transverse direction of the text, and the color array of adjacent line-by-line text is opposite to the color array of adjacent line-by-line text.
[0088] Optionally, in the present embodiment, the line-break gradient effect may be a single-line gradient effect or a multi-line gradient effect, that is, the number of text lines corresponding to each line-break text may be a single line or multiple lines.
[0089] S303: Obtaining the overall height and number of text lines of the text to be processed through a text layout tool.
[0090] Specifically, the text to be processed is measured by a text layout tool to obtain the overall height of the text to be processed and the number of text lines.
[0091] S304: Determine the text height of the line-by-line text based on the overall height and the number of text lines.
[0092] Specifically, after the overall height of the text to be processed and the number of text lines are measured, the height of each line of text can be determined based on the overall height and the number of text lines.
[0093] For example, assuming the overall height is H and the number of text lines is C, the quotient of the overall height and the number of text lines H / C is the height h of each single line of text, that is, h = H / C. If the corresponding line gradient effect is a multi-line gradient effect, the height of each line of text is n*h, where n is the number of lines of text in each line. It can be understood that, assuming there are N lines of text to be processed, if each line of text is a single line, then N*h = H, and if each line of text is n lines, then N*n*h = H.
[0094] S305: Obtain the first line of text to be processed of the text to be processed.
[0095] Specifically, after determining the height of the line-break text, the first line of text to be processed of the text to be processed is obtained, wherein the first line of text to be processed is the first line of text to be processed that has not been subjected to text gradient processing.
[0096] For example, assuming that the height of the line break text has just been determined (the line break text has not been drawn at this time), the first line break text to be processed is the first line break text, so the first line break text is obtained. After the first line break text is drawn, the first line break text to be processed is the second line break text, so the second line break text is obtained, and so on.
[0097] S306: Setting the constructor of the linear gradient shader corresponding to the line of text to be processed according to the line gradient processing method.
[0098] Specifically, after determining the line gradient processing method for the text to be processed and obtaining the first line of text to be processed, the linear gradient shader is called according to the line gradient processing method, and the constructor in the linear gradient shader is set. The constructor includes at least one of a drawing start point, a drawing end point, a color array, a gradient ratio, and an edge fill mode.
[0099] Specifically, the setting of the constructor of the gradient shader includes steps S3061-S3063:
[0100] S3061: Determine whether the line-by-line gradient effect is a line-by-line mirror gradient effect. If yes, jump to step S3062; otherwise, jump to step S3063.
[0101] In this embodiment, selection buttons corresponding to different gradient display effects are added to the effect display interface. The corresponding gradient display effect can be determined according to the selected selection button, and it is judged whether the gradient display effect is a row-by-row mirror gradient effect. If so, jump to step S3062, otherwise jump to step S3063.
[0102] S3062: Setting the constructor of the linear gradient shader corresponding to the first line of text to be processed in a manner that the color arrays of two adjacent lines of text are opposite.
[0103] Specifically, if the line-by-line gradient effect is a line-by-line mirror gradient effect, the constructor of the linear gradient shader is set in a manner that the color arrays of two adjacent lines of text are opposite.
[0104] For different branch vertical mirror gradient effects and branch horizontal mirror gradient effects, the settings of the constructor should follow the following principles respectively:
[0105] Based on the line-by-line gradient processing method of vertical mirror gradient of the line, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the lower left corner of the line-by-line text, and the color array is set to be opposite to the color array corresponding to the adjacent line of text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are 0f and n*h respectively, and the color array can be set to draw normally for odd-numbered lines and reverse the gradient color for even-numbered lines;
[0106] The line gradient processing method based on the line horizontal mirror gradient is to set the drawing starting point and the drawing end point in the constructor to the upper left corner and the upper right corner of the line text respectively, and set the color array to be opposite to the color array corresponding to the adjacent line of text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are Wt and 0 respectively, and the color array can be set to draw normally for odd lines and reverse the gradient color for even lines.
[0107] S3063: Setting the constructor of the linear gradient shader corresponding to the first line of text to be processed.
[0108] If the line-by-line gradient effect is not a line-by-line mirror gradient effect, determine whether the line-by-line gradient effect is a line-by-line repeated gradient effect or a line-by-line diagonal gradient effect, and set the constructor of the linear gradient shader corresponding to the first line of text to be processed according to the corresponding line-by-line gradient processing method.
[0109] For the line-by-line repeated gradient effect and the line-by-line diagonal gradient effect, the constructor settings should follow the following principles:
[0110] Based on the line-by-line gradient processing method of repeated gradient, the drawing starting point and the drawing end point in the constructor are set to the upper left corner and the lower left corner of the line-by-line text respectively, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are 0f and n*h respectively.
[0111] Based on the line-by-line gradient processing method of the line-by-line diagonal gradient, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the lower right corner of the line-by-line text, that is, the horizontal coordinate and the vertical coordinate of the drawing end point are Wt and n*h respectively.
[0112] S307: Setting a text brush according to the linear gradient shader.
[0113] The setting of the text brush may refer to step S204, which will not be described in detail in this embodiment.
[0114] S308: Draw each line of the text to be processed at the position corresponding to each line of text on the canvas using the text layout tool and the text brush to obtain the gradient effect text corresponding to the line gradient effect. If there is still the first line of text to be processed, return to step S305 to re-acquire the first line of text to be processed until all the lines of text to be processed have been subjected to the text gradient processing.
[0115] Specifically, drawing the text to be processed includes steps S3081-S3082:
[0116] S3081: Draw the first line of text to be processed on the canvas using a text layout tool based on a text brush.
[0117] Specifically, after setting the text brush, the text brush is set to the text layout tool, and the text layout tool draws the first line of text to be processed on the canvas based on the text brush, thereby obtaining the line-by-line gradient effect text corresponding to the line-by-line gradient effect.
[0118] It can be understood that after the first line of text to be processed is subjected to text gradient processing and line-by-line gradient effect text is drawn, the first line of text to be processed becomes the next line of text, until all lines of text to be processed have been subjected to text gradient processing and the line-by-line gradient effect text is sequentially combined into gradient effect text.
[0119] S3082: Shift the text height of the text line on the canvas along the text height direction.
[0120] Specifically, after completing the drawing of the first line of text to be processed, the canvas is translated along the text height direction (Y-axis direction) by an amplitude corresponding to the text height (n*h) of the line-by-line text, so that when drawing the next first line of text to be processed, the next line-by-line gradient effect text is located below the current line-by-line gradient effect text.
[0121] Further, return to step S305 to re-acquire the first line of text to be processed of the text to be processed, until all the lines of text to be processed have been subjected to text gradient processing, that is, steps S305-S308 are looped and executed N / n times (the number of lines).
[0122] Fig.10 This is a schematic diagram of a gradient effect text corresponding to a repeated gradient effect in lines provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, the drawing starting point and the drawing end point are the upper left corner and the lower left corner of each line of text respectively, and the gradient color of each line changes from red to blue and then from blue to green from top to bottom.
[0123] Fig.11This is a schematic diagram of a gradient effect text corresponding to a diagonal gradient effect in lines provided in an embodiment of the present application, wherein the gradient array is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, the drawing starting point and the drawing end point are the upper left corner and the lower right corner of each line of text respectively, and the gradient color of each line changes from red to blue and then from blue to green from the upper left corner to the lower right corner.
[0124] Fig.12 This is a schematic diagram of a gradient effect text corresponding to a vertical mirror gradient effect in a line provided in an embodiment of the present application, wherein the gradient array of odd-numbered rows is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, and the gradient array of even-numbered rows is set to colors = {Color.GREEN, Color.BLUE, Color.RED}, and the drawing starting point and drawing end point are the upper left corner and lower left corner of each line of text respectively. The gradient colors of odd-numbered rows change from red to blue and then from blue to green from top to bottom, and the gradient colors of even-numbered rows change from green to blue and then from blue to red from top to bottom.
[0125] Fig.13 This is a schematic diagram of a gradient effect text corresponding to a horizontal mirrored gradient effect in lines provided in an embodiment of the present application, wherein the gradient array of odd-numbered lines is set to colors = {Color.RED, Color.BLUE, Color.GREEN}, and the gradient array of even-numbered lines is set to colors = {Color.GREEN, Color.BLUE, Color.RED}, the drawing starting point and the drawing end point are the upper left corner and the upper right corner of each line of text respectively, the gradient colors of odd-numbered lines change from red to blue from left to right, and then from blue to green, and the gradient colors of even-numbered lines change from green to blue from left to right, and then from blue to red.
[0126] S309: Return the canvas to its initial position.
[0127] Specifically, after all lines of text to be processed have been subjected to text gradient processing and gradient effect text has been obtained, the canvas is restored to the initial position to restore the drawing position for the next text drawing. When the gradient display effect is switched next time or the text to be processed is updated, the text to be processed can be redrawn at the original position.
[0128] S310: Displaying the gradient effect text in the gradient text box.
[0129] As described above, after receiving the text to be processed, multiple lines of text are decomposed into multiple lines, a linear gradient shader is set based on the corresponding line gradient processing method, and then a text brush is set according to the linear gradient shader. Then, the text layout tool uses the text brush to process the lines of text on the canvas at different positions to obtain the line gradient effect text corresponding to each line of text to be processed. The line gradient effect text can be combined into the gradient effect text required for the line gradient effect to achieve a richer line gradient effect. And the line gradient effect is not limited to a certain line gradient effect, and multiple line gradient effects can be combined in one gradient effect text. For example, in the lyrics of some music applications with multiple people singing together, a line gradient effect can be set for male voices, a line gradient effect can be set for female voices, and a line gradient effect can be set for chorus. And the gradient width is not limited to the overall width of each line of fonts, and can be one-half or one-third of the width of each line of fonts (can be set through different drawing end positions), thereby expanding more cool advanced text gradient effects.
[0130] Fig.14 A schematic diagram of the structure of a device for realizing a text gradient effect provided by an embodiment of the present application is given. Fig.14 The text gradient effect realization device comprises a text receiving module 41 , an effect determination module 42 , a gradient processing module 43 and a text display module 44 .
[0131] Among them, the text receiving module 41 is used to receive the text to be processed input into the gradient text box; the effect determination module 42 is used to determine the corresponding gradient processing method based on the set text gradient effect, and the text gradient effect includes the overall gradient effect and the line gradient effect; the gradient processing module 43 is used to perform text gradient processing on the text to be processed based on the gradient processing method to obtain the gradient effect text corresponding to the text gradient effect; the text display module 44 is used to display the gradient effect text in the gradient text box.
[0132] As described above, the gradient processing method for the text to be processed is determined based on the set text gradient effect, and the text gradient processing is performed on the text to be processed according to the gradient processing method to obtain a gradient effect text corresponding to the text gradient effect, and the gradient effect text is displayed in a gradient text box. In addition, the text gradient effect can be set to a line gradient effect or a line gradient effect according to the text effect requirements to meet the needs of richer text gradient effects.
[0133] The embodiment of the present application also provides a computer device, which can integrate the text gradient effect implementation device provided in the embodiment of the present application. Fig.15 Schematic diagram of a computer device provided in an embodiment of the present application. Fig.15The computer device includes: an input device 53, an output device 54, a memory 52 and one or more processors 51; the memory 52 is used to store one or more programs; when the one or more programs are executed by the one or more processors 51, the one or more processors 51 implement the text gradient effect implementation method provided in the above embodiment. The input device 53, the output device 54, the memory 52 and the processor 51 can be connected by a bus or other means. Fig.15 The example of connecting through bus is taken in the following.
[0134] The memory 52, as a computing device readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the text gradient effect implementation method described in any embodiment of the present application (for example, the text receiving module 51, the effect determination module 52, the gradient processing module 53 and the text display module 54 in the text gradient effect implementation device). The memory 52 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function; the data storage area may store data created according to the use of the device, etc. In addition, the memory 52 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 52 may further include a memory remotely arranged relative to the processor 51, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0135] The input device 53 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 54 may include a display device such as a display screen.
[0136] The processor 51 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 52, that is, realizes the above-mentioned method for realizing the text gradient effect.
[0137] The above-mentioned text gradient effect realization device, equipment and computer can be used to execute the text gradient effect realization method provided by any of the above-mentioned embodiments, and have corresponding functions and beneficial effects.
[0138] An embodiment of the present application also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to execute a method for implementing a text gradient effect as provided in the above embodiment, and the method for implementing a text gradient effect includes: receiving a text to be processed input into a gradient text box; determining a corresponding gradient processing method based on a set text gradient effect, wherein the text gradient effect includes an overall gradient effect and a line gradient effect; performing text gradient processing on the text to be processed based on the gradient processing method to obtain a gradient effect text corresponding to the text gradient effect; and displaying the gradient effect text in the gradient text box.
[0139] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.
[0140] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application is not limited to the text gradient effect implementation method described above, and can also execute related operations in the text gradient effect implementation method provided in any embodiment of the present application.
[0141] The text gradient effect implementation apparatus, device and storage medium provided in the above embodiments can execute the text gradient effect implementation method provided in any embodiment of the present application. For technical details not described in detail in the above embodiments, please refer to the text gradient effect implementation method provided in any embodiment of the present application.
[0142] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A method for realizing a text gradient effect, characterized in that: include: Receive the text to be processed input into the gradient text box; Determining a line-by-line gradient processing method for the text to be processed based on line-by-line gradient effects, wherein the line-by-line gradient effects include line-by-line repeated gradient effects, line-by-line diagonal gradient effects, line-by-line longitudinal mirror gradient effects, and line-by-line transverse mirror gradient effects; In the case where the gradient processing method for the text to be processed is a line-by-line gradient processing method, the overall height and the number of text lines of the text to be processed are obtained through a text layout tool; the text height of the line-by-line text is determined based on the overall height and the number of text lines, wherein the text height of each single-line text is the quotient of the overall height and the number of text lines, and in the case where the line-by-line gradient effect is a multi-line gradient effect, the text height of each line-by-line text is the product of the text height of each single-line text and the number of text lines of each line-by-line text; the first line-by-line text to be processed of the text to be processed is obtained, and the first line-by-line text to be processed is the line-by-line text to be processed in the front line that has not undergone text gradient processing; according to The line-by-line gradient processing method sets a constructor of a linear gradient shader corresponding to the line of text to be processed, and the constructor corresponding to the line-by-line gradient processing method includes a drawing start point, a drawing end point, a color array, a gradient ratio, and an edge filling mode; a text brush is set according to the linear gradient shader corresponding to the line-by-line gradient processing method, and the first line of text to be processed is drawn on the canvas based on the text brush according to the text layout tool, the text height of the line of text on the canvas is translated along the text height direction, and the first line of text to be processed of the text to be processed is re-acquired, until all the lines of text to be processed are subjected to text gradient processing, so as to obtain the gradient effect text corresponding to the line-by-line gradient effect; The gradient effect text is displayed in the gradient text box.
2. The method for realizing text gradient effect according to claim 1, characterized in that: In the case where the gradient processing method for the text to be processed is a line-by-line gradient processing method, the setting of the constructor includes at least one of the following: Based on the line-by-line repeated gradient processing method, the drawing starting point and the drawing end point in the constructor are set to the upper left corner and the lower left corner of the line-by-line text respectively; Based on the line-by-line gradient processing method of diagonal gradient of line-by-line, the drawing starting point and the drawing end point in the constructor are set to the upper left corner and the lower right corner of the line-by-line text respectively; Based on the line branch gradient processing method of the vertical mirror gradient of the line branch, the drawing starting point and the drawing end point in the constructor are respectively set to the upper left corner and the lower left corner of the line branch text, and the color array is set to be opposite to the color array corresponding to the adjacent line of text; Based on the branch gradient processing method of horizontal mirror gradient of the branch, the drawing starting point and the drawing end point in the constructor are set to the upper left corner and the upper right corner of the branch text respectively, and the color array is set opposite to the color array corresponding to the adjacent line of text.
3. The method for realizing text gradient effect according to claim 1, characterized in that: The constructor for setting the linear gradient shader according to the row-by-row gradient processing method includes: If the line-by-line gradient effect is a line-by-line mirror gradient effect, the constructor of the linear gradient shader corresponding to the first line of text to be processed is set in a manner that the color arrays of two adjacent lines of text are opposite.
4. The method for realizing text gradient effect according to claim 1, characterized in that: The constructor for setting the linear gradient shader according to the row-by-row gradient processing method includes: If the line-by-line gradient effect is not a line-by-line mirror gradient effect, then the constructor of the linear gradient shader corresponding to the first line of text to be processed is set.
5. The method for realizing text gradient effect according to claim 1, characterized in that: After all the lines of text to be processed have been subjected to text gradient processing, the following further includes: Restore the canvas to its initial position to restore the drawing position for the next text drawing.
6. A device for realizing a text gradient effect, characterized in that: It includes a text receiving module, an effect determining module, a gradient processing module and a text display module, wherein: A text receiving module, used for receiving the text to be processed input into the gradient text box; An effect determination module, used for determining a line-by-line gradient processing mode for the text to be processed based on a line-by-line gradient effect, wherein the line-by-line gradient effect includes a line-by-line repeated gradient effect, a line-by-line diagonal gradient effect, a line-by-line longitudinal mirror gradient effect, and a line-by-line transverse mirror gradient effect; A gradient processing module is used to obtain the overall height and the number of text lines of the text to be processed through a text layout tool when the gradient processing method for the text to be processed is a line-by-line gradient processing method; determine the text height of the line-by-line text based on the overall height and the number of text lines, wherein the text height of each single-line text is the quotient of the overall height and the number of text lines, and when the line-by-line gradient effect is a multi-line gradient effect, the text height of each line-by-line text is the product of the text height of each single-line text and the number of text lines of each line-by-line text; obtain the first line of text to be processed of the text to be processed, wherein the first line of text to be processed is the line of text to be processed at the front line that has not undergone text gradient processing characters; setting the constructor of the linear gradient shader corresponding to the line text to be processed according to the line gradient processing mode, the constructor corresponding to the line gradient processing mode includes a drawing start point, a drawing end point, a color array, a gradient ratio and an edge filling mode, setting a text brush according to the linear gradient shader corresponding to the line gradient processing mode, drawing the first line text to be processed on the canvas based on the text brush according to the text layout tool, translating the text height of the line text of the canvas along the text height direction, and re-obtaining the first line text to be processed of the text to be processed, until all the lines text to be processed have been subjected to text gradient processing, so as to obtain the gradient effect text corresponding to the line gradient effect; A text display module is used to display the gradient effect text in the gradient text box.
7. A computer device, characterized in that: include: memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the text gradient effect implementation method as described in any one of claims 1-5.
8. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the text gradient effect realization method as described in any one of claims 1 to 5 when executed by a computer processor.
