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


C++ Color::getAlpha方法代码示例

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


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

示例1: onSetColor

void HsvSliders::onSetColor(const app::Color& color)
{
  setAbsSliderValue(0, color.getHue());
  setAbsSliderValue(1, color.getSaturation());
  setAbsSliderValue(2, color.getValue());
  setAbsSliderValue(3, color.getAlpha());
}
开发者ID:JamesLongo,项目名称:aseprite,代码行数:7,代码来源:color_sliders.cpp

示例2: draw_color

void draw_color(ui::Graphics* g, const Rect& rc, const app::Color& color)
{
  if (rc.w < 1 || rc.h < 1)
    return;

  app::Color::Type type = color.getType();
  int alpha = color.getAlpha();

  if (alpha < 255) {
    if (rc.w == rc.h)
      rectgrid(g, rc, gfx::Size(rc.w/2, rc.h/2));
    else
      rectgrid(g, rc, gfx::Size(rc.w/4, rc.h/2));
  }

  if (alpha > 0) {
    if (type == app::Color::IndexType) {
      int index = color.getIndex();

      if (index >= 0 && index < get_current_palette()->size()) {
        g->fillRect(color_utils::color_for_ui(color), rc);
      }
      else {
        g->fillRect(gfx::rgba(0, 0, 0), rc);
        g->drawLine(gfx::rgba(255, 255, 255),
                    gfx::Point(rc.x+rc.w-2, rc.y+1),
                    gfx::Point(rc.x+1, rc.y+rc.h-2));
      }
    }
    else
      g->fillRect(color_utils::color_for_ui(color), rc);
  }
}
开发者ID:net4nt,项目名称:aseprite,代码行数:33,代码来源:gfx.cpp

示例3: 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());
}
开发者ID:webbie1887,项目名称:aseprite,代码行数:14,代码来源:color_sliders.cpp

示例4: 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);
  }
}
开发者ID:webbie1887,项目名称:aseprite,代码行数:18,代码来源:color_popup.cpp

示例5: 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);
}
开发者ID:webbie1887,项目名称:aseprite,代码行数:39,代码来源:color_popup.cpp

示例6: 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());
//.........这里部分代码省略.........
开发者ID:4144,项目名称:aseprite,代码行数:101,代码来源:cmd_eyedropper.cpp


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