Document display method and device
By changing the color of the elements in the document view area in the dark mode of the word processing software, the problem of the lack of color transformation of special elements in the dark mode is solved, and the display effect and user experience are improved.
Patent Information
- Application Number
- CN202311520047.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-14
- Publication Date
- 2025-05-16
AI Technical Summary
When word processing software switches from light to dark mode, special elements (such as cursor) in the document (such as the cursor) lack color changes, affecting the display effect of the document.
When the word processing software is in the preset color mode, by obtaining the elements in the electronic document currently displayed in the document view area, the target color component is determined based on the initial color component of the element, and color transformation is performed to display the element.
Through color change, the display effect of electronic documents is improved, the user experience is improved, the user's eye fatigue is relieved, and the user's eyes are protected.
Smart Images

Figure CN120012710A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a document display method and device. Background Art
[0002] With the development of computers, people's daily office work has gradually become electronic, and various types of electronic documents have been gradually used for office work, so various types of word processing software (such as WPS Office) have developed rapidly. Among them, the display of word processing software depends on the display. In order to improve the user experience, relieve the user's eye fatigue, and protect the user's eyes, various types of word processing software provide dark mode.
[0003] Currently, when the mode of a word processing software is switched from a light mode to a dark mode, the background of the document view area in the word processing software is set to black, and for the document currently being displayed in the document view area, the black text in the document is changed to white text, and the text of other colors is also changed in color. However, in addition to text elements, there are other special elements in the document (such as the cursor), which lack corresponding color changes, affecting the display of the document. Summary of the invention
[0004] In order to solve the technical problem that in addition to text elements, there are other special elements (such as cursors) in the above document, which lack corresponding color changes and affect the display of the document, the embodiment of the present application provides a document display method, device, electronic device and storage medium. The specific technical solution is as follows:
[0005] In a first aspect of an embodiment of the present application, a document display method is first provided, the method comprising:
[0006] When the word processing software is in a preset color mode, setting the background of the document view area of the word processing software to the preset color;
[0007] Determine the electronic document currently displayed in the document view area, and obtain at least one element currently displayed in the electronic document;
[0008] For any of the elements, determining a target color component corresponding to the element according to an initial color component of an initial color of the element;
[0009] The initial color component is subjected to color transformation by using the target color component to obtain a target color, and the element is displayed with the target color.
[0010] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0011] The target color components include a target red component, a target green component and a target blue component;
[0012] The step of determining, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element comprises:
[0013] For any of the elements, obtaining the initial red component, the initial green component, and the initial blue component of the initial color of the element;
[0014] Determine a first brightness of the initial color by using the initial red component, the initial green component and the initial blue component;
[0015] Determining a color increment of the initial color according to the first brightness;
[0016] The initial red component, the initial green component and the initial blue component are processed by the color increment to obtain the target red component, the target green component and the target blue component corresponding to the element.
[0017] In an optional implementation, determining the first brightness of the initial color by using the initial red component, the initial green component, and the initial blue component includes:
[0018] A weighted sum is performed on the initial red component, the initial green component, and the initial blue component to obtain a first brightness of the initial color.
[0019] In an optional implementation, determining the color increment of the initial color by using the first brightness includes:
[0020] Obtaining a preset first value and a preset second value, and determining a product of the preset second value and the first brightness;
[0021] Determine a difference between a product of the preset second value and the first brightness and the preset first value;
[0022] The difference is determined as a color increment of the initial color.
[0023] In an optional implementation, the processing of the initial red component, the initial green component, and the initial blue component by the color increment to obtain the target red component, the target green component, and the target blue component corresponding to the element includes:
[0024] Determine the sum of the initial red component and the color increment, and determine the sum of the initial red component and the color increment as the target red component corresponding to the element;
[0025] Determine a sum of the initial green component and the color increment, and determine the sum of the initial green component and the color increment as the target green component corresponding to the element;
[0026] A sum of the initial blue component and the color increment is determined, and the sum of the initial blue component and the color increment is determined as the target blue component corresponding to the element.
[0027] In an optional implementation, performing color transformation on the initial color component by using the target color component to obtain the target color includes:
[0028] transforming the initial red component into the target red component;
[0029] transforming the initial green component into the target green component;
[0030] Transforming the initial blue component into the target blue component;
[0031] The target color is obtained by superimposing the target red component, the target green component and the target blue component.
[0032] In an optional implementation, the transforming the initial red component into the target red component includes:
[0033] Determining whether the target red component is within a preset value range;
[0034] When the target red component is within the preset value range, the initial red component is transformed into the target red component.
[0035] In an optional embodiment, the method further comprises:
[0036] When the target red component is not within the preset value range, determining whether the target red component is greater than a preset first value;
[0037] In the case where the target red component is greater than the preset first value, the target red component is converted to the preset first value, and the initial red component is converted to the target red component;
[0038] or,
[0039] When the target red component is not within the preset value range, determining whether the target red component is less than a preset third value;
[0040] In the case where the target red component is smaller than the preset third value, the target red component is transformed into the preset third value, and the initial red component is transformed into the target red component.
[0041] In an optional implementation, the transforming the initial green component into the target green component comprises:
[0042] Determining whether the target green component is within a preset value range;
[0043] When the target green component is within the preset value range, the initial green component is transformed into the target green component.
[0044] In an optional embodiment, the method further comprises:
[0045] In the case where the target green component is not within the preset value range, determining whether the target green component is greater than a preset first value;
[0046] In the case where the target green component is greater than the preset first value, the target green component is transformed into the preset first value, and the initial green component is transformed into the target green component;
[0047] or,
[0048] When the target green component is not within the preset value range, determining whether the target green component is less than a preset third value;
[0049] In the case where the target green component is smaller than the preset third value, the target green component is transformed into the preset third value, and the initial green component is transformed into the target green component.
[0050] In an optional embodiment, the method further comprises:
[0051] When the target blue component is not within the preset value range, determining whether the target blue component is greater than a preset first value;
[0052] When the target blue component is greater than the preset first value, the target blue component is transformed into the preset first value, and the initial blue component is transformed into the target blue component;
[0053] or,
[0054] When the target blue component is not within the preset value range, determining whether the target blue component is less than a preset third value;
[0055] When the target blue component is smaller than the preset third value, the target blue component is transformed into the preset third value, and the initial blue component is transformed into the target blue component.
[0056] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0057] The target color components include a target red component, a target green component and a target blue component;
[0058] The step of determining, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element comprises:
[0059] For any of the elements, obtaining the initial red component, the initial green component, and the initial blue component of the initial color of the element;
[0060] Obtaining a preset first value, determining a difference between the preset first value and the initial red component, and determining the difference between the preset first value and the initial red component as a target red component corresponding to the element;
[0061] Determine a difference between the preset first value and the initial green component, and determine the difference between the preset first value and the initial green component as a target green component corresponding to the element;
[0062] A difference between the preset first value and the initial blue component is determined, and the difference between the preset first value and the initial blue component is determined as a target blue component corresponding to the element.
[0063] In an optional implementation, performing color transformation on the initial color component by using the target color component to obtain the target color includes:
[0064] Convert the target red component, the target green component and the target blue component into hue, a second brightness and a saturation;
[0065] Transforming the hue to obtain a target hue, and converting the target hue, the second brightness, and the saturation into a final red component, a final green component, and a final blue component;
[0066] Transforming the initial red component into the final red component, transforming the initial green component into the final green component, and transforming the initial blue component into the final blue component;
[0067] The target color is obtained by superimposing the final red component, the final green component and the final blue component.
[0068] In an optional implementation, the transforming the hue to obtain a target hue includes:
[0069] Obtaining a preset fourth value and a preset fifth value, and determining the sum of the hue and the preset fourth value;
[0070] The sum of the hue and the preset fourth value is modulo-operated with the preset fifth value to obtain the target hue.
[0071] In an optional implementation, before obtaining the initial red component, the initial green component, and the initial blue component of the initial color of any of the elements, the method further includes:
[0072] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0073] In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0074] or,
[0075] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0076] In the case that there is no preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0077] In an optional implementation, before obtaining the initial red component, the initial green component, and the initial blue component of the initial color of any of the elements, the method further includes:
[0078] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0079] In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0080] or,
[0081] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0082] In the case where there is a preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0083] In a second aspect of the embodiments of the present application, a document display device is further provided, the device comprising:
[0084] A background setting module, used to set the background of the document view area of the word processing software to a preset color when the word processing software is in a preset color mode;
[0085] A document determination module, used to determine the electronic document currently displayed in the document view area;
[0086] An element acquisition module, used to acquire at least one element being displayed in the electronic document;
[0087] A component determination module, configured to determine, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element;
[0088] The color conversion module is used to perform color conversion on the initial color component through the target color component to obtain a target color, and display the element with the target color.
[0089] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0090] The target color components include a target red component, a target green component and a target blue component;
[0091] The component determination module specifically includes:
[0092] A component acquisition submodule, used for acquiring, for any of the elements, the initial red component, the initial green component and the initial blue component of the initial color of the element;
[0093] a brightness determination submodule, configured to determine a first brightness of the initial color according to the initial red component, the initial green component and the initial blue component;
[0094] an increment determination submodule, configured to determine a color increment of the initial color according to the first brightness;
[0095] The component processing submodule is used to process the initial red component, the initial green component and the initial blue component through the color increment to obtain the target red component, the target green component and the target blue component corresponding to the element.
[0096] In an optional implementation, the brightness determination submodule is specifically used to:
[0097] A weighted sum is performed on the initial red component, the initial green component, and the initial blue component to obtain a first brightness of the initial color.
[0098] In an optional implementation, the increment determination submodule is specifically used to:
[0099] Obtaining a preset first value and a preset second value, and determining a product of the preset second value and the first brightness;
[0100] Determine a difference between a product of the preset second value and the first brightness and the preset first value;
[0101] The difference is determined as a color increment of the initial color.
[0102] In an optional implementation, the component processing submodule is specifically used for:
[0103] Determine the sum of the initial red component and the color increment, and determine the sum of the initial red component and the color increment as the target red component corresponding to the element;
[0104] Determine a sum of the initial green component and the color increment, and determine the sum of the initial green component and the color increment as the target green component corresponding to the element;
[0105] A sum of the initial blue component and the color increment is determined, and the sum of the initial blue component and the color increment is determined as the target blue component corresponding to the element.
[0106] In an optional implementation, the color conversion module specifically includes:
[0107] A red component conversion submodule, used for converting the initial red component into the target red component;
[0108] A green component conversion submodule, used for converting the initial green component into the target green component;
[0109] A blue component conversion submodule, used for converting the initial blue component into the target blue component;
[0110] The component superposition submodule is used to obtain a target color by superimposing the target red component, the target green component and the target blue component.
[0111] In an optional implementation, the red component transformation submodule is specifically used for:
[0112] Determining whether the target red component is within a preset value range;
[0113] When the target red component is within the preset value range, the initial red component is transformed into the target red component.
[0114] In an optional implementation, the red component transformation submodule is further used for:
[0115] When the target red component is not within the preset value range, determining whether the target red component is greater than a preset first value;
[0116] In the case where the target red component is greater than the preset first value, the target red component is converted to the preset first value, and the initial red component is converted to the target red component;
[0117] or,
[0118] When the target red component is not within the preset value range, determining whether the target red component is less than a preset third value;
[0119] In the case where the target red component is smaller than the preset third value, the target red component is transformed into the preset third value, and the initial red component is transformed into the target red component.
[0120] In an optional implementation, the green component conversion submodule is specifically used for:
[0121] Determining whether the target green component is within a preset value range;
[0122] When the target green component is within the preset value range, the initial green component is transformed into the target green component.
[0123] In an optional implementation, the green component transformation submodule is further used for:
[0124] In the case where the target green component is not within the preset value range, determining whether the target green component is greater than a preset first value;
[0125] In the case where the target green component is greater than the preset first value, the target green component is transformed into the preset first value, and the initial green component is transformed into the target green component;
[0126] or,
[0127] When the target green component is not within the preset value range, determining whether the target green component is less than a preset third value;
[0128] In the case where the target green component is smaller than the preset third value, the target green component is transformed into the preset third value, and the initial green component is transformed into the target green component.
[0129] In an optional implementation, the blue component transformation submodule is specifically used for:
[0130] Determining whether the target blue component is within a preset value range;
[0131] When the target blue component is within the preset value range, the initial blue component is transformed into the target blue component.
[0132] In an optional implementation, the blue component transformation submodule is further used for:
[0133] When the target blue component is not within the preset value range, determining whether the target blue component is greater than a preset first value;
[0134] When the target blue component is greater than the preset first value, the target blue component is transformed into the preset first value, and the initial blue component is transformed into the target blue component;
[0135] or,
[0136] When the target blue component is not within the preset value range, determining whether the target blue component is less than a preset third value;
[0137] When the target blue component is smaller than the preset third value, the target blue component is transformed into the preset third value, and the initial blue component is transformed into the target blue component.
[0138] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0139] The target color components include a target red component, a target green component and a target blue component;
[0140] The component determination module specifically includes:
[0141] A component acquisition submodule, used for acquiring, for any of the elements, the initial red component, the initial green component and the initial blue component of the initial color of the element;
[0142] a red component determination submodule, configured to obtain a preset first value, determine a difference between the preset first value and the initial red component, and determine the difference between the preset first value and the initial red component as a target red component corresponding to the element;
[0143] A green component determination submodule, used to determine a difference between the preset first value and the initial green component, and determine the difference between the preset first value and the initial green component as a target green component corresponding to the element;
[0144] The blue component submodule is used to determine the difference between the preset first value and the initial blue component, and determine the difference between the preset first value and the initial blue component as the target blue component corresponding to the element.
[0145] In an optional implementation, the color conversion module specifically includes:
[0146] A component conversion submodule, used for converting the target red component, the target green component and the target blue component into hue, second brightness and saturation;
[0147] A hue transformation submodule, used to transform the hue to obtain a target hue;
[0148] A hue, brightness, and saturation conversion submodule, used to convert the target hue, the second brightness, and the saturation into a final red component, a final green component, and a final blue component;
[0149] a component conversion submodule, configured to convert the initial red component into the final red component, convert the initial green component into the final green component, and convert the initial blue component into the final blue component;
[0150] The component superposition submodule is used to obtain a target color by superimposing the final red component, the final green component and the final blue component.
[0151] In an optional implementation, the hue conversion submodule is specifically used for:
[0152] Obtaining a preset fourth value and a preset fifth value, and determining the sum of the hue and the preset fourth value;
[0153] The sum of the hue and the preset fourth value is modulo-operated with the preset fifth value to obtain the target hue.
[0154] In an optional implementation, the component acquisition submodule is specifically used to:
[0155] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0156] In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0157] or,
[0158] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0159] In the case that there is no preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0160] In an optional implementation, the component acquisition submodule is specifically used to:
[0161] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0162] In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0163] or,
[0164] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0165] In the case where there is a preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0166] In a third aspect of the embodiments of the present application, there is further provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0167] Memory, used to store computer programs;
[0168] The processor is used to implement any document display method described in the first aspect when executing the program stored in the memory.
[0169] In a fourth aspect of the embodiments of the present application, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the storage medium is run on a computer, the computer executes any document display method described in the first aspect above.
[0170] In a fifth aspect of the embodiments of the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the document display methods described above.
[0171] The technical solution provided by the embodiment of the present application is that when the word processing software is in a preset color mode, the background of the document view area of the word processing software is set to a preset color, the electronic document currently displayed in the document view area is determined, at least one element being displayed in the electronic document is obtained, and for any element, the target color component corresponding to the element is determined according to the initial color component of the initial color of the element, the initial color component is color-converted by the target color component to obtain the target color, and the element is displayed with the target color. When the word processing software is in a preset color mode, by setting the background of the document view area of the word processing software to a preset color, at least one element being displayed in the electronic document currently displayed in the document view area is obtained, and for any element, the target color component corresponding to the element is determined according to the initial color component of the initial color of the element, and the initial color is color-converted by the target color to obtain the target color, and the element is displayed with the target color, so that the color of at least one element being displayed in the electronic document currently displayed in the document view area is converted, the display effect of the electronic document is improved, the user experience is improved, and the user's eye fatigue can be relieved and the user's eyes can be protected. BRIEF DESCRIPTION OF THE DRAWINGS
[0172] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0173] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0174] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0175] Figure 1 A schematic diagram of an implementation flow of a document display method shown in an embodiment of the present application;
[0176] Figure 2 It is a schematic diagram of an implementation process of another document display method shown in an embodiment of the present application;
[0177] Figure 3 It is a schematic diagram of an implementation process of another document display method shown in an embodiment of the present application;
[0178] Figure 4 A schematic diagram of the structure of a document display device shown in an embodiment of the present application;
[0179] Figure 5 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0180] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, 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 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 making creative work are within the scope of protection of this application.
[0181] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0182] In an embodiment of the present application, in order to improve the display effect of electronic documents, improve user experience, relieve user eye fatigue, and protect user eyes, when the word processing software is in a preset color mode (e.g., dark mode or dark mode), in addition to setting the background of the document view area of the word processing software to a preset color (e.g., black corresponding to the dark or dark mode), the color of at least one element currently displayed in the electronic document currently displayed in the document view area is changed.
[0183] It should be noted that for at least one element being displayed in the electronic document, for example, it can be text, cursor, highlight, strikethrough, underline, path (such as square, rectangle), annotation, watermark, header and footer, etc., as for pictures, they are not affected by the background, that is, they are not affected by the preset color mode, so there is no need to perform color conversion. Therefore, the above-mentioned elements do not include pictures, and the embodiments of the present application are not limited to this.
[0184] Based on this, Figure 1 FIG. 1 is a schematic diagram of an implementation flow of a document display method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:
[0185] S101, when the word processing software is in a preset color mode, setting the background of the document view area of the word processing software to a preset color.
[0186] In the embodiments of the present application, usually, for word processing software, it is in an initial color mode (for example, light color mode). At this time, the background of the document view area (the area in the word processing software used to display electronic documents) of the word processing software is generally set to an initial color such as white, and for the electronic document being displayed in the document view area, the text and other elements therein can be displayed in black, for example.
[0187] Since users experience visual fatigue after viewing electronic documents for a long time, in order to improve user experience, relieve user eye fatigue, and protect user eyes, a preset color mode (such as dark mode or dark mode) is provided for word processing software. Therefore, for the user, a mode switching instruction can be triggered, which is used to instruct to switch from the initial color mode (such as light mode) to the preset color mode (such as dark mode or dark mode), and can be triggered by a button.
[0188] Thus, in response to the mode switching instruction, the mode of the word processing software is switched from the initial color mode (e.g., light mode) to the preset color mode (e.g., dark mode or dark black mode), so that the word processing software can achieve mode switching. When the word processing software is in the preset color mode (e.g., dark mode or dark black mode), the background of the document view area of the word processing software can be set to the preset color (e.g., dark or black).
[0189] It should be noted that for preset colors, such as dark colors, generally refer to colors whose color purity is lower than a preset threshold value as dark colors, and color purity refers to the purity of the color. Dark colors generally refer to black, dark blue, brown, dark green, cyan, etc., while light colors are the opposite of dark colors, and generally refer to colors whose color purity is not lower than a preset threshold value as light colors, generally refer to white, yellow, pink, sky blue, light green, etc., and the embodiments of the present application do not limit this.
[0190] S102: Determine the electronic document currently displayed in the document view area, and obtain at least one element currently displayed in the electronic document.
[0191] In an embodiment of the present application, for word processing software, there is generally a certain document view area that can be used to display electronic documents, so that the electronic document currently displayed in the document view area in the word processing software can be determined, and at least one element being displayed in the electronic document needs to be obtained.
[0192] Among them, for the at least one element being displayed in the electronic document, it can be at least one element being displayed in the entire area of the electronic document, or the user selects a specific area in the electronic document, so that it can be at least one element being displayed in the specific area of the electronic document, thereby achieving a color change effect of the elements in the specific area of the electronic document.
[0193] It should be noted that for an electronic document, there is at least one element, such as text. Some of these elements may be hidden and some may be displayed, so it is necessary to change the color of the elements in the displayed state. Based on this, it is necessary to obtain at least one element being displayed in the electronic document. The embodiments of the present application are not limited to this.
[0194] In addition, what is currently displayed in the document view area may not be an electronic document, but may be a scanned copy, such as a PDF scanned copy. In this case, the scanned copy can be converted into a layout electronic document first, and then the program continues to execute to obtain at least one element currently displayed in the layout electronic document.
[0195] Among them, the at least one element being displayed in the layout electronic document can specifically be text, cursor, highlight, strikethrough, underline, path (such as square, rectangle), annotation, watermark, header or footer, etc., which is not limited in this embodiment of the present application.
[0196] S103: for any element, determine a target color component corresponding to the element according to an initial color component of the initial color of the element.
[0197] S104, performing color transformation on the initial color component through the target color component to obtain a target color, and displaying the element with the target color.
[0198] In an embodiment of the present application, for any element being displayed in an electronic document, the initial color of the element, that is, the current color of the element, can be obtained, and the target color component of the element can be determined based on the initial color component of the initial color of the element. The initial color component is transformed by the target color component to obtain the target color, so that the element can be displayed with the target color, thereby achieving color transformation of the element.
[0199] It should be noted that the initial color of an element is usually expressed in RGB. If it is not expressed in RGB, it must be converted into a color expressed in RGB. The corresponding initial color components include an initial red component, an initial green component, and an initial blue component. The target color components include a target red component, a target green component, and a target blue component. The embodiments of the present application are not limited to this.
[0200] In addition, the initial red component usually refers to the value of the R (red) channel, which ranges from 0 to 255, and the same is true for the target red component; the initial green component usually refers to the value of the G (green) channel, which ranges from 0 to 255, and the same is true for the target green component; the initial blue component usually refers to the value of the B (blue) channel, which ranges from 0 to 255, and the same is true for the target blue component.
[0201] Through the above description of the technical solution provided by the embodiment of the present application, when the word processing software is in a preset color mode, the background of the document view area of the word processing software is set to a preset color, the electronic document currently displayed in the document view area is determined, and at least one element being displayed in the electronic document is obtained. For any element, the target color component corresponding to the element is determined according to the initial color component of the initial color of the element, the initial color component is transformed by the target color component to obtain the target color, and the element is displayed with the target color.
[0202] When the word processing software is in a preset color mode, by setting the background of the document view area of the word processing software to the preset color, obtaining at least one element being displayed in the electronic document currently displayed in the document view area, for any element, determining the target color component corresponding to the element through the initial color component of the initial color of the element, performing color transformation on the initial color to obtain the target color, and displaying the element with the target color, the color transformation is performed on at least one element being displayed in the electronic document currently displayed in the document view area, thereby improving the display effect of the electronic document, improving the user experience, relieving the user's eye fatigue, and protecting the user's eyes.
[0203] It should be noted that the above embodiment describes a process in which the color of an element being displayed in an electronic document changes from light to dark. Correspondingly, for an element being displayed in an electronic document, the process in which the color changes from dark to light is reversible to the process in which the color changes from light to dark, that is, the color transformation principle of the above embodiment can also be used to achieve the process in which the color changes from dark to light, which means that when the preset color mode is a light mode, the word processing software is in a light mode, and thus when the word processing software is in a light mode, the background of the document view area of the word processing software is set to a light color, the electronic document currently displayed in the document view area is determined, at least one element being displayed in the electronic document is obtained, and for any element, a target color component corresponding to the element is determined according to an initial color component of the initial color of the element, the initial color component is transformed by the target color component to obtain a target color, and the element is displayed with the target color.
[0204] like Figure 2 FIG. 1 is a schematic diagram of an implementation flow of another document display method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:
[0205] S201, when the word processing software is in a preset color mode, setting the background of the document view area of the word processing software to a preset color.
[0206] In the embodiment of the present application, this step is similar to the above-mentioned step S101, and the embodiment of the present application will not be described one by one here.
[0207] S202: Determine the electronic document currently displayed in the document view area, and obtain at least one element currently displayed in the electronic document.
[0208] In the embodiment of the present application, this step is similar to the above-mentioned step S102, and the embodiment of the present application will not be described one by one here.
[0209] S203: For any element, obtain an initial red component, an initial green component, and an initial blue component of the initial color of the element.
[0210] In the embodiment of the present application, for any element being displayed in the electronic document, an initial red component, an initial green component, and an initial blue component of the initial color of the element (ie, the current color of the element) are obtained.
[0211] The initial color of an element, such as the initial color of a text, generally refers to the color of the text, which can be directly obtained. For example, text usually has various attributes, including color attributes, which record the color of the text, so the initial color of the text can be obtained. The initial red component, initial green component, and initial blue component can be obtained from the R channel, G channel, and B channel respectively.
[0212] S204, determining a first brightness of the initial color according to the initial red component, the initial green component and the initial blue component.
[0213] In the embodiment of the present application, for the initial red component, the initial green component and the initial blue component of the initial color, the first brightness of the initial color can be determined by the initial red component, the initial green component and the initial blue component.
[0214] For the initial red component, the initial green component and the initial blue component of the initial color, a weighted sum may be performed on the initial red component, the initial green component and the initial blue component to obtain a first brightness of the initial color.
[0215] For example, for the initial red component Cred, the initial green component Cgreen, and the initial blue component Cblue of the initial color C, a weighted sum can be performed using the following formula to obtain the first brightness L(C) of the initial color C. It should be noted that the values 0.3, 0.59, and 0.11 here are only exemplary, and other values can be selected as needed, and the embodiments of the present application are not limited to this.
[0216] L(C)=0.3*C red +0.59*C green +0.11*C blue .
[0217] For example, for the initial red component Cred, the initial green component Cgreen, and the initial blue component Cblue of the initial color C, a weighted sum can be performed using the following formula to obtain the first brightness L(C) of the initial color C. It should be noted that the values 0.299, 0.587, and 0.114 here are only exemplary, and other values can be selected as needed, and the embodiments of the present application are not limited thereto.
[0218] L(C)=0.299*C red +0.587*C green +0.114*C blue .
[0219] For example, for the initial red component Cred, the initial green component Cgreen and the initial blue component Cblue of the initial color C, a weighted sum can be performed using the following formula to obtain the first brightness L(C) of the initial color C, which is more efficient than the above formula.
[0220] L(C)=(299*C red +587*C green +114*Cblue ) / 1000. It should be noted that the values 299, 587, and 114 here are only for exemplary descriptions, and other values may be selected as needed, and the present application embodiment does not limit this.
[0221] S205: Determine a color increment of the initial color according to the first brightness.
[0222] In the embodiment of the present application, for the first brightness of the initial color, the color increment of the initial color can be determined by the first brightness, wherein the color increment is used to increment the three color components of the initial color.
[0223] Specifically, a preset first value and a preset second value are obtained, and the product of the preset second value and the first brightness is determined, and the difference between the product of the preset second value and the first brightness and the preset first value is determined, and the difference is determined as the color increment of the initial color.
[0224] For example, a preset first value 255 and a preset second value 2 are obtained, and the product of the preset second value (e.g., 2) and the first brightness L(C) is determined, and the difference A between the product of the preset second value 2 and the first brightness L(C) and the preset first value (e.g., 255) is determined, and the difference A is determined as the color increment of the initial color C, as shown in the following formula. It should be noted that the preset first value 255 and the preset second value 2 here are only exemplary, and other values can be selected as needed, and the embodiment of the present application is not limited to this.
[0225] A=255-L(C)*2.
[0226] S206, processing the initial red component, the initial green component and the initial blue component by color increment to obtain a target red component, a target green component and a target blue component corresponding to the element.
[0227] In an embodiment of the present application, for the color increment of the initial color, the initial red component, the initial green component and the initial blue component can be processed through the color increment to obtain the target red component, the target green component and the target blue component corresponding to the element, which means that the initial red component, the initial green component and the initial blue component are processed through the color increment to obtain the three new color components of the element.
[0228] Specifically, the sum of the initial red component and the color increment is determined, and the sum of the initial red component and the color increment is determined as the target red component corresponding to the element; the sum of the initial green component and the color increment is determined, and the sum of the initial green component and the color increment is determined as the target green component corresponding to the element; the sum of the initial blue component and the color increment is determined, and the sum of the initial blue component and the color increment is determined as the target blue component corresponding to the element.
[0229] For example, determine the sum of the initial red component Cred and the color increment A, and determine the sum of the initial red component Cred and the color increment A as the target red component Cnewred of the element, determine the sum of the initial green component Cgreen and the color increment A, and determine the sum of the initial green component Cgreen and the color increment A as the target green component Cnewgreen corresponding to the element, determine the sum of the initial blue component Cblue and the color increment A, and determine the sum of the initial blue component Cblue and the color increment A as the target blue component Cnewblue corresponding to the element, which can be shown in the following formula.
[0230] C 新red =C red +A.
[0231] C 新green =C green +A.
[0232] C 新blue =C blue +A.
[0233] S207, transforming the initial red component into a target red component.
[0234] In the embodiment of the present application, for the initial red component of the initial color of the element, the initial red component needs to be transformed into a target red component, which means that the value of the R channel is transformed from the initial red component to the target red component.
[0235] It should be noted that in RGB, the value range of the red channel is 0 to 255. Therefore, for the target red component (i.e., the new red component), it is necessary to limit it to a certain value range, such as 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0236] Based on this, it is determined whether the target red component is within a preset value range. If the target red component is within the preset value range, the initial red component is transformed into the target red component, so that the value of the R channel can be transformed from the initial red component to the target red component.
[0237] In addition, when the target red component is not within the preset numerical range, it is determined whether the target red component is greater than the preset first numerical value (for example, 255). When the target red component is greater than the preset first numerical value, the target red component is first converted to the preset first numerical value, and then the initial red component is converted to the target red component. In this way, the value of the R channel can be converted from the initial red component to the preset first numerical value.
[0238] Alternatively, when the target red component is not within the preset value range, determine whether the target red component is less than a preset third value (for example, 0). When the target red component is less than the preset third value, first convert the target red component to the preset third value, and then convert the initial red component to the target red component. In this way, the value of the R channel can be converted from the initial red component to the preset third value.
[0239] S208, transforming the initial green component into the target green component.
[0240] In the embodiment of the present application, for the initial green component of the initial color of the element, the initial green component needs to be transformed into a target green component, which means that the value of the G channel is transformed from the initial green component to the target green component.
[0241] It should be noted that in RGB, the value range of the green channel is 0 to 255. Therefore, for the target green component (i.e., the new green component), it is necessary to limit it to a certain value range, for example, 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0242] Based on this, it is determined whether the target green component is within a preset value range. If the target green component is within the preset value range, the initial green component is transformed into the target green component, so that the value of the R channel can be transformed from the initial green component to the target green component.
[0243] In addition, when the target green component is not within the preset numerical range, it is determined whether the target green component is greater than the preset first numerical value (for example, 255). When the target green component is greater than the preset first numerical value, the target green component is first converted to the preset first numerical value, and then the initial green component is converted to the target green component. In this way, the value of the G channel can be converted from the initial green component to the preset first numerical value.
[0244] Alternatively, when the target green component is not within the preset value range, determine whether the target green component is less than a preset third value (for example, 0). When the target green component is less than the preset third value, first convert the target green component to the preset third value, and then convert the initial green component to the target green component. In this way, the value of the G channel can be converted from the initial green component to the preset third value.
[0245] S209: transform the initial blue component into a target blue component.
[0246] In the embodiment of the present application, for the initial blue component of the initial color of the element, the initial blue component needs to be transformed into a target blue component, which means that the value of the B channel is transformed from the initial blue component to the target blue component.
[0247] It should be noted that in RGB, the value range of the blue channel is 0 to 255. Therefore, for the target blue component (i.e., the new blue component), it is necessary to limit it to a certain numerical range, for example, 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0248] Based on this, it is determined whether the target blue component is within a preset value range. If the target blue component is within the preset value range, the initial blue component is transformed into the target blue component, so that the value of the R channel can be transformed from the initial blue component to the target blue component.
[0249] In addition, when the target blue component is not within the preset numerical range, it is determined whether the target blue component is greater than the preset first numerical value (for example, 255). When the target blue component is greater than the preset first numerical value, the target blue component is first converted to the preset first numerical value, and then the initial blue component is converted to the target blue component. In this way, the value of the B channel can be converted from the initial blue component to the preset first numerical value.
[0250] Alternatively, when the target blue component is not within the preset value range, determine whether the target blue component is less than a preset third value (for example, 0). When the target blue component is less than the preset third value, first transform the target blue component into the preset third value, and then transform the initial blue component into the target blue component. In this way, the value of the B channel can be transformed from the initial blue component to the preset third value.
[0251] S210, obtaining a target color by superimposing a target red component, a target green component, and a target blue component, and displaying the element with the target color.
[0252] In an embodiment of the present application, for the initial color, after the above processing, the value of the R channel can be transformed from the initial red component to the target red component, the value of the G channel can be transformed from the initial green component to the target green component, and the value of the B channel can be transformed from the initial blue component to the target blue component. In this way, the target red component, the target green component and the target blue component can be mixed and superimposed to obtain the target color, and the element can be displayed with the target color.
[0253] Through the above description of the technical solution provided by the embodiment of the present application, when the word processing software is in a preset color mode, by setting the background of the document view area of the word processing software to the preset color, obtaining at least one element currently displayed in the electronic document currently displayed in the document view area, and performing color conversion on any element, the display effect of the electronic document is improved, the user experience is improved, the user's eye fatigue can be relieved, and the user's eyes can be protected. In addition, for text other than black, the above method is used to perform color conversion, which can improve its display effect compared with the prior art.
[0254] like Figure 3 FIG. 1 is a schematic diagram of an implementation flow of another document display method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:
[0255] S301, when the word processing software is in a preset color mode, setting the background of the document view area of the word processing software to a preset color.
[0256] In the embodiment of the present application, this step is similar to the above-mentioned step S101, and the embodiment of the present application will not be described one by one here.
[0257] S302: Determine the electronic document currently displayed in the document view area, and obtain at least one element currently displayed in the electronic document.
[0258] In the embodiment of the present application, this step is similar to the above-mentioned step S102, and the embodiment of the present application will not be described one by one here.
[0259] S303: For any element, obtain an initial red component, an initial green component, and an initial blue component of the initial color of the element.
[0260] In the embodiment of the present application, this step is similar to the above-mentioned step S203, and the embodiment of the present application will not be described one by one here.
[0261] S304, obtaining a preset first value, determining a difference between the preset first value and an initial red component, and determining the difference between the preset first value and the initial red component as a target red component corresponding to the element.
[0262] In an embodiment of the present application, for the initial red component of the initial color, a preset first value can be obtained, the difference between the preset first value and the initial red component can be determined, and the difference between the preset first value and the initial red component can be determined as the target red component corresponding to the element, where the target red component is a new red component.
[0263] For example, for the initial red component Cred of the initial color C, obtain the preset first value 255, determine the difference between the preset first value 255 and the initial red component Cred, and determine the difference between the preset first value 255 and the initial red component Cred as the target red component corresponding to the element, that is, the new red component Cred, as shown in the following formula. It should be noted that the preset first value 255 here is only used as an exemplary description, and other values can be selected as needed, and the embodiment of the present application is not limited to this.
[0264] C 新red =255-C red .
[0265] S305, determining a difference between a preset first value and an initial green component, and determining the difference between the preset first value and the initial green component as a target green component corresponding to the element.
[0266] In an embodiment of the present application, for the initial green component of the initial color, the difference between the preset first value and the initial green component can be determined, and the difference between the preset first value and the initial green component can be determined as the target green component corresponding to the element, where the target green component is a new green component.
[0267] For example, for the initial green component Cgreen of the initial color C, determine the difference between the preset first value 255 and the initial green component Cgreen, and determine the difference between the preset first value 255 and the initial green component Cgreen as the target green component Cnewgreen corresponding to the element, as shown in the following formula.
[0268] C 新green =255-C green .
[0269] S306: Determine a difference between a preset first value and an initial blue component, and determine the difference between the preset first value and the initial blue component as a target blue component corresponding to the element.
[0270] In an embodiment of the present application, for the initial blue component of the initial color, the difference between the preset first value and the initial blue component can be determined, and the difference between the preset first value and the initial blue component can be determined as the target blue component corresponding to the element, where the target blue component is a new blue component.
[0271] For example, for the initial blue component Cblue of the initial color C, determine the difference between the preset first value 255 and the initial blue component Cblue, and determine the difference between the preset first value 255 and the initial blue component Cblue as the target blue component Cnewblue corresponding to the element, as shown in the following formula.
[0272] C新blue =255-C blue .
[0273] S307, converting the target red component, the target green component and the target blue component into hue, a second brightness and saturation.
[0274] In the embodiment of the present application, the target red component, the target green component and the target blue component, ie, three new color components, can be converted into hue, second brightness and saturation.
[0275] It should be noted that the target red component, the target green component and the target blue component can be converted into hue, second brightness and saturation according to the RGB to HSV conversion method. The specific conversion method can refer to the existing conversion method.
[0276] In addition, the target red component, the target green component and the target blue component can be converted into hue, second brightness and saturation according to the RGB to HLS method. The specific conversion method can refer to the existing conversion method.
[0277] For HSV, it refers to Hue, Saturation, Value; for HLS, it refers to Hue, Lightness, Saturation.
[0278] Hue represents the position of the color on the color wheel, and its value range is 0 to 360 degrees. Brightness represents the lightness or darkness of the color, and its value range is 0 to 100%. Saturation represents the purity of the color, and its value range is 0 to 100%.
[0279] S308, transforming the hue to obtain a target hue, and converting the target hue, the second brightness, and the saturation into a final red component, a final green component, and a final blue component.
[0280] In an embodiment of the present application, the hue can be transformed to obtain a target hue, so that the target hue, the second brightness and the saturation can be converted into a final red component, a final green component and a final blue component.
[0281] It should be noted that the target hue, the second brightness and the saturation may be converted into a final red component, a final green component and a final blue component in the manner of HSV converting RGB. For the specific conversion method, reference may be made to the existing conversion method.
[0282] In addition, the target hue, the second brightness and the saturation may be converted into a final red component, a final green component and a final blue component in accordance with the HLS conversion method for RGB. For specific conversion methods, reference may be made to existing conversion methods.
[0283] Among them, the hue can be transformed in the following way: obtain the preset fourth value and the preset fifth value, and determine the sum of the hue and the preset fourth value, and perform a modulo operation on the sum of the hue and the preset fourth value and the preset fifth value to obtain the target hue.
[0284] For example, for hue H, obtain the preset fourth value 180 (the value range of hue is 0-360, and the middle value 180 is selected here) and the preset fifth value 360 (the value range of hue is 0-360, and the boundary value 360 is selected here), and determine the sum of hue H and the preset fourth value 180, and perform a modulo operation on the sum of hue H and the preset fourth value 180 and the preset fifth value 360 to obtain the target hue H new, as shown in the following formula, where mod represents modulo. It should be noted that the preset fourth value 180 and the preset fifth value 360 here are only for exemplary description, and other values can be selected as needed, and the embodiments of the present application are not limited to this.
[0285] H 新 =(H+180)mod 360.
[0286] S309: transform the initial red component into a final red component, transform the initial green component into a final green component, and transform the initial blue component into a final blue component.
[0287] In the embodiment of the present application, for the initial red component of the initial color of the element, it is necessary to transform the initial red component into a final red component, which means transforming the value of the R channel from the initial red component to the final red component.
[0288] It should be noted that in RGB, the value range of the red channel is 0 to 255. Therefore, the final red component (i.e. the final red component) needs to be limited to a certain value range, such as 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0289] For the initial green component of the initial color of the element, the initial green component needs to be transformed into a final green component, which means that the value of the G channel is transformed from the initial green component to the final green component.
[0290] It should be noted that in RGB, the value range of the green channel is 0 to 255. Therefore, for the final green component (that is, the final green component), it is necessary to limit it to a certain value range, for example, 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0291] For the initial blue component of the initial color of the element, the initial blue component needs to be transformed into a final blue component, which means that the value of the B channel is transformed from the initial blue component to the final blue component.
[0292] It should be noted that in RGB, the value range of the blue channel is 0 to 255. Therefore, for the final blue component (that is, the final blue component), it is necessary to limit it to a certain numerical range, for example, 0 to 255. If it exceeds 255, it is forced to 255, and if it is lower than 0, it is forced to 0.
[0293] S310, a target color is obtained by superimposing a final red component, a final green component, and a final blue component, and the element is displayed with the target color.
[0294] In an embodiment of the present application, for the initial color, after the above processing, the value of the R channel can be transformed from the initial red component to the final red component, the value of the G channel can be transformed from the initial green component to the final green component, and the value of the B channel can be transformed from the initial blue component to the final blue component. In this way, the final red component, the final green component and the final blue component can be mixed and superimposed to obtain the target color, and the element can be displayed with the target color.
[0295] Through the above description of the technical solution provided by the embodiment of the present application, when the word processing software is in a preset color mode, by setting the background of the document view area of the word processing software to the preset color, obtaining at least one element currently displayed in the electronic document currently displayed in the document view area, and performing color conversion on any element, the display effect of the electronic document is improved, the user experience is improved, the user's eye fatigue can be relieved, and the user's eyes can be protected. In addition, for text other than black, the above method is used to perform color conversion, which can improve its display effect compared with the prior art.
[0296] In addition, it should be noted that for Figure 2 Compared with the document display method shown in Figure 3 The document display method shown in the figure has a faster processing efficiency, while Figure 3 Compared with the document display method shown in Figure 2 The document display method shown has a better display effect.
[0297] Based on this, after acquiring at least one element being displayed in the electronic document, the color types of the initial color corresponding to the at least one element may be counted, and it may be determined whether the color types exceed a preset number of types.
[0298] When the number of color types does not exceed the preset number, it means that the color of the elements in the current electronic document is relatively single and the number of color types is not large. Considering resource consumption, a method with faster processing efficiency can be selected at this time, so steps S203 to S210 can be executed.
[0299] When the number of color types exceeds the preset number, it means that the colors of the elements in the current electronic document are richer and the number of color types is larger. Considering the display effect, a method with better display effect can be selected at this time, so steps S303 to S310 can be executed.
[0300] In addition, after acquiring at least one element being displayed in the electronic document, the initial color corresponding to the at least one element may be counted, and it may be determined whether there is a preset color, such as black, navy blue, etc., in the initial color.
[0301] When there is no preset color (such as black, navy blue, etc.) in the initial color, it means that the colors of the elements in the current electronic document are mostly light colors, such as white, and the display of the elements is less affected under the preset color mode (such as dark mode or dark mode). At this time, a method with faster processing efficiency can be selected, so steps S203 to S210 can be executed.
[0302] When there is a preset color (such as black, navy blue, etc.) in the initial color, it means that there is a preset color in the color of the element in the current electronic document, such as black. The preset color (such as dark mode or dark mode) mode has a greater impact on the display of the element. At this time, a method with better display effect can be selected, so steps S303 to S310 can be executed.
[0303] Corresponding to the above method embodiment, the present application embodiment also provides a document display device, such as Figure 4 As shown, the apparatus may include: a background setting module 410 , a document determination module 420 , an element acquisition module 430 , a component determination module 440 , and a color conversion module 450 .
[0304] The background setting module 410 is used to set the background of the document view area of the word processing software to a preset color when the word processing software is in a preset color mode;
[0305] The document determination module 420 is used to determine the electronic document currently displayed in the document view area;
[0306] An element acquisition module 430, configured to acquire at least one element being displayed in the electronic document;
[0307] A component determination module 440, configured to determine, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element;
[0308] The color conversion module 450 is used to perform color conversion on the initial color component through the target color component to obtain a target color, and display the element with the target color.
[0309] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0310] The target color components include a target red component, a target green component and a target blue component;
[0311] The component determination module specifically includes:
[0312] A component acquisition submodule, used for acquiring, for any of the elements, the initial red component, the initial green component and the initial blue component of the initial color of the element;
[0313] a brightness determination submodule, configured to determine a first brightness of the initial color according to the initial red component, the initial green component and the initial blue component;
[0314] an increment determination submodule, configured to determine a color increment of the initial color according to the first brightness;
[0315] The component processing submodule is used to process the initial red component, the initial green component and the initial blue component through the color increment to obtain the target red component, the target green component and the target blue component corresponding to the element.
[0316] In an optional implementation, the brightness determination submodule is specifically used to:
[0317] A weighted sum is performed on the initial red component, the initial green component, and the initial blue component to obtain a first brightness of the initial color.
[0318] In an optional implementation, the increment determination submodule is specifically used to:
[0319] Obtaining a preset first value and a preset second value, and determining a product of the preset second value and the first brightness;
[0320] Determine a difference between a product of the preset second value and the first brightness and the preset first value;
[0321] The difference is determined as a color increment of the initial color.
[0322] In an optional implementation, the component processing submodule is specifically used for:
[0323] Determine the sum of the initial red component and the color increment, and determine the sum of the initial red component and the color increment as the target red component corresponding to the element;
[0324] Determine a sum of the initial green component and the color increment, and determine the sum of the initial green component and the color increment as the target green component corresponding to the element;
[0325] A sum of the initial blue component and the color increment is determined, and the sum of the initial blue component and the color increment is determined as the target blue component corresponding to the element.
[0326] In an optional implementation, the color conversion module specifically includes:
[0327] A red component conversion submodule, used for converting the initial red component into the target red component;
[0328] A green component conversion submodule, used for converting the initial green component into the target green component;
[0329] A blue component conversion submodule, used for converting the initial blue component into the target blue component;
[0330] The component superposition submodule is used to obtain a target color by superimposing the target red component, the target green component and the target blue component.
[0331] In an optional implementation, the red component transformation submodule is specifically used for:
[0332] Determining whether the target red component is within a preset value range;
[0333] When the target red component is within the preset value range, the initial red component is transformed into the target red component.
[0334] In an optional implementation, the red component transformation submodule is further used for:
[0335] When the target red component is not within the preset value range, determining whether the target red component is greater than a preset first value;
[0336] In the case where the target red component is greater than the preset first value, the target red component is converted to the preset first value, and the initial red component is converted to the target red component;
[0337] or,
[0338] When the target red component is not within the preset value range, determining whether the target red component is less than a preset third value;
[0339] In the case where the target red component is smaller than the preset third value, the target red component is transformed into the preset third value, and the initial red component is transformed into the target red component.
[0340] In an optional implementation, the green component conversion submodule is specifically used for:
[0341] Determining whether the target green component is within a preset value range;
[0342] When the target green component is within the preset value range, the initial green component is transformed into the target green component.
[0343] In an optional implementation, the green component transformation submodule is further used for:
[0344] In the case where the target green component is not within the preset value range, determining whether the target green component is greater than a preset first value;
[0345] In the case where the target green component is greater than the preset first value, the target green component is transformed into the preset first value, and the initial green component is transformed into the target green component;
[0346] or,
[0347] When the target green component is not within the preset value range, determining whether the target green component is less than a preset third value;
[0348] In the case where the target green component is smaller than the preset third value, the target green component is transformed into the preset third value, and the initial green component is transformed into the target green component.
[0349] In an optional implementation, the blue component transformation submodule is specifically used for:
[0350] Determining whether the target blue component is within a preset value range;
[0351] When the target blue component is within the preset value range, the initial blue component is transformed into the target blue component.
[0352] In an optional implementation, the blue component transformation submodule is further used for:
[0353] When the target blue component is not within the preset value range, determining whether the target blue component is greater than a preset first value;
[0354] When the target blue component is greater than the preset first value, the target blue component is transformed into the preset first value, and the initial blue component is transformed into the target blue component;
[0355] or,
[0356] When the target blue component is not within the preset value range, determining whether the target blue component is less than a preset third value;
[0357] When the target blue component is smaller than the preset third value, the target blue component is transformed into the preset third value, and the initial blue component is transformed into the target blue component.
[0358] In an optional embodiment, the initial color components include an initial red component, an initial green component and an initial blue component;
[0359] The target color components include a target red component, a target green component and a target blue component;
[0360] The component determination module specifically includes:
[0361] A component acquisition submodule, used for acquiring, for any of the elements, the initial red component, the initial green component and the initial blue component of the initial color of the element;
[0362] a red component determination submodule, configured to obtain a preset first value, determine a difference between the preset first value and the initial red component, and determine the difference between the preset first value and the initial red component as a target red component corresponding to the element;
[0363] A green component determination submodule, used to determine a difference between the preset first value and the initial green component, and determine the difference between the preset first value and the initial green component as a target green component corresponding to the element;
[0364] The blue component submodule is used to determine the difference between the preset first value and the initial blue component, and determine the difference between the preset first value and the initial blue component as the target blue component corresponding to the element.
[0365] In an optional implementation, the color conversion module specifically includes:
[0366] A component conversion submodule, used for converting the target red component, the target green component and the target blue component into hue, second brightness and saturation;
[0367] A hue transformation submodule, used to transform the hue to obtain a target hue;
[0368] A hue, brightness, and saturation conversion submodule, used to convert the target hue, the second brightness, and the saturation into a final red component, a final green component, and a final blue component;
[0369] a component conversion submodule, configured to convert the initial red component into the final red component, convert the initial green component into the final green component, and convert the initial blue component into the final blue component;
[0370] The component superposition submodule is used to obtain a target color by superimposing the final red component, the final green component and the final blue component.
[0371] In an optional implementation, the hue conversion submodule is specifically used for:
[0372] Obtaining a preset fourth value and a preset fifth value, and determining the sum of the hue and the preset fourth value;
[0373] The sum of the hue and the preset fourth value is modulo-operated with the preset fifth value to obtain the target hue.
[0374] In an optional implementation, the component acquisition submodule is specifically used to:
[0375] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0376] In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0377] or,
[0378] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0379] In the case that there is no preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0380] In an optional implementation, the component acquisition submodule is specifically used to:
[0381] Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types;
[0382] In a case where the number of color types does not exceed the preset number of types, performing the step of obtaining the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements;
[0383] or,
[0384] Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors;
[0385] In the case where there is a preset color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
[0386] The present application also provides an electronic device, such as Figure 5 As shown, it includes a processor 51, a communication interface 52, a memory 53 and a communication bus 54, wherein the processor 51, the communication interface 52, and the memory 53 communicate with each other through the communication bus 54.
[0387] A memory 53, for storing computer programs;
[0388] The processor 51 is used to execute the program stored in the memory 53 to implement the following steps:
[0389] When the word processing software is in a preset color mode, the background of the document view area of the word processing software is set to a preset color; the electronic document currently displayed in the document view area is determined, and at least one element being displayed in the electronic document is obtained; for any of the elements, a target color component corresponding to the element is determined according to an initial color component of the initial color of the element; the initial color component is transformed by the target color component to obtain a target color, and the element is displayed with the target color.
[0390] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0391] The communication interface is used for communication between the above electronic device and other devices.
[0392] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0393] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0394] In another embodiment provided in the present application, a storage medium is provided, in which instructions are stored. When the instructions are executed on a computer, the computer executes the document display method described in any one of the above embodiments.
[0395] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the document display method described in any one of the above embodiments.
[0396] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a storage medium, or transmitted from one storage medium to another storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0397] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0398] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0399] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A document display method, characterized in that: The method comprises: When the word processing software is in a preset color mode, setting the background of the document view area of the word processing software to the preset color; Determine the electronic document currently displayed in the document view area, and obtain at least one element currently displayed in the electronic document; For any of the elements, determining a target color component corresponding to the element according to an initial color component of an initial color of the element; The initial color component is subjected to color transformation by using the target color component to obtain a target color, and the element is displayed with the target color.
2. The method according to claim 1, characterized in that The initial color components include an initial red component, an initial green component and an initial blue component; The target color components include a target red component, a target green component and a target blue component; The step of determining, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element comprises: For any of the elements, obtaining the initial red component, the initial green component, and the initial blue component of the initial color of the element; Determine a first brightness of the initial color by using the initial red component, the initial green component and the initial blue component; Determining a color increment of the initial color according to the first brightness; The initial red component, the initial green component and the initial blue component are processed by the color increment to obtain the target red component, the target green component and the target blue component corresponding to the element.
3. The method according to claim 2, characterized in that The determining the first brightness of the initial color by using the initial red component, the initial green component and the initial blue component comprises: A weighted sum is performed on the initial red component, the initial green component, and the initial blue component to obtain a first brightness of the initial color.
4. The method according to claim 2, characterized in that: The step of determining the color increment of the initial color by using the first brightness includes: Obtaining a preset first value and a preset second value, and determining a product of the preset second value and the first brightness; Determine a difference between a product of the preset second value and the first brightness and the preset first value; The difference is determined as a color increment of the initial color.
5. The method according to claim 2, characterized in that: The step of processing the initial red component, the initial green component, and the initial blue component by the color increment to obtain the target red component, the target green component, and the target blue component corresponding to the element includes: Determine the sum of the initial red component and the color increment, and determine the sum of the initial red component and the color increment as the target red component corresponding to the element; Determine a sum of the initial green component and the color increment, and determine the sum of the initial green component and the color increment as the target green component corresponding to the element; A sum of the initial blue component and the color increment is determined, and the sum of the initial blue component and the color increment is determined as the target blue component corresponding to the element.
6. The method according to claim 2, characterized in that The step of performing a color transformation on the initial color component by using the target color component to obtain the target color includes: transforming the initial red component into the target red component; transforming the initial green component into the target green component; Transforming the initial blue component into the target blue component; The target color is obtained by superimposing the target red component, the target green component and the target blue component.
7. The method according to claim 6, characterized in that The converting the initial red component into the target red component comprises: Determining whether the target red component is within a preset value range; When the target red component is within the preset value range, transforming the initial red component into the target red component; When the target red component is not within the preset value range, determining whether the target red component is greater than a preset first value; In the case where the target red component is greater than the preset first value, the target red component is converted to the preset first value, and the initial red component is converted to the target red component; or, When the target red component is not within the preset value range, determining whether the target red component is less than a preset third value; In the case where the target red component is smaller than the preset third value, the target red component is transformed into the preset third value, and the initial red component is transformed into the target red component.
8. The method according to claim 6, characterized in that The converting the initial green component into the target green component comprises: Determining whether the target green component is within a preset value range; When the target green component is within the preset value range, transforming the initial green component into the target green component; In the case where the target green component is not within the preset value range, determining whether the target green component is greater than a preset first value; In the case where the target green component is greater than the preset first value, the target green component is transformed into the preset first value, and the initial green component is transformed into the target green component; or, When the target green component is not within the preset value range, determining whether the target green component is less than a preset third value; In the case where the target green component is smaller than the preset third value, the target green component is transformed into the preset third value, and the initial green component is transformed into the target green component.
9. The method according to claim 6, characterized in that The converting the initial blue component into the target blue component comprises: Determining whether the target blue component is within a preset value range; When the target blue component is within the preset value range, transforming the initial blue component into the target blue component; When the target blue component is not within the preset value range, determining whether the target blue component is greater than a preset first value; When the target blue component is greater than the preset first value, the target blue component is transformed into the preset first value, and the initial blue component is transformed into the target blue component; or, When the target blue component is not within the preset value range, determining whether the target blue component is less than a preset third value; When the target blue component is smaller than the preset third value, the target blue component is transformed into the preset third value, and the initial blue component is transformed into the target blue component.
10. The method according to claim 1, characterized in that The initial color components include an initial red component, an initial green component and an initial blue component; The target color components include a target red component, a target green component and a target blue component; The step of determining, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element comprises: For any of the elements, obtaining the initial red component, the initial green component, and the initial blue component of the initial color of the element; Obtaining a preset first value, determining a difference between the preset first value and the initial red component, and determining the difference between the preset first value and the initial red component as a target red component corresponding to the element; Determine a difference between the preset first value and the initial green component, and determine the difference between the preset first value and the initial green component as a target green component corresponding to the element; A difference between the preset first value and the initial blue component is determined, and the difference between the preset first value and the initial blue component is determined as a target blue component corresponding to the element.
11. The method according to claim 10, characterized in that The step of performing a color transformation on the initial color component by using the target color component to obtain the target color includes: Convert the target red component, the target green component and the target blue component into hue, a second brightness and a saturation; Transforming the hue to obtain a target hue, and converting the target hue, the second brightness, and the saturation into a final red component, a final green component, and a final blue component; Transforming the initial red component into the final red component, transforming the initial green component into the final green component, and transforming the initial blue component into the final blue component; The target color is obtained by superimposing the final red component, the final green component and the final blue component.
12. The method according to claim 11, characterized in that The step of transforming the hue to obtain a target hue includes: Obtaining a preset fourth value and a preset fifth value, and determining the sum of the hue and the preset fourth value; The sum of the hue and the preset fourth value is modulo-operated with the preset fifth value to obtain the target hue.
13. The method according to claim 2, characterized in that Before obtaining the initial red component, the initial green component, and the initial blue component of the initial color of any of the elements, the method further includes: Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types; In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements; or, Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors; In a case where there is no dark color in the initial color, the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements is performed.
14. The method according to claim 10, characterized in that Before obtaining the initial red component, the initial green component, and the initial blue component of the initial color of any of the elements, the method further includes: Counting the color types of the initial color corresponding to at least one of the elements, and determining whether the color types exceed a preset number of types; In a case where the number of color types does not exceed the preset number of types, performing the step of acquiring the initial red component, the initial green component, and the initial blue component of the initial color of any one of the elements; or, Counting the initial colors corresponding to at least one of the elements, and determining whether there is a preset color in the initial colors; In the case where there is a dark color in the initial color, the step of acquiring the initial red component, the initial green component and the initial blue component of the initial color of any one of the elements is performed.
15. A document display device, characterized in that: The device comprises: A background setting module, used to set the background of the document view area of the word processing software to a preset color when the word processing software is in a preset color mode; A document determination module, used to determine the electronic document currently displayed in the document view area; An element acquisition module, used to acquire at least one element being displayed in the electronic document; A component determination module, configured to determine, for any of the elements, a target color component corresponding to the element according to an initial color component of an initial color of the element; The color conversion module is used to perform color conversion on the initial color component through the target color component to obtain a target color, and display the element with the target color.