当前位置: 首页>>代码示例>>C++>>正文


C++ FColor::alpha方法代码示例

本文整理汇总了C++中FColor::alpha方法的典型用法代码示例。如果您正苦于以下问题:C++ FColor::alpha方法的具体用法?C++ FColor::alpha怎么用?C++ FColor::alpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FColor的用法示例。


在下文中一共展示了FColor::alpha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hsbFromRgb

FColor HSB::hsbFromRgb(const FColor& rgb) {
    const auto brightness = max(
        max(RGB::red(rgb), RGB::green(rgb)), RGB::blue(rgb));
    auto hue = 0.0f, saturation = 0.0f;

    if (not near(brightness, 0.0)) {
        const auto darkest = min(
            min(RGB::red(rgb), RGB::green(rgb)), RGB::blue(rgb));
        const auto range = brightness - darkest;
        saturation = range / brightness;

        if (not near(saturation, 0.0)) {
            const float r = (brightness - RGB::red(rgb)) / range;
            const float g = (brightness - RGB::green(rgb)) / range;
            const float b = (brightness - RGB::blue(rgb)) / range;

            if (near(RGB::red(rgb), brightness))
                hue = b - g;
            else if (near(RGB::green(rgb), brightness))
                hue = 2.0f + r - b;
            else
                hue = 4.0f + g - r;

            hue /= 6.0f;

            if (hue < 0)
                hue += 1.0f;
        }
    }
    return FColor(hue, saturation, brightness, rgb.alpha());
}
开发者ID:TopRamenGod,项目名称:echomesh,代码行数:31,代码来源:HSB.cpp

示例2: hsbToRgb

// from http://www.cs.rit.edu/~ncs/color/t_convert.html
FColor HSB::hsbToRgb(const FColor& hsb) {
    auto h = hue(hsb), s = saturation(hsb), b = brightness(hsb);
    float red, green, blue;
    if (s == 0) {
        // achromatic (grey)
        red = green = blue = b;
    } else {
        h *= 6;			// sector 0 to 5
        int i = floor(h);
        auto f = h - i;			// factorial part of h
        auto p = b * (1 - s);
        auto q = b * (1 - s * f);
        auto t = b * (1 - s * (1 - f));

        switch(i) {
            case 0:
                red = b;
                green = t;
                blue = p;
                break;

            case 1:
                red = q;
                green = b;
                blue = p;
                break;

            case 2:
                red = p;
                green = b;
                blue = t;
                break;

            case 3:
                red = p;
                green = q;
                blue = b;
                break;

            case 4:
                red = t;
                green = p;
                blue = b;
                break;

            case 5:
            default:
                red = b;
                green = p;
                blue = q;
                break;
        }
    }

    return FColor(red, green, blue, hsb.alpha());
}
开发者ID:TopRamenGod,项目名称:echomesh,代码行数:57,代码来源:HSB.cpp


注:本文中的FColor::alpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。