Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of a palette generation method according to an embodiment of the present application. The execution subject of the method shown in fig. 1 can be, but is not limited to, a mobile phone, a computer, and other intelligent terminals. Or the execution subject of the method shown in fig. 1 may also be a client itself capable of executing the method, for example, the method shown in fig. 1 is executed by the palette generation device.
As shown in fig. 1, at S102, a dominant color of the palette is determined.
The palette is composed of a series of basic colors with certain representativeness and their gradient colors, and the user can find the required color in the palette and acquire the color value.
Based on the principle of palette making, the dominant color of the palette analysis may be determined first. It should be noted that, at the same time of determining the main color of the palette, the number of the main color (main color number) is determined at the same time.
For example, the user may select a dominant color as color number 5. The specific color of the dominant color may be selected by the user.
At S104, based on the designated number, a scale value corresponding to the designated number is determined by the bezier curve.
The designated number may be a preset number. For example, the preset number may be 1 to 9, where color No. 5 is the dominant color.
The Bezier curve realizes smooth transition of the curve, and the more points on the curve, the smoother the curve transition.
The designated number can be associated with the scale value by means of a bezier curve, whereby, based on the designated number, a corresponding scale value can be uniquely determined by means of the bezier curve, so that, based on the designated number, a more smooth determination of the scale value is possible.
For example, for numbers 1 to 9, the corresponding scale values determined may then be smoothly transitioned.
At S106, a mixed color is determined based on the magnitude relationship between the designated number and the number of the main color.
The main color plate generally comprises a light color part and a dark color part which are two color plates. For light-colored partial color panels, the dominant color is mainly mixed with white. For dark part color panels, the dominant color is mainly mixed with black. Here, white and black are mixed colors.
Here, it should be noted that the mixed color may be another color, and particularly, for the dark partial color plate, the mixed color is not limited to black, and may be generated based on the dominant color.
It is further noted that, in general, when the designated number is less than or equal to the number of the main color, the designated portion is usually the number of the light portion color plate, and when the designated number is greater than the number of the main color, the designated number is usually the number of the dark portion color plate. Therefore, based on the magnitude relationship between the designated number and the number of the dominant color, the mixed color can be determined.
For example, for the color palette including numbers 1 to 9, color No. 5 is the main color, color nos. 1 to 4 are light part color plates, and color nos. 6 to 9 are dark part color plates.
At S108, a color palette is generated based on the dominant color, the scale value, and the mixed color.
The brightness of the mixed color can be adjusted based on the ratio value, and then the main color and the adjusted mixed color are mixed to generate a corresponding color palette.
For each number on the palette, a proportion value corresponding to the designated number can be determined through the Bezier curve, and based on the characteristics of the Bezier curve, the proportion value can be smoothly transited based on the designated number; after the palette is generated through the proportion value, the main color and the mixed color, the palette has the characteristic of a Bezier curve based on the proportion value, so that the transition of color gradation is more harmonious, and the problem that the hue of the depth part in the formed palette is incomplete, particularly the color of the deep color part is gray due to the superposition of equal proportion is avoided.
In some embodiments, the bezier curve may be represented by a bernstein base polynomial of order n, and the value of n may preferably be between 1 and 10 based on practical applications, where the present implementation does not specifically limit the value of n, and the magnitude of n does not affect the specific implementation of the present embodiment.
FIG. 2 is a schematic illustration of the determination of a scale value from a Bezier curve according to an embodiment of the present application. As shown in fig. 2, the bezier curve in the graph may be plotted based on parameters 0.26, 0.09, 0.67, 0.73. 0.26 corresponds to the parameter ctx, 0.09 corresponds to the parameter start, 0.67 corresponds to the parameter end, and 0.73 corresponds to the parameter curvature.
For the above parameters, the bezier curve may be generated by the following function, namely:
*@param{CanvasRenderingContext2D}ctx;
a start point of @ param { Array < number > };
(vii) at param { Array < number > } end point;
@ param { number } curve (0-1);
*/function drawCurvePath(ctx,start,end,curveness){};
the abscissa of the generated bezier curve may represent the number of the palette, and the ordinate may represent the scale value corresponding to the number of the palette.
As can be seen from fig. 2, when the scale value corresponding to the designated number is determined by the bezier curve based on the designated number, the abscissa coordinate point in the two-dimensional coordinate system in which the bezier curve is located may be determined based on the designated number; based on the abscissa coordinate points, the proportional values on the ordinate axis corresponding to the abscissa coordinate points may be determined by a bezier curve.
Wherein, the distance between any two adjacent numbers in fig. 2 is the same. It should be further noted that, the horizontal axis and the vertical axis are relative, and the two may be converted in position based on their own positional relationship, for example, the two may be rotated in the same direction by 90 degrees to convert the horizontal axis and the vertical axis, but this does not affect the implementation of the present embodiment.
Alternatively, as an example, when the proportional value on the vertical axis corresponding to the abscissa coordinate point is determined by the bezier curve based on the abscissa coordinate point, an intersection point of a straight line passing through the abscissa coordinate point and perpendicular to the abscissa and the bezier curve may be determined based on the abscissa coordinate point; based on the intersection point, a scale value corresponding to the intersection point on the vertical axis in the two-dimensional coordinate system can be determined.
Specifically, color No. 6 in fig. 2 is the dominant color, and the proportional value corresponding to color No. 1 is 7.6%, indicating that color No. 1 is reduced by 93%; the ratio of color No. 6 is 100%, indicating that the dominant color is reduced by 0%.
Alternatively, as an example, when determining the mixed color, white may be determined as the mixed color of the light part color plate, that is, when the designated number is less than or equal to the number of the main color, white may be determined as the mixed color. And for the mixed color of the light part color plate, the main color can be adjusted to form the mixed color, and specifically, when the specified number is larger than the number of the main color, the color of the main color after the HSB value adjustment can be determined as the mixed color.
When the dominant color is adjusted, the dominant color may be correspondingly hue-rotated and the luminance value may be deepened based on the HSB model to generate a mixed color. The color palette obtained in this way has the advantages that the colors of the color plates of the dark color part are not gray, and the overall visual sensation can be improved.
In the HSB model, H represents hue (H, hue). And on a standard color wheel with the angle of 0-360 degrees, the hue is measured according to the position. In common use, the hue is identified by a color name, such as red, green, or orange. Black and white leuco phases.
S represents the color purity (S), and is gray when S is 0. None of the white, black and other gray colors is saturated. At maximum saturation, each hue has the purest shade. The S value range is 0-100%.
B represents brightness (B), which is the brightness of a color. When B is 0, it is black. The maximum brightness is the state of the brightest color. The S value range is 0-100%.
RGB represents the colors of three channels of red, green and blue, and various colors can be obtained by changing the three color channels of red (R), green (G) and blue (B) and superposing the three color channels with each other. Therefore, any one dominant color can be represented in the form of RGB.
Any color represented by RGB can be represented in a three-dimensional space, and the hue rotation is the rotation of an RGB point on the three-dimensional space by a certain angle around the perpendicular bisector of the plane formed by the RGB three points.
When the dominant color is adjusted, the corresponding hue of the dominant color may be rotated based on the cool/warm tone of the color to deepen the brightness value. Specifically, when the dominant color is a warm color, the hue of the dominant color may be rotated counterclockwise by a first preset angle, and the brightness value of the dominant color may be deepened by a first preset ratio; and when the main color is the cold color, clockwise rotating the hue of the main color by a second preset angle, and deepening the brightness value of the main color by a second preset proportion.
When the main color is different cold and warm colors, the different strategies are executed to perform corresponding hue rotation on the main color and deepen the brightness value, and the purpose of performing targeted hue rotation on the darkest value of the main color of the cold and warm colors can be achieved, so that the color visual effect is improved.
Wherein, the first preset angle may be 26 degrees, and the first preset proportion may be 50%; the second predetermined angle may be 10 degrees, and the second predetermined ratio may be 55%. These values may be such that the B value in the HSB model of mixed colors is the maximum, i.e. B is 100%. The maximum value of B is only the optimal choice of this embodiment, and the value of B may be other different values, which are all within the implementation range of this embodiment. It should be noted that the above specific values are only preferred values determined by the present embodiment according to actual situations, the present embodiment is not limited to the specific limitations on the above values, the first preset angle and the second preset angle may be other values, and the first preset ratio and the second preset ratio may also be other values.
For the generated palette, for any dominant color (including any color customized by the user), a more satisfactory dominant color tone scale can be obtained through the Bezier curve and the HSB model, and the requirements of the user are met.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
An electronic device according to an embodiment of the present application will be described in detail below with reference to fig. 3. Referring to fig. 3, at a hardware level, the electronic device includes a processor, optionally, an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be interconnected by an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 3, but this does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the palette generation device on the logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
determining a dominant color of the palette;
determining a proportional value corresponding to the designated number through a Bezier curve based on the designated number;
determining a mixed color based on a magnitude relationship between the designated number and the number of the dominant color;
generating the palette based on the dominant color, the ratio value, and the mixed color.
The method for generating a palette according to the embodiment of fig. 1 of the present application may be applied to a processor, or may be implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
Of course, besides the software implementation, the electronic device of the present application does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
Embodiments of the present application also provide a computer-readable storage medium storing one or more programs, where the one or more programs include instructions, which, when executed by an electronic device including a plurality of application programs, enable the electronic device to perform the method of the embodiment shown in fig. 1, and are specifically configured to perform the following method:
determining a dominant color of the palette;
determining a proportional value corresponding to the designated number through a Bezier curve based on the designated number;
determining a mixed color based on a magnitude relationship between the designated number and the number of the dominant color;
generating the palette based on the dominant color, the ratio value, and the mixed color.
Fig. 4 is a schematic structural diagram of a palette generation apparatus according to an embodiment of the present application. As shown in fig. 4, in one software implementation, the palette generating apparatus 400 includes:
a dominant color determination module 420 for determining a dominant color of the palette;
a proportional value determining module 440, configured to determine, based on a specified number, a proportional value corresponding to the specified number through a bezier curve;
a color determination module 460, configured to determine a mixed color based on a magnitude relationship between the designated number and the number of the dominant color;
a generating module 480 configured to generate the color palette based on the dominant color, the ratio value, and the mixed color.
Based on the palette generation apparatus of the present embodiment, for each number on the palette, a proportional value corresponding to the designated number may be determined by a bezier curve, and based on the characteristics of the bezier curve, the proportional value may transition smoothly based on the designated number; after the palette is generated through the proportion value, the main color and the mixed color, the palette has the characteristic of a Bezier curve based on the proportion value, so that the transition of color gradation is more harmonious, and the problem that the hue of the depth part in the formed palette is incomplete, particularly the color of the deep color part is gray due to the superposition of equal proportion is avoided.
Alternatively, as one embodiment, the ratio value determination module 440,
determining a horizontal axis coordinate point in a two-dimensional coordinate system where the Bezier curve is located based on the designated number;
determining, from the Bezier curve, a proportional value on a vertical axis corresponding to the abscissa coordinate point based on the abscissa coordinate point.
Alternatively, as one embodiment, the ratio value determination module 440,
determining an intersection point of a straight line passing through the abscissa coordinate point and perpendicular to the abscissa and the Bezier curve based on the abscissa coordinate point;
and determining a proportion value corresponding to the intersection point on a longitudinal axis in the two-dimensional coordinate system based on the intersection point.
Alternatively, as one embodiment, the color determination module 460,
determining white as a mixed color when the designated number is less than or equal to the number of the dominant color;
and when the specified number is greater than the number of the main color, determining the color of the main color after the HSB value is adjusted as a mixed color.
Alternatively, as one embodiment, the color determination module 460,
and performing corresponding hue rotation on the main color and deepening a brightness value to generate the mixed color based on an HSB model.
Alternatively, as one embodiment, the color determination module 460,
when the main color is warm, rotating the hue of the main color counterclockwise by a first preset angle, and deepening the brightness value of the main color by a first preset proportion;
and when the main color is a cold color, clockwise rotating the hue of the main color by a second preset angle, and deepening the brightness value of the main color by a second preset proportion.
Alternatively, the processor may, as an embodiment,
the first preset angle is 26 degrees, and the first preset proportion is 50%;
the second preset angle is 10 degrees, and the second preset proportion is 55%.
Alternatively, the computer program, as an embodiment,
the B value in the HSB model of the mixed color is the maximum value.
Optionally, as one embodiment, the generating module 480
Adjusting the brightness of the mixed color based on the ratio value;
and mixing the main color and the adjusted mixed color to generate a corresponding color palette.
Optionally, as an embodiment, the specified number is a preset number.
The palette generating device 400 may also execute the method in the embodiment shown in fig. 1, and implement the functions of the palette generating device 400 in the embodiment shown in fig. 1, which are not described herein again in this embodiment of the present application.
In short, the above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.