一对一视频聊天app源码,Android开发之取两个色值的中间色

编程知识 更新时间:2023-05-02 20:03:08

一对一视频聊天app源码,Android开发之取两个色值的中间色

/**
 * 获取两个色值的中间色
 * @param fraction
 * @param startColor
 * @param endColor
 * @return
 */
public static int getCurrentColor(float fraction, int startColor, int endColor) {
    int redCurrent;
    int blueCurrent;
    int greenCurrent;
    int alphaCurrent;
 
    int redStart = Color.red(startColor);
    int blueStart = Color.blue(startColor);
    int greenStart = Color.green(startColor);
    int alphaStart = Color.alpha(startColor);
 
    int redEnd = Color.red(endColor);
    int blueEnd = Color.blue(endColor);
    int greenEnd = Color.green(endColor);
    int alphaEnd = Color.alpha(endColor);
 
    int redDifference = redEnd - redStart;
    int blueDifference = blueEnd - blueStart;
    int greenDifference = greenEnd - greenStart;
    int alphaDifference = alphaEnd - alphaStart;
 
    redCurrent = (int) (redStart + fraction * redDifference);
    blueCurrent = (int) (blueStart + fraction * blueDifference);
    greenCurrent = (int) (greenStart + fraction * greenDifference);
    alphaCurrent = (int) (alphaStart + fraction * alphaDifference);
 
    return Color.argb(alphaCurrent, redCurrent, greenCurrent, blueCurrent);
}

以上就是一对一视频聊天app源码,Android开发之取两个色值的中间色, 更多内容欢迎关注之后的文章

更多推荐

一对一视频聊天app源码,Android开发之取两个色值的中间色

本文发布于:2023-04-28 10:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/4988c1c94febffcf6e0779e2f5723ab1.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:源码   两个   视频   中间色   app

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 108537文章数
  • 27419阅读数
  • 0评论数