相关疑难解决方法(0)

计算颜色渐变

给定两种颜色和n步,如何计算n种颜色,包括产生淡化效果的两种给定颜色?

如果可能的话,伪代码是首选,但这可能是用Java实现的.

谢谢!

colors fade

11
推荐指数
3
解决办法
2万
查看次数

iOS在两种颜色之间的点处查找颜色

我有一个问题:我需要能够采用两种颜色并从中制作出"虚拟渐变".然后,我需要能够在此行的任何位置找到颜色.我目前的做法是:

if (fahrenheit < kBottomThreshold)
{
    return [UIColor colorWithRed:kBottomR/255.0f green:kBottomG/255.0f blue:kBottomB/255.0f alpha:1];
}
if (fahrenheit > kTopThreshold)
{
    return [UIColor colorWithRed:kTopR/255.0f green:kTopG/255.0f blue:kTopB/255.0f alpha:1];
}

double rDiff = kTopR - kBottomR;
double gDiff = kTopG - kBottomG;
double bDiff = kTopB - kBottomB;

double tempDiff = kTopThreshold - kBottomThreshold;

double rValue;
double gValue;
double bValue;

rValue = kBottomR + ((rDiff/tempDiff) * fahrenheit);
gValue = kBottomG + ((gDiff/tempDiff) * fahrenheit);
bValue = kBottomB + ((bDiff/tempDiff) * fahrenheit);

return [UIColor colorWithRed:rValue/255.0f green:gValue/255.0f …
Run Code Online (Sandbox Code Playgroud)

gradient blending linear-gradients uicolor ios

9
推荐指数
4
解决办法
3091
查看次数

如何从Color SwiftUI获取RGB组件

如果我有一个SwiftUI Color

let col: Color = Color(red: 0.5, green: 0.5, blue: 0.5)
Run Code Online (Sandbox Code Playgroud)

如何从中获取RGB分量col
像这样:

print(col.components.red)
Run Code Online (Sandbox Code Playgroud)

在UIKit中,我可以使用,UIColor.getRed但SwiftUI中似乎没有等效项。

rgb colors swift swiftui

5
推荐指数
3
解决办法
822
查看次数

标签 统计

colors ×2

blending ×1

fade ×1

gradient ×1

ios ×1

linear-gradients ×1

rgb ×1

swift ×1

swiftui ×1

uicolor ×1