从动画颜色改变到颜色

从动画颜色改变到颜色

本文介绍了机器人:从动画颜色改变到颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个颜色,我需要创建一个实时动画快速度从颜色到另一个交换机。

我想只是为了增加颜色的十六进制,直到我到了别的,而是给了一个非常糟糕的动画,因为它显示出许多不相关的颜色。

我使用setColorFilter(颜色,colorfilter),以改变的ImageView的颜色。

改变色调会给我最好的视觉效果?如果是的话,我能怎样改变了坚实的颜色?

解决方案:我通过递归移色相解决了这个问题。

 私人诠释hueChange(INT C,INT度){
       浮动[] HSV =新的浮动[3]; //数组来存储HSV值
       Color.colorToHSV(C,HSV); //获取像素的原始HSV值
       HSV [0] = HSV [0] +度; //添加移位到HSV阵列的HUE
       HSV [0] = HSV [0]%360; //局限色调值:[0,360]
       返回Color.HSVToColor(Color.alpha(C),单纯疱疹病毒);
    }
 

解决方案

解决方案:我通过递归移色相解决了这个问题。

 私人诠释hueChange(INT C,INT度){
       浮动[] HSV =新的浮动[3]; //数组来存储HSV值
       Color.colorToHSV(C,HSV); //获取像素的原始HSV值
       HSV [0] = HSV [0] +度; //添加移位到HSV阵列的HUE
       HSV [0] = HSV [0]%360; //局限色调值:[0,360]
       返回Color.HSVToColor(Color.alpha(C),单纯疱疹病毒);
    }
 

Assuming I have two colors, and I need to create a real time animation that fastly switches from a color to another.

I tried just to increment the color hexadecimal until I reach the other, but that gave a really bad animation as it showed lots of unrelated colors.

I am using setColorFilter(color, colorfilter) to change the color of an imageview.

Changing the HUE will give me the best visual results? If so, how can I change it for a solid color?

SOLUTION:I solved it by recursively shifting hue

private int hueChange(int c,int deg){
       float[] hsv = new float[3];       //array to store HSV values
       Color.colorToHSV(c,hsv); //get original HSV values of pixel
       hsv[0]=hsv[0]+deg;                //add the shift to the HUE of HSV array
       hsv[0]=hsv[0]%360;                //confines hue to values:[0,360]
       return Color.HSVToColor(Color.alpha(c),hsv);
    }
解决方案

SOLUTION: I solved it by recursively shifting hue

private int hueChange(int c,int deg){
       float[] hsv = new float[3];       //array to store HSV values
       Color.colorToHSV(c,hsv); //get original HSV values of pixel
       hsv[0]=hsv[0]+deg;                //add the shift to the HUE of HSV array
       hsv[0]=hsv[0]%360;                //confines hue to values:[0,360]
       return Color.HSVToColor(Color.alpha(c),hsv);
    }

这篇关于机器人:从动画颜色改变到颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:18