Character color determination method and device, storage medium and electronic device
By obtaining the current background brightness of the target text control and the preset first and second colors of the background where the target text control is located, dynamically determine the display color of the target text control, solving the problem of complex dynamic word color implementation process and high performance consumption in the prior art, and realizing clear visibility and high recognition of the text under different lighting and backgrounds.
Patent Information
- Application Number
- CN202411998125.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
AI Technical Summary
When implementing dynamic font colors in the prior art, the development process is complex, the memory occupies a large amount of performance, and the text information is difficult to ensure clear readability and recognition under the interface background with complex contrast.
By obtaining the current background brightness of the background where the target text control is located, and obtaining the first color and the second color, corresponding to the text control colors under the first background brightness and the second background brightness, the display color of the target text control is dynamically determined based on these colors and the current background brightness.
It realizes dynamic determination of text color based on the real-time brightness of the background where the target text control is located, ensuring that the text is clearly visible and highly recognizable under different lighting conditions and background complexity, avoiding the sudden jump of text color, providing a smoother and continuous visual effect, and reducing memory and performance consumption.
Smart Images

Figure CN119904555A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to a text color determination method, device, storage medium and electronic device. Background Art
[0002] In the process of game development, we need to consider not only the game play design, production, and plot, but also the beauty of the game screen and the clarity of the displayed text to satisfy the players' visual experience. The game engine needs to perform rendering, texturing, and mapping in terms of user interface (UI) design, lighting, special effects, and rendering to improve the adaptability of the dynamic text color display in the game interface.
[0003] At present, although there are solutions to achieve dynamic font color using Unreal Motion Graphics (UMG) and using the Slate framework, when the game background environment is complex and the color is uncontrollable, the above two solutions will make it difficult to ensure clear readability and recognition of the text in the game interface. At the same time, when achieving dynamic font color, the above two solutions have a complex development process, occupy a large amount of memory, and have high performance consumption. In addition, it is difficult to ensure clear readability and recognition of text information in an interface background with complex contrast.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] At least some embodiments of the present application provide a method, device, storage medium and electronic device for determining text color, so as to at least solve the technical problems in the related art of using UMG technology or Slate framework to realize dynamic text color, resulting in a complex development process, large memory usage, high performance consumption, and difficulty in ensuring clear readability and recognizability of text information in an interface background with complex contrast.
[0006] According to one embodiment of the present application, a method for determining text color is provided, the method comprising: obtaining the current background brightness of the background where the target text control is located; obtaining a first color and a second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness; based on the first color, the second color and the current background brightness, determining the current color to be displayed of the target text control.
[0007] According to one embodiment of the present application, a text color determination device is also provided, which includes: a first acquisition module, used to obtain the current background brightness of the background where the target text control is located; a second acquisition module, used to obtain a first color and a second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness; a determination module, used to determine the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0008] According to one embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the text color determination method in the above embodiment when running on a computer or a processor.
[0009] According to one embodiment of the present application, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the text color determination method in the above embodiment.
[0010] According to one embodiment of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the text color determination method in the above embodiment is implemented.
[0011] In at least some embodiments of the present application, by obtaining the current background brightness of the background where the target text control is located, the first color and the second color are obtained at the same time, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by calculating based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition under the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and the memory and performance consumption are reduced, thereby solving the technical problems of using UMG technology or Slate framework to realize dynamic text color in the related art, resulting in complex development process, large memory usage, high performance consumption, and difficulty in ensuring clear readability and recognition of text information under the interface background with complex contrast. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0013] Figure 1 This is a hardware structure block diagram of a mobile terminal for adjusting text color according to an embodiment of the present application;
[0014] Figure 2 is a flow chart of a method for determining text color according to one embodiment of the present application;
[0015] Figure 3 is a structural block diagram of a text color determination device according to one optional embodiment of the present application;
[0016] Figure 4 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0017] To facilitate understanding, some descriptions of concepts related to the embodiments of the present application are given exemplarily for reference.
[0018] As shown below:
[0019] Unreal Motion Graphics (UMG): is a UI system in Unreal Engine (UE) used to create user interfaces in games and other interactive experiences. UMG is a tool based on blueprints and visual scripting that allows game developers to design and create complex UI elements such as menus, heads-up displays (HUDs), dialog boxes, etc. without programming or coding knowledge.
[0020] Slate framework: is an open source content editable framework, mainly used to build rich text editors. Slate supports complex block-level elements, such as nested lists, tables, pictures, videos, links, etc., allowing developers to easily create feature-rich editors.
[0021] Tick event: It is an event in UE that is called in every frame to update the state and logic of the object. Tick events are often used to represent short intervals of time, usually in milliseconds. Tick events are a form of timer or clock that is used to trigger code or events periodically. In each Tick event, the program will execute a specific block of code or operation to update the program state or perform a specific task at a certain time interval. Tick events are often used to implement animations, game loops, timers, and other operations that need to be performed periodically. Tick events can help programmers control the execution speed and responsiveness of the program and implement some complex functions.
[0022] Unreal Motion Graphics Widgets (UMG Widgets): is a user interface tool in UE that is used to create and manage various UI elements in the game, such as buttons, text boxes, progress bars, etc. With UMG Widgets, developers can easily design and implement user interfaces in games to enhance the player experience. UMG Widgets supports a variety of interactive functions and style settings, and can be customized and adjusted according to game requirements.
[0023] Buffer: A temporary storage area for data, used to store data during data transmission so that it can be processed or transmitted when needed. Buffer is usually used to transfer data between devices of different speeds to balance the speed of data production and consumption. Buffer can temporarily store data during data transmission to avoid data loss or problems caused by mismatched data transmission speeds. Buffer can be hardware buffer or software buffer, used to store different types of data, such as audio, video, text, etc.
[0024] Shader: A program used to achieve visual effects such as light and shadow, color and texture in computer graphics. It is usually used to execute on a graphics processor to achieve advanced processing and rendering of graphics. Shader can control various aspects of graphics, such as lighting, shadows, color, texture, etc., so that the graphics look more realistic and vivid. Shader can be divided into different types such as vertex shader, fragment shader and geometry shader. Each type of shader has different functions and effects. Shader plays a very important role in the field of computer graphics and can help achieve various complex visual effects.
[0025] Floating point value: A value that represents the brightness of a color, usually used to describe the brightness of a color. In the value of color brightness, 0.0 is usually used to represent the darkest color, and 1.0 is used to represent the brightest color. Decimals can be used within this range to represent colors of different brightness. For example, 0.5 represents the middle brightness of a color, that is, a color that is half bright and half dark.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] In a possible implementation, in the field of computer vision technology, in the process of realizing dynamic changes in text color, it is necessary to use UMG technology based on blueprints and visual scripting tools to design and create complex UI elements without programming or coding knowledge, and then realize dynamic text color changes, or to write a large amount of C++ code through Slate framework technology and frequently modify and test to realize dynamic text color changes.
[0029] After practice and careful research, the inventor found that the method of using UMG technology or Slate framework to realize dynamic text color will lead to a complex development process, large memory usage, high performance consumption, and it is difficult to ensure clear readability and recognition of text information under the interface background with complex contrast. Based on this, the game scene applied by the embodiment of the present application can be the field of computer vision technology in the game, and a method for determining text color is proposed, by obtaining the current background brightness of the background where the target text control is located, and simultaneously obtaining the first color and the second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by calculating based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition under the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and memory and performance consumption are reduced, thereby solving the technical problems of using UMG technology or Slate framework to achieve dynamic text color in related technologies, resulting in a complex development process, large memory usage, high performance consumption, and difficulty in ensuring clear readability and recognition of text information in an interface background with complex contrast.
[0030] The above method embodiments involved in this application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone, a PDA, a mobile Internet device, a tablet computer (Personal Access Display, PAD), a game console and other terminal devices. Figure 1 1 is a hardware structure block diagram of a mobile terminal of a text color determination method according to an embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) processor 102 (the processor 102 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a programmable logic device (field-programmable gate array, FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. In one embodiment of the present application, it may also include: a transmission device 106, an input and output device 108 and a display device 110.
[0031] In some optional embodiments mainly based on game scenarios, the above-mentioned device can also provide a human-computer interaction interface with a touch-sensitive surface, which can sense finger contact and / or gestures to perform human-computer interaction with a graphical user interface (Graphical User Interface, GUI). The human-computer interaction function may include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital videos, playing digital music and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0032] Those skilled in the art will understand that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0033] According to one embodiment of the present application, an embodiment of a method for determining text color is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] In a possible implementation, the present application embodiment provides a method for determining text color. Figure 2 is a flow chart of a method for determining text color according to one embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0035] Step S20, obtaining the current background brightness of the background where the target text control is located.
[0036] In the embodiments of the present application, the target text control can be understood as a user interface (UI) element for displaying text information on a graphical user interface. For example, taking a game interface as an example, the target text control can be an option in a game menu, a character dialogue, a task description, a prompt message in the game, a numerical display in a status bar, etc., which is used to convey information and instructions in the game to the player, and is not limited here.
[0037] The current background brightness of the background where the target text control is located can be understood as the brightness of the screen background blocked by the target text control. For example, when a UI element in the game, such as a text box or a paragraph of text, is displayed at a certain position on the screen, the brightness level of the game screen below this position (excluding the UI layer itself) is defined as the current background brightness of the background where the text control is located.
[0038] It is understandable that background brightness is an indicator of quantitative brightness, usually in a range of 0 to 1, where 0 represents the darkest (such as black or a color close to black) and 1 represents the brightest (such as white or a color close to white). For example, in game development, this brightness value can be calculated in real time by the shader when rendering UI elements, and is obtained by analyzing the pixel color below the location of the target text control, which is not limited here.
[0039] By obtaining the current background brightness of the target text control, a basis can be provided for the subsequent dynamic text color change on the screen, so that the text color can be dynamically adjusted according to the background brightness level, ensuring that the text is clearly readable under any background brightness, thereby improving the user experience and the aesthetics of the game interface.
[0040] Step S22, obtaining a first color and a second color, wherein the first color is a text control color corresponding to the first background brightness, and the second color is a text control color corresponding to the second background brightness.
[0041] In the embodiment of the present application, the first color and the second color are also obtained, wherein the first color is the color of the text control corresponding to the first background brightness. The first background brightness can be set to a very dark background brightness level, and the text display color on a very dark background, i.e., the first color, needs to be predetermined according to the overall style and visual requirements of the application project (e.g., the overall style and visual requirements of the game to be developed). It is understandable that the first color is usually a brighter color to ensure the readability and recognition of the text in a dark background environment.
[0042] The second color is the color of the text control corresponding to the second background brightness, and the second background brightness can be set to a very bright background brightness level. It is understandable that under a bright background, if the text still maintains the first color, it may become difficult to recognize due to insufficient contrast. Therefore, the second color is usually a darker color, so as to provide good text visibility under a bright background. That is, the first color and the second color are the two extreme color values corresponding to the target text control when the background color is at extreme brightness.
[0043] It should be noted that the color of the text control is usually pre-set according to the visual style, color specifications and UI design principles of the application project, that is, during the development process, two color values, namely the first color and the second color, are pre-defined. The difference between the first color and the second color in this application is only the brightness. For example, if the preset color of the target text control is yellow according to the visual style, color specifications and UI design principles of the application project, the first color can be a brighter yellow, and the second color can be a lower brightness yellow, which is not limited here.
[0044] By obtaining the first color and the second color, the two extreme color values corresponding to the target text control under the extreme background brightness can be determined, which will help to subsequently achieve text readability and aesthetics of the interface under various complex backgrounds, while also complying with the specifications and visual consistency requirements of the application project.
[0045] Step S24, determining the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0046] In an embodiment of the present application, the color of the target text control to be currently displayed can be determined based on the first color, the second color, and the current background brightness obtained above. Among them, the color of the target text control to be currently displayed can be understood as the color of the text planned to be actually displayed on the screen after calculation based on the first color, the second color, and the current background brightness. Exemplarily, when the target text control in the UI interface needs to present text information, the color of the target text control to be currently displayed is the final text color, which ensures the readability and visual effect of the text in a specific background.
[0047] Based on the first color, the second color and the current background brightness, the color of the target text control to be displayed is determined, so that the color of the target text control can be determined in real time and dynamically to adapt to the ever-changing game background, thereby maintaining the readability and aesthetics of the UI text in any environment, while avoiding the UI visual weight and performance consumption problems caused by strong strokes or high-contrast backgrounds in traditional methods. In addition, by performing calculations based on the preset first color and second color, sudden jumps in text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect. Furthermore, the present application only performs simple calculations based on the first color, the second color and the current background brightness, which can reduce the logical processing burden of the processor and reduce memory and performance consumption.
[0048] In the embodiment of the present application, by obtaining the current background brightness of the background where the target text control is located, the first color and the second color are obtained at the same time, wherein the first color is the color of the text control corresponding to the first background brightness, and the second color is the color of the text control corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by calculating based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition under the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and the memory and performance consumption are reduced, thereby solving the technical problems of using UMG technology or Slate framework to realize dynamic text color in the related art, resulting in complex development process, large memory occupation, high performance consumption, and difficulty in ensuring clear readability and recognition of text information under the interface background with complex contrast.
[0049] In a possible implementation, in step S24, determining the current color to be displayed of the target text control based on the first color, the second color, and the current background brightness may include the following execution steps:
[0050] Step S241, performing interpolation calculation between the first color and the second color based on the current background brightness and a preset linear interpolation function to obtain the current color to be displayed of the target text control.
[0051] In the embodiment of the present application, the preset linear interpolation function may be a linear interpolation function (Lerp). It is understandable that the linear interpolation function is a mathematical function used to smoothly transition between two points according to given parameters. The basic formula of the Lerp function is Lerp (a, b, t) = a + (ba) * t. In the embodiment of the present application, a and b represent the first color and the second color respectively, and t is the current background brightness value, which is used to determine the degree of transition from the first color to the second color.
[0052] When determining the color to be displayed of the target text control based on the first color, the second color, and the current background brightness, the current background brightness value can be used as a parameter of the Lerp function, and interpolation calculations are performed based on the preset first color and second color. Exemplarily, the calculation is completed in real time inside the shader, and the display color of the text control is dynamically adjusted according to the change of the current background brightness. For example, if the current background brightness is 0.7, the text color will be calculated as 30% of the first color plus 70% of the second color, thereby obtaining the display color that best suits the current background brightness.
[0053] Thus, based on the current background brightness and the interpolation calculation between the first color and the second color by the preset linear interpolation function, the color of the text control can be dynamically and accurately determined to ensure its clear visibility and visual consistency in different environments. The real-time color adjustment mechanism of the present application not only improves the readability of the text, but also maintains the lightweight UI interface and the high efficiency of the game performance.
[0054] In a possible implementation, in step S20, obtaining the current background brightness of the background where the target text control is located may include the following execution steps:
[0055] Step S201, obtaining a rendering cache of a target screen frame, wherein the target screen frame includes a target text control;
[0056] Step S202, determining color information of a target picture frame based on a rendering cache;
[0057] Step S203, determining the current background brightness based on the color information.
[0058] In the embodiment of the present application, the target screen frame can be understood as a game screen frame, and the target screen frame includes a target text control. In a game engine (such as Unreal Engine), each frame of the picture will be generated by a rendering pipeline and finally displayed on the screen. The game screen frame refers to the image rendered and output to the screen by the game at a certain moment. Exemplarily, each frame of the game screen is a snapshot of the game world at a specific point in time, including all visual elements in the game world, such as characters, backgrounds, UI interfaces, etc. The game engine usually renders these pictures continuously at a speed of multiple frames per second (such as 60 frames per second or higher), thereby creating a smooth dynamic visual effect, which is not limited here.
[0059] It is understandable that the engine creates a rendering cache, usually referred to as a frame buffer or a rendering target, which contains the color information of all pixels in the current screen. In an embodiment of the present application, it is necessary to obtain the rendering cache of the target screen frame from the engine through a predefined interface before the UI control is rendered. It should be noted that the present application excludes the color information of the UI layer itself and only focuses on the three-dimensional (3D) environment color under the UI layer, that is, the rendering cache contains all pixel information in the game scene except the UI layer, which can be used to analyze the color and brightness of the game background.
[0060] After obtaining the rendering cache of the target screen frame, it is necessary to extract color information from the rendering cache. The color information includes the color information of all elements in the target screen frame, that is, the color information of the direct background of the target text control. Exemplarily, when obtaining the color information of the direct background of the target text control, this step is performed inside the Shader, using the texture (Texture Coordinates, UV) coordinates of the target text control, that is, the position information of the text on the screen, to read the specific color value of the position from the rendering cache.
[0061] After the color information is determined, the current background brightness is determined based on the color information. Usually, the color information is converted into grayscale values, and then the average brightness of the background or the brightness of a specific area is calculated by analyzing the distribution of the grayscale values. In the embodiment of the present application, this current background brightness is calculated in real time to reflect the background brightness of the game scene in the current state, which is helpful for the subsequent dynamic adjustment of the text color.
[0062] Thus, the rendering cache of the target screen frame is obtained, and the color information of the target screen frame is determined based on the rendering cache. Finally, the current background brightness is calculated based on the color information, which helps to more accurately adjust the text display color, ensuring that the text is still clear and readable in the complex and changing game background, and is consistent with the overall visual style of the game, avoiding the performance overhead and debugging complexity of traditional technologies.
[0063] In a possible implementation, in step S203, determining the current background brightness based on the color information may include the following execution steps:
[0064] Step S2031, sampling color information based on the target screen coordinates of the target text control to obtain a first background color, wherein the first background color is used to represent a background pixel color corresponding to any pixel in the target text control;
[0065] Step S2032, performing a preprocessing operation on the first background color based on the surrounding background color to obtain a target background color, wherein the surrounding background color is used to represent the background pixel color within a preset range around any pixel in the target text control;
[0066] Step S2033, determining the current background brightness based on the target background color.
[0067] In an embodiment of the present application, when determining the current background brightness based on color information, the color information can be sampled based on the target screen coordinates of the target text control to obtain a first background color, wherein the first background color is used to represent the background pixel color corresponding to any pixel in the target text control.
[0068] For example, when the shader starts processing the target text control, the shader will use the target screen coordinates (i.e., UV coordinates) of the target text control to sample on the pre-acquired rendering buffer to determine the background pixel color in the target text control coverage area. This process is pixel-level, which means that for each pixel in the target text control, the shader will read the background pixel color at the corresponding position to obtain the first background color. The first background color directly reflects the specific background pixel color behind the target text control and is the basis for subsequent calculations.
[0069] After obtaining the first background color, the first background color is preprocessed based on the surrounding background color to obtain the target background color, wherein the surrounding background color is used to represent the background pixel color within a preset range around any pixel in the target text control.
[0070] It is understandable that in order to more accurately reflect the color and brightness of the environment surrounding the target text control, it is necessary to further analyze the background pixel color within a preset range around any pixel in the target text control, that is, the surrounding background color. The purpose of this step is to eliminate the influence of the abnormal value of a single pixel (for example, a pixel with too high or too low brightness) on the background brightness calculation, and to improve the stability and reliability of the calculation results.
[0071] Exemplarily, the preprocessing operation may include averaging, median or weighted average calculation of the surrounding background colors, and the final target background color is a color value that comprehensively considers the local background and the surrounding environment, which is used for subsequent determination of background brightness and is not limited here.
[0072] After obtaining the target background color, the current background brightness is determined based on the target background color, which can be understood as converting the target background color into a brightness value that can be used for subsequent dynamic text color calculations, namely, the current background brightness.
[0073] Thus, the accuracy and stability of the background brightness calculation are ensured. Through fine sampling and preprocessing of color information and brightness calculation, the present application can adjust the color of text controls in real time according to changes in the game scene to improve readability and recognition while maintaining the lightweight and visual consistency of the UI interface.
[0074] In a possible implementation, in step S2031, sampling color information based on the target screen coordinates of the target text control to obtain the first background color may include the following execution steps:
[0075] Step S20311, obtaining the target pixel shader mounted by the target text control;
[0076] Step S20312: sampling the color information based on the target screen coordinates in the target pixel shader to obtain a first background color.
[0077] In an embodiment of the present application, when the color information is sampled based on the target screen coordinates of the target text control to obtain the first background color, the target pixel shader mounted on the target text control can be obtained. It can be understood that in game development or UI design, each UI component, including text controls, is usually associated with one or more shaders. A shader is a program running on a graphics processor that processes and renders the color and lighting effects of a single pixel. For the target text control, the target pixel shader mounted on the target text control contains code for processing text display logic and color mixing calculations, which can directly operate pixel-level color information. By obtaining this specific pixel shader, it is ensured that the color information of the target text control can be processed using the correct logic and parameters.
[0078] After obtaining the target pixel shader, the color information is sampled based on the target screen coordinates in the target pixel shader to obtain the first background color. It can be understood that the color information sampling based on the target screen coordinates is performed inside the target pixel shader, and the target screen coordinates are the position information of the target text control on the screen. In the target pixel shader, these target screen coordinates are used to access the color information previously extracted from the rendering cache to perform pixel-level color sampling.
[0079] It can be understood that, for each pixel in the target text control, the target pixel shader reads the pixel color of the background corresponding to the pixel in the screen coordinates to obtain the first background color.
[0080] Therefore, by obtaining the target pixel shader of the target text control and sampling the background color in the target pixel shader based on the target screen coordinates, the background color behind the target text control can be accurately determined without being affected by the color of the UI layer itself. Compared with traditional logic processing or average color calculation using a limited number of pixels, this application provides higher accuracy and real-time performance, ensuring that the dynamic color adaptation technology can respond quickly to the color changes of each pixel in the game scene, thereby improving the readability and visual consistency of the text.
[0081] In a possible implementation, in step S2032, performing a preprocessing operation on the first background color based on the surrounding background colors to obtain the target background color may include the following execution steps:
[0082] Step S20321, performing a fuzzy operation on the first background color based on the surrounding background colors to obtain a second background color;
[0083] Step S20322: adjusting the resolution of the second background color based on the surrounding background color to obtain a target background color.
[0084] In an embodiment of the present application, when the first background color is preprocessed based on the surrounding background color to obtain the target background color, the first background color can be blurred based on the surrounding background color to obtain the second background color, and then the resolution of the second background color can be adjusted based on the surrounding background color to obtain the target background color.
[0085] It is understandable that after obtaining the first background color at the pixel level, local color anomalies or noise may be encountered. These anomalies may come from special effects, texture details or lighting changes in the game scene. Directly using these color information may cause the dynamic adjustment of the text color to be too abrupt or unstable. Therefore, this application will perform a blurring operation, that is, mixing the first background color with the surrounding background color to obtain the second background color.
[0086] The blurring operation is essentially a filtering or smoothing process, which may use algorithms such as Gaussian blur, mean filtering or median filtering to perform weighted averaging of the background pixel colors within a preset range behind the target text control, thereby reducing the impact of color anomalies and obtaining smoother and more stable background color information. This helps ensure that the adjustment of text color appears natural and smooth even in rapidly changing scenes.
[0087] After obtaining the second background color, the resolution of the second background color is adjusted based on the surrounding background colors to obtain the target background color. It can be understood that based on the second background color, the resolution is further adjusted to match the display requirements of the text control to obtain the final target background color.
[0088] Among them, the purpose of adjusting the resolution is to optimize computing efficiency and visual effects. Since the second background color is obtained by blurring the surrounding background colors, it may have a higher resolution, that is, it contains a lot of details, but in some cases, these details are not necessary for the dynamic adjustment of the text color, but may increase the computing load. Therefore, it is necessary to adjust the resolution of the second background color according to the size and display requirements of the text control, such as downsampling, resampling or resolution scaling operations, so as to obtain a target background color that can reflect the color characteristics of the surrounding background and match the display requirements of the text control.
[0089] Therefore, by blurring the first background color and adjusting the resolution, smoother and more stable background color information can be obtained, and the balance between computing efficiency and visual effects can be ensured, thereby effectively improving the stability and usability of the dynamic text color adaptation algorithm, avoiding visual discomfort caused by color mutations, and ensuring the clarity and readability of text information in the game and its harmony with the background.
[0090] In a possible implementation, the text color determination method further includes:
[0091] Stores the render cache in a preset storage area.
[0092] In the embodiment of the present application, the preset storage area can be understood as a memory buffer designed to optimize graphics performance and resource management. Exemplarily, the preset storage area includes but is not limited to a frame buffer, a texture buffer, a vertex buffer, a shader storage buffer, a rendering target, and a temporary buffer, which are not limited here.
[0093] Storing the rendering cache in a preset storage area can be understood as an operation in which, in computer graphics processing or game development, image data or intermediate calculation results generated during the graphics rendering process are purposefully stored in a predefined memory area specifically used to store such data in order to optimize performance and achieve specific visual effects. This is not limited here.
[0094] In the embodiment of the present application, by storing the rendering cache in a preset storage area, not only the efficiency of graphics processing can be improved, but also more complex and higher-quality visual effects can be achieved, while facilitating data management and debugging.
[0095] In a possible implementation, the text control determination method further includes:
[0096] Dynamically apply the current color to be displayed in the target text control to the target text control.
[0097] In an embodiment of the present application, after determining the current color of the target text control to be displayed, the current color of the target text control to be displayed can be dynamically applied to the target text control, so that for each game screen frame, the color of the target text control will be automatically adjusted according to the changes in the background to maintain the clarity and recognizability of the text.
[0098] It can be seen that in the embodiment of the present application, by calculating the contrast and hue relationship of different parts of the picture, the technical effect of dynamically changing the color of the text according to the actual situation is achieved. The specific steps are: first, extract the rendering buffer of the UE for pre-storage. That is, the program obtains the interface provided by the pre-agreed program through the code and uses the engine for rendering. There are similar interfaces in other engines, which are basically 3D worlds. After removing the UI layer, extract all the content of the game's 3D world and the content of subsequent processing. Pre-store the extracted rendering buffer in a public full-screen screenshot memory for temporary storage.
[0099] Then, the buffer information is identified by the shader on the text control, and the text is mixed and discolored. That is, first of all, the buffer is a screenshot of the 3D world in the engine before the UI control is rendered. The UI text control can get its own screen control UV in the shader. Using this UV to get the content of the full-screen buffer can get the 3D background display content behind the UI. The text control here is equal to the UI text control, which is a UI functional component unit. Shader materials can be hung on it to modify the text performance. Each text UI control can hang a shader and modify the display calculation. The buffer is a full-screen screenshot buffer, not just belonging to a certain UI text control. The UI text control only processes its own display and uses the public full-screen buffer. Mixed color change is specifically a set of two colors given by the GUI that meet the specific font and function requirements in the game, corresponding to the display under extremely dark and extremely bright backgrounds respectively. After getting these two colors in the shader, interpolation display is performed according to the brightness of the background. Specifically, the color changes in each UI text control, and the calculation is done based on each background pixel in the material shader. Therefore, the text color changes very accurately, which is more delicate than a single text. A text may be displayed in two colors on the left and right, that is, a text may change into multiple colors delicately.
[0100] Then, each text control is divided into two directions: color change and color, background highlight and background too dark, and finally, through the background blending calculation and the setting of percentage parameters, the interpolation between the two color contrasts is smoothly transitioned. Since the color change is performed in the shader, it is a pixel-level color change, so there is no need to split the text. According to the pixel background brightness of a text, the color can be temporarily and dynamically changed in the game to the pixel level. Among them, color refers to the static value, and color change refers to the action of changing the color by interpolating between two colors. Background highlight and background too dark belong to the judgment of a float brightness value. Assuming that the brightest is 1 and the darkest is 0, according to this brightness value, linear interpolation is performed between the UI text color that should be displayed on the brightest background and the color that should be displayed on the darkest background. By setting a material shader for each UI text control, the background behind the entire text control is determined. The material shader has its own brightest and darkest colors passed in as parameters, and then the shader is displayed according to the brightness of each background pixel. The background blending calculation is specifically linear interpolation (the darkest UI background shows the text color, the brightest UI background shows the text color, and the background brightness). The background brightness is a value from 0 to 1, which can be understood as from 0% to 100%. Through the above method, the function of text color changing dynamically according to the scene color is realized.
[0101] This application not only has a precise percentage value correspondence, but also changes the gradual change of the color change process to a direct color cut to determine the bright and dark areas, that is, there is no need to solve the smoothness problem in time, and the color can be changed immediately in the current frame shader. In terms of visual appearance, it is not abrupt because the shaking of the color change background at the pixel level will not be reflected in the entire UI control, and there is no problem of the entire UI control changing color and flickering. By judging the color change, the user can clearly see the text, and it is also combined with the text color customized by the project to achieve the purpose of standardization.
[0102] Through the above steps, in the context of an interface with complex contrast, the present application can accurately control the dynamic font color, allowing users to clearly read the text, and under the premise of ensuring the lightweight UI, it solves the adaptability problem of text information, that is, there is no need to add a circle of bloated grooves around the text to achieve the purpose of protruding and clear display. With this automatic color change, you can completely cancel a circle of grooves and still display UI text clearly. The present application can also ensure recognition and enhance visual effects, ensure brand consistency, make the UI more consistent and professional, and the present application can not only accurately judge highlights and too dark backgrounds technically, but also quickly realize dynamic font color changes. Since the present application can be developed quickly, is easy to use, does not require complex logic and high performance requirements, and intuitiveness and rapid iteration are the greatest advantages of the present application, the present application does not need to load a large amount of resources, that is, the present application has low memory overhead, low performance consumption, and high modification efficiency.
[0103] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0104] In this embodiment, a text color determination device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0105] Figure 3 is a structural block diagram of a text color determination device according to one embodiment of the present application. Figure 3 As shown, taking a text color determination device 300 as an example, the text color determination device 300 includes: a first acquisition module 301, used to obtain the current background brightness of the background where the target text control is located; a second acquisition module 302, used to obtain a first color and a second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness; a determination module 303, used to determine the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0106] Optionally, the determination module 303 is further used to: perform interpolation calculation between the first color and the second color based on the current background brightness and a preset linear interpolation function to obtain the current color to be displayed of the target text control.
[0107] Optionally, the first acquisition module 301 is further used to: acquire a rendering cache of a target screen frame, wherein the target screen frame includes a target text control; determine color information of the target screen frame based on the rendering cache; and determine current background brightness based on the color information.
[0108] Optionally, the first acquisition module 301 is also used to: sample color information based on the target screen coordinates of the target text control to obtain a first background color, wherein the first background color is used to represent the background pixel color corresponding to any pixel in the target text control; preprocess the first background color based on the surrounding background color to obtain a target background color, wherein the surrounding background color is used to represent the background pixel color within a preset range around any pixel in the target text control; determine the current background brightness based on the target background color.
[0109] Optionally, the first acquisition module 301 is further used to: acquire a target pixel shader mounted on a target text control; and sample color information in the target pixel shader based on target screen coordinates to obtain a first background color.
[0110] Optionally, the first acquisition module 301 is further used to: perform a blurring operation on the first background color based on the surrounding background color to obtain a second background color; and adjust the resolution of the second background color based on the surrounding background color to obtain a target background color.
[0111] Optionally, the device further includes: a storing module, configured to store the rendering cache into a preset storage area.
[0112] Optionally, the device further includes: an application module, configured to dynamically apply the color currently to be displayed by the target text control to the target text control.
[0113] Thus, by obtaining the current background brightness of the background where the target text control is located, the first color and the second color are obtained at the same time, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by calculating based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition under the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and the memory and performance consumption are reduced, thereby solving the technical problems that the UMG technology or Slate framework is used in the related art to realize dynamic text color, resulting in a complex development process, large memory usage, high performance consumption, and it is difficult to ensure clear readability and recognition of text information under the interface background with complex contrast.
[0114] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0115] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0116] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0117] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0118] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0119] Step S20, obtaining the current background brightness of the background where the target text control is located;
[0120] Step S22, obtaining a first color and a second color, wherein the first color is a color of the text control corresponding to the first background brightness, and the second color is a color of the text control corresponding to the second background brightness;
[0121] Step S24, determining the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0122] In the computer-readable storage medium of this embodiment, a technical solution of a method for determining text color is provided, by obtaining the current background brightness of the background where the target text control is located, and simultaneously obtaining the first color and the second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be currently displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by calculating based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition in the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and memory and performance consumption are reduced, thereby solving the technical problems of using UMG technology or Slate framework to achieve dynamic text color in related technologies, resulting in a complex development process, large memory usage, high performance consumption, and difficulty in ensuring clear readability and recognition of text information in an interface background with complex contrast.
[0123] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0124] In an exemplary embodiment of the present application, a program product capable of implementing the above method of the present embodiment is stored on a computer-readable storage medium. In some possible implementations, various aspects of the embodiments of the present application can also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of various exemplary implementations of the present application described in the above "Exemplary Method" section of the present embodiment.
[0125] According to the program product for implementing the above method according to the embodiment of the present application, it can adopt a portable compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present application is not limited to this. In the embodiment of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0126] The program product may be in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Electrically Programmable Read-Only Memory, EPROM) or flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0127] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the above.
[0128] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0129] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0130] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0131] Step S20, obtaining the current background brightness of the background where the target text control is located;
[0132] Step S22, obtaining a first color and a second color, wherein the first color is a color of the text control corresponding to the first background brightness, and the second color is a color of the text control corresponding to the second background brightness;
[0133] Step S24, determining the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0134] In the electronic device of this embodiment, a technical solution of a method for determining text color is provided, by obtaining the current background brightness of the background where the target text control is located, and simultaneously obtaining the first color and the second color, wherein the first color is the text control color corresponding to the first background brightness, and the second color is the text control color corresponding to the second background brightness, and then based on the first color, the second color and the current background brightness, the color of the target text control to be currently displayed is determined. The purpose of dynamically determining the display color of the text control is achieved, thereby realizing the dynamic determination of the text color according to the real-time brightness of the background where the target text control is located, ensuring the clear visibility and high recognition of the text under different lighting conditions and background complexity. At the same time, by performing calculations based on the preset first color and second color, the sudden jump of the text color when the background brightness changes can be avoided, providing a smoother and continuous visual effect, and the text can also ensure clear readability and recognition in the interface background with complex contrast. In addition, by performing simple calculations, the logical processing burden of the processor is reduced, and memory and performance consumption are reduced, thereby solving the technical problems of using UMG technology or Slate framework to achieve dynamic text color in related technologies, resulting in a complex development process, large memory usage, high performance consumption, and difficulty in ensuring clear readability and recognition of text information in an interface background with complex contrast.
[0135] Figure 4 is a schematic diagram of an electronic device according to an embodiment of the present application. Figure 4 As shown, the electronic device 400 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0136] like Figure 4 As shown, the electronic device 400 is in the form of a general computing device. The components of the electronic device 400 may include but are not limited to: at least one processor 410, at least one memory 420, a bus 430 connecting different system components (including the memory 420 and the processor 410), and a display 440.
[0137] The memory 420 stores program codes, which can be executed by the processor 410, so that the processor 410 executes the steps described in the method section of the embodiment of the present application according to various exemplary implementations of the present application.
[0138] The memory 420 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 4201 and / or a cache memory unit 4202, and may further include a read-only memory unit (ROM) 4203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0139] In some examples, the memory 420 may also include a program / utility 4204 having a set (at least one) of program modules 4205, such program modules 4205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include the implementation of a network environment. The memory 420 may further include a memory remotely disposed relative to the processor 410, and these remote memories may be connected to the electronic device 400 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 combinations thereof.
[0140] Bus 430 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus of processor 410, or any of a variety of bus architectures.
[0141] The display 440 may be, for example, a touch screen liquid crystal display (LCD), which may enable a user to interact with a user interface of the electronic device 400 .
[0142] Optionally, the electronic device 400 may also communicate with one or more external devices 500 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 400, and / or any device that enables the electronic device 400 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 450. Furthermore, the electronic device 400 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 460. Figure 4 As shown, the network adapter 460 communicates with other modules of the electronic device 400 via the bus 430. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Array of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0143] The electronic device 400 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0144] It can be understood by those skilled in the art that Figure 4 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 4 More or fewer components as shown, or with Figure 1 The memory 420 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the text color determination method in the embodiment of the present application. The processor 410 executes various functional applications and data processing by running the computer program stored in the memory 420, that is, implementing the above-mentioned text color determination method.
[0145] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and the computer program implements the method provided in the embodiment when executed by a processor.
[0146] Optionally, the computer program included in the above-mentioned computer program product is executed by a processor to perform the following steps:
[0147] Step S20, obtaining the current background brightness of the background where the target text control is located;
[0148] Step S22, obtaining a first color and a second color, wherein the first color is a color of the text control corresponding to the first background brightness, and the second color is a color of the text control corresponding to the second background brightness;
[0149] Step S24, determining the current color to be displayed of the target text control based on the first color, the second color and the current background brightness.
[0150] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0151] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0153] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0154] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0155] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0156] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for determining text color, characterized in that: The method comprises: Get the current background brightness of the background where the target text control is located; Get a first color and a second color, wherein the first color is the color of the text control corresponding to the first background brightness, and the second color is the color of the text control corresponding to the second background brightness; Based on the first color, the second color and the current background brightness, a color to be currently displayed of the target text control is determined.
2. The method according to claim 1, characterized in that The determining, based on the first color, the second color, and the current background brightness, of a color to be currently displayed of the target text control comprises: An interpolation calculation is performed between the first color and the second color based on the current background brightness and a preset linear interpolation function to obtain a color to be currently displayed of the target text control.
3. The method according to claim 1, characterized in that The step of obtaining the current background brightness of the background where the target text control is located includes: Acquire a rendering cache of a target screen frame, wherein the target screen frame includes the target text control; Determining color information of the target picture frame based on the rendering buffer; The current background brightness is determined based on the color information.
4. The method according to claim 3, characterized in that The determining the current background brightness based on the color information comprises: Sampling the color information based on the target screen coordinates of the target text control to obtain a first background color, wherein the first background color is used to represent a background pixel color corresponding to any pixel in the target text control; Performing a preprocessing operation on the first background color based on the surrounding background color to obtain a target background color, wherein the surrounding background color is used to represent the background pixel color within a preset range around any pixel in the target text control; The current background brightness is determined based on the target background color.
5. The method according to claim 4, characterized in that The sampling of the color information based on the target screen coordinates of the target text control to obtain the first background color includes: Get the target pixel shader mounted by the target text control; The color information is sampled in the target pixel shader based on the target screen coordinates to obtain the first background color.
6. The method according to claim 4, characterized in that The performing a preprocessing operation on the first background color based on the surrounding background colors to obtain a target background color comprises: Performing a fuzzy operation on the first background color based on the surrounding background color to obtain a second background color; The resolution of the second background color is adjusted based on the surrounding background color to obtain the target background color.
7. The method according to claim 3, characterized in that The method further comprises: The rendering cache is stored in a preset storage area.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: The color currently to be displayed of the target text control is dynamically applied to the target text control.
9. A text color determination device, characterized in that: The device comprises: The first acquisition module is used to acquire the current background brightness of the background where the target text control is located; A second acquisition module is used to acquire a first color and a second color, wherein the first color is a color of the text control corresponding to the first background brightness, and the second color is a color of the text control corresponding to the second background brightness; A determination module is used to determine the color to be currently displayed of the target text control based on the first color, the second color and the current background brightness.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the text color determination method described in any one of claims 1 to 8 when running on a computer or a processor.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the text color determination method as claimed in any one of claims 1 to 8 when being executed by a processor.
12. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the text color determination method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Text display method and device and storage medium
CN108287744A
Method for adjusting character colors of application interface, storage medium and terminal equipment
CN110780961A
Method and device for adjusting text color
CN114089994A
Text display method and device, computer equipment and storage medium
CN114968426A
Character color determination method and device, medium, electronic equipment and program product
CN118840453A