本文整理汇总了C++中app::Color::getGreen方法的典型用法代码示例。如果您正苦于以下问题:C++ Color::getGreen方法的具体用法?C++ Color::getGreen怎么用?C++ Color::getGreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::Color
的用法示例。
在下文中一共展示了Color::getGreen方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSetColor
void RgbSliders::onSetColor(const app::Color& color)
{
setAbsSliderValue(0, color.getRed());
setAbsSliderValue(1, color.getGreen());
setAbsSliderValue(2, color.getBlue());
setAbsSliderValue(3, color.getAlpha());
}
示例2: draw_alpha_slider
// TODO this code is exactly the same as draw_alpha_slider() with a ui::Graphics
void draw_alpha_slider(she::Surface* s,
const gfx::Rect& rc,
const app::Color& color)
{
const int xmax = MAX(1, rc.w-1);
const doc::color_t c =
(color.getType() != app::Color::MaskType ?
doc::rgba(color.getRed(),
color.getGreen(),
color.getBlue(), 255): 0);
for (int x=0; x<rc.w; ++x) {
const int a = (255 * x / xmax);
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1, c, a);
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2, c, a);
const int mid = rc.h/2;
const int odd = (x / rc.h) & 1;
s->drawVLine(
app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c2: c1)),
rc.x+x, rc.y, mid);
s->drawVLine(
app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c1: c2)),
rc.x+x, rc.y+mid, rc.h-mid);
}
}
示例3: setColor
void HexColorEntry::setColor(const app::Color& color)
{
m_entry.setTextf("%02x%02x%02x",
color.getRed(),
color.getGreen(),
color.getBlue());
}
示例4: onSetColor
void ColorSliders::onSetColor(const app::Color& color)
{
setAbsSliderValue(Channel::Red, color.getRed());
setAbsSliderValue(Channel::Green, color.getGreen());
setAbsSliderValue(Channel::Blue, color.getBlue());
setAbsSliderValue(Channel::HsvHue, int(color.getHsvHue()));
setAbsSliderValue(Channel::HsvSaturation, int(color.getHsvSaturation() * 100.0));
setAbsSliderValue(Channel::HsvValue, int(color.getHsvValue() * 100.0));
setAbsSliderValue(Channel::HslHue, int(color.getHslHue()));
setAbsSliderValue(Channel::HslSaturation, int(color.getHslSaturation() * 100.0));
setAbsSliderValue(Channel::HslLightness, int(color.getHslLightness() * 100.0));
setAbsSliderValue(Channel::Gray, color.getGray());
setAbsSliderValue(Channel::Alpha, color.getAlpha());
}
示例5: color_for_image
raster::color_t color_utils::color_for_image(const app::Color& color, PixelFormat format)
{
if (color.getType() == app::Color::MaskType)
return 0;
raster::color_t c = -1;
switch (format) {
case IMAGE_RGB:
c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
break;
case IMAGE_GRAYSCALE:
c = graya(color.getGray(), 255);
break;
case IMAGE_INDEXED:
if (color.getType() == app::Color::IndexType)
c = color.getIndex();
else
c = get_current_palette()->findBestfit(color.getRed(), color.getGreen(), color.getBlue());
break;
}
return c;
}
示例6: setPaletteEntry
void PaletteEntryEditor::setPaletteEntry(const app::Color& color)
{
PalettePicks entries;
getPicks(entries);
color_t new_pal_color = doc::rgba(color.getRed(),
color.getGreen(),
color.getBlue(), 255);
Palette* palette = get_current_palette();
for (int c=0; c<palette->size(); c++) {
if (entries[c])
palette->setEntry(c, new_pal_color);
}
}
示例7: findBestfitIndex
void ColorPopup::findBestfitIndex(const app::Color& color)
{
if (!m_colorPalette)
return;
// Find bestfit palette entry
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int a = color.getAlpha();
// Search for the closest color to the RGB values
int i = get_current_palette()->findBestfit(r, g, b, a, 0);
if (i >= 0) {
m_colorPalette->deselect();
m_colorPalette->selectColor(i);
}
}
示例8: color_for_allegro
int color_utils::color_for_allegro(const app::Color& color, int depth)
{
int c = -1;
switch (color.getType()) {
case app::Color::MaskType:
c = get_mask_for_bitmap(depth);
break;
case app::Color::RgbType:
case app::Color::HsvType:
c = makeacol_depth(depth,
color.getRed(),
color.getGreen(),
color.getBlue(), 255);
break;
case app::Color::GrayType:
c = color.getGray();
if (depth != 8)
c = makeacol_depth(depth, c, c, c, 255);
break;
case app::Color::IndexType:
c = color.getIndex();
if (depth != 8) {
ASSERT(c >= 0 && c < (int)get_current_palette()->size());
uint32_t _c = get_current_palette()->getEntry(c);
c = makeacol_depth(depth,
rgba_getr(_c),
rgba_getg(_c),
rgba_getb(_c), 255);
}
break;
}
return c;
}
示例9: setColor
void ColorPopup::setColor(const app::Color& color,
const SetColorOptions options)
{
m_color = color;
if (m_simpleColors) {
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int a = color.getAlpha();
int i = g_simplePal->findExactMatch(r, g, b, a, -1);
if (i >= 0)
m_simpleColors->selectColor(i);
else
m_simpleColors->deselect();
}
if (color.getType() == app::Color::IndexType) {
if (m_colorPalette) {
m_colorPalette->deselect();
m_colorPalette->selectColor(color.getIndex());
}
}
m_sliders.setColor(m_color);
if (!m_disableHexUpdate)
m_hexColorEntry.setColor(m_color);
if (options == ChangeType)
selectColorType(m_color.getType());
// Set the new color
Shade shade = m_oldAndNew.getShade();
shade.resize(2);
shade[1] = (color.getType() == app::Color::IndexType ? color.toRgb(): color);
if (!m_insideChange)
shade[0] = shade[1];
m_oldAndNew.setShade(shade);
}
示例10: color_for_ui
ui::Color color_utils::color_for_ui(const app::Color& color)
{
ui::Color c = ui::ColorNone;
switch (color.getType()) {
case app::Color::MaskType:
c = ui::ColorNone;
break;
case app::Color::RgbType:
case app::Color::HsvType:
c = ui::rgba(color.getRed(),
color.getGreen(),
color.getBlue(), 255);
break;
case app::Color::GrayType:
c = ui::rgba(color.getGray(),
color.getGray(),
color.getGray(), 255);
break;
case app::Color::IndexType: {
int i = color.getIndex();
ASSERT(i >= 0 && i < (int)get_current_palette()->size());
uint32_t _c = get_current_palette()->getEntry(i);
c = ui::rgba(rgba_getr(_c),
rgba_getg(_c),
rgba_getb(_c), 255);
break;
}
}
return c;
}
示例11: pickSample
void EyedropperCommand::pickSample(const doc::Site& site,
const gfx::Point& pixelPos,
app::Color& color)
{
// Check if we've to grab alpha channel or the merged color.
Preferences& pref = Preferences::instance();
bool allLayers =
(pref.eyedropper.sample() == app::gen::EyedropperSample::ALL_LAYERS);
ColorPicker picker;
picker.pickColor(site,
pixelPos,
(allLayers ?
ColorPicker::FromComposition:
ColorPicker::FromActiveLayer));
app::gen::EyedropperChannel channel =
pref.eyedropper.channel();
app::Color picked = picker.color();
switch (channel) {
case app::gen::EyedropperChannel::COLOR_ALPHA:
color = picked;
break;
case app::gen::EyedropperChannel::COLOR:
if (picked.getAlpha() > 0)
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::ALPHA:
switch (color.getType()) {
case app::Color::RgbType:
case app::Color::IndexType:
color = app::Color::fromRgb(color.getRed(),
color.getGreen(),
color.getBlue(),
picked.getAlpha());
break;
case app::Color::HsvType:
color = app::Color::fromHsv(color.getHue(),
color.getSaturation(),
color.getValue(),
picked.getAlpha());
break;
case app::Color::GrayType:
color = app::Color::fromGray(color.getGray(),
picked.getAlpha());
break;
}
break;
case app::gen::EyedropperChannel::RGBA:
if (picked.getType() == app::Color::RgbType)
color = picked;
else
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::RGB:
if (picked.getAlpha() > 0)
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::HSVA:
if (picked.getType() == app::Color::HsvType)
color = picked;
else
color = app::Color::fromHsv(picked.getHue(),
picked.getSaturation(),
picked.getValue(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::HSV:
if (picked.getAlpha() > 0)
color = app::Color::fromHsv(picked.getHue(),
picked.getSaturation(),
picked.getValue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::GRAYA:
if (picked.getType() == app::Color::GrayType)
color = picked;
else
color = app::Color::fromGray(picked.getGray(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::GRAY:
if (picked.getAlpha() > 0)
color = app::Color::fromGray(picked.getGray(),
color.getAlpha());
//.........这里部分代码省略.........
示例12: setAbsolutePaletteEntryChannel
void PaletteEntryEditor::setAbsolutePaletteEntryChannel(ColorSliders::Channel channel, const app::Color& color)
{
PalettePicks entries;
getPicks(entries);
int picksCount = entries.picks();
uint32_t src_color;
int r, g, b;
Palette* palette = get_current_palette();
for (int c=0; c<palette->size(); c++) {
if (!entries[c])
continue;
// Get the current RGB values of the palette entry
src_color = palette->getEntry(c);
r = rgba_getr(src_color);
g = rgba_getg(src_color);
b = rgba_getb(src_color);
switch (m_type) {
case app::Color::RgbType:
// Modify one entry
if (picksCount == 1) {
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
}
// Modify one channel a set of entries
else {
// Setup the new RGB values depending of the modified channel.
switch (channel) {
case ColorSliders::Red:
r = color.getRed();
case ColorSliders::Green:
g = color.getGreen();
break;
case ColorSliders::Blue:
b = color.getBlue();
break;
}
}
break;
case app::Color::HsvType:
{
Hsv hsv;
// Modify one entry
if (picksCount == 1) {
hsv.hue(color.getHue());
hsv.saturation(double(color.getSaturation()) / 100.0);
hsv.value(double(color.getValue()) / 100.0);
}
// Modify one channel a set of entries
else {
// Convert RGB to HSV
hsv = Hsv(Rgb(r, g, b));
// Only modify the desired HSV channel
switch (channel) {
case ColorSliders::Hue:
hsv.hue(color.getHue());
break;
case ColorSliders::Saturation:
hsv.saturation(double(color.getSaturation()) / 100.0);
break;
case ColorSliders::Value:
hsv.value(double(color.getValue()) / 100.0);
break;
}
}
// Convert HSV back to RGB
Rgb rgb(hsv);
r = rgb.red();
g = rgb.green();
b = rgb.blue();
}
break;
}
palette->setEntry(c, doc::rgba(r, g, b, 255));
}
}