wangliang_wd

feat:优化早晚报背景色

@@ -25,6 +25,8 @@ import { viewColumInsightIntentShare } from '../../utils/InsightIntentShare' @@ -25,6 +25,8 @@ import { viewColumInsightIntentShare } from '../../utils/InsightIntentShare'
25 import { common } from '@kit.AbilityKit'; 25 import { common } from '@kit.AbilityKit';
26 import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'; 26 import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent';
27 import { EmitterEventId, EmitterUtils } from 'wdKit/Index' 27 import { EmitterEventId, EmitterUtils } from 'wdKit/Index'
  28 +import { ColorUtils } from '../../utils/ColorUtils';
  29 +
28 30
29 const TAG = 'MorningEveningPaperComponent'; 31 const TAG = 'MorningEveningPaperComponent';
30 32
@@ -217,7 +219,9 @@ export struct MorningEveningPaperComponent { @@ -217,7 +219,9 @@ export struct MorningEveningPaperComponent {
217 console.log(TAG, "compInfoBean compStyle = " + imageUrl) 219 console.log(TAG, "compInfoBean compStyle = " + imageUrl)
218 220
219 if (this.pageInfoBean.backgroundColor.length > 0){ 221 if (this.pageInfoBean.backgroundColor.length > 0){
220 - this.mixedBgColor = this.pageInfoBean.backgroundColor 222 + let colorDatas = ColorUtils.hexColorValueToRGB(this.pageInfoBean.backgroundColor)
  223 + let color = ColorUtils.getMorningEveningPaperRgb({red:colorDatas[0],green:colorDatas[1],blue:colorDatas[2],alpha:1})
  224 + this.mixedBgColor = "#ff" + color.red.toString(16).padStart(2,'0') + color.green.toString(16).padStart(2,'0') + color.blue.toString(16).padStart(2,'0');
221 return 225 return
222 } 226 }
223 227
@@ -251,9 +255,9 @@ export struct MorningEveningPaperComponent { @@ -251,9 +255,9 @@ export struct MorningEveningPaperComponent {
251 effectKit.createColorPicker(pixelMap, (err, colorPicker) => { 255 effectKit.createColorPicker(pixelMap, (err, colorPicker) => {
252 let color = colorPicker.getLargestProportionColor(); 256 let color = colorPicker.getLargestProportionColor();
253 console.log(TAG, "compInfoBean compStyle = " + color) 257 console.log(TAG, "compInfoBean compStyle = " + color)
254 - // color = ColorUtils.getMorningEveningPaperRgb({red:color.red,green:color.green,blue:color.blue,alpha:color.alpha}) 258 + color = ColorUtils.getMorningEveningPaperRgb({red:color.red,green:color.green,blue:color.blue,alpha:color.alpha})
255 // 将取色器选取的color示例转换为十六进制颜色代码 259 // 将取色器选取的color示例转换为十六进制颜色代码
256 - this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16).padStart(2,'0') + color.green.toString(16).padStart(2,'0') + color.blue.toString(16).padStart(2,'0'); 260 + this.mixedBgColor = "#ff" + color.alpha.toString(16) + color.red.toString(16).padStart(2,'0') + color.green.toString(16).padStart(2,'0') + color.blue.toString(16).padStart(2,'0');
257 console.log(TAG, "compInfoBean compStyle = " + this.mixedBgColor) 261 console.log(TAG, "compInfoBean compStyle = " + this.mixedBgColor)
258 }); 262 });
259 } 263 }
@@ -179,14 +179,16 @@ export class ColorUtils { @@ -179,14 +179,16 @@ export class ColorUtils {
179 179
180 public static getMorningEveningPaperRgb(color: ColorRgb): ColorRgb { 180 public static getMorningEveningPaperRgb(color: ColorRgb): ColorRgb {
181 // RGB颜色取值范围是0~255,需要转换为0~1的浮点数 181 // RGB颜色取值范围是0~255,需要转换为0~1的浮点数
182 - const red: number = color.red;  
183 - const green: number = color.green;  
184 - const blue: number = color.blue; 182 +
  183 + const red: number = color.red / MAX_RGB_VALUE;
  184 + const green: number = color.green / MAX_RGB_VALUE;
  185 + const blue: number = color.blue / MAX_RGB_VALUE;
185 186
186 const max: number = Math.max(red, green, blue); 187 const max: number = Math.max(red, green, blue);
187 const min: number = Math.min(red, green, blue); 188 const min: number = Math.min(red, green, blue);
188 const delta: number = max - min; 189 const delta: number = max - min;
189 190
  191 +
190 // 色调 192 // 色调
191 let hue: number = 0; 193 let hue: number = 0;
192 // 饱和度 194 // 饱和度