• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ wxColor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中wxColor的典型用法代码示例。如果您正苦于以下问题:C++ wxColor类的具体用法?C++ wxColor怎么用?C++ wxColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: ConvertTo24Bit

wxBitmap ConvertTo24Bit( wxColor bgColor, wxBitmap front ) {
    if( front.GetDepth() == 24 ) return front;

    wxBitmap result( front.GetWidth(), front.GetHeight(), 24 );
    front.UseAlpha();

    wxImage im_front = front.ConvertToImage();
    wxImage im_result = result.ConvertToImage();

    unsigned char *presult = im_result.GetData();
    unsigned char *pfront = im_front.GetData();

    unsigned char *afront = NULL;
    if( im_front.HasAlpha() )
        afront = im_front.GetAlpha();

    for( int i = 0; i < result.GetWidth(); i++ ) {
        for( int j = 0; j < result.GetHeight(); j++ ) {

            double alphaF = (double) ( *afront++ ) / 256.0;
            unsigned char r = *pfront++ * alphaF + bgColor.Red() * ( 1.0 - alphaF );
            *presult++ = r;
            unsigned char g = *pfront++ * alphaF + bgColor.Green() * ( 1.0 - alphaF );
            *presult++ = g;
            unsigned char b = *pfront++ * alphaF + bgColor.Blue() * ( 1.0 - alphaF );
            *presult++ = b;
        }
    }

    result = wxBitmap( im_result );
    return result;
}
开发者ID:doublespy,项目名称:OpenCPN,代码行数:32,代码来源:styles.cpp


示例2: StepColour

// StepColour() it a utility function that simply darkens
// or lightens a color, based on the specified percentage
static wxColor StepColour(const wxColor& c, int percent)
{
    int r = c.Red(), g = c.Green(), b = c.Blue();
    return wxColour((unsigned char)wxMin((r*percent)/100,255),
                    (unsigned char)wxMin((g*percent)/100,255),
                    (unsigned char)wxMin((b*percent)/100,255));
}
开发者ID:lpoujoulat,项目名称:wxWidgetsToolPalette,代码行数:9,代码来源:minifram.cpp


示例3: wxStepColour

static wxColor wxStepColour(const wxColor& c, int ialpha)
{
    if (ialpha == 100)
        return c;

    double r = c.Red(), g = c.Green(), b = c.Blue();
    double bg;

    // ialpha is 0..200 where 0 is completely black
    // and 200 is completely white and 100 is the same
    // convert that to normal alpha 0.0 - 1.0
    ialpha = wxMin(ialpha, 200);
    ialpha = wxMax(ialpha, 0);
    double alpha = ((double)(ialpha - 100.0))/100.0;

    if (ialpha > 100)
    {
        // blend with white
        bg = 255.0;
        alpha = 1.0 - alpha;  // 0 = transparent fg; 1 = opaque fg
    }
     else
    {
        // blend with black
        bg = 0.0;
        alpha = 1.0 + alpha;  // 0 = transparent fg; 1 = opaque fg
    }

    r = wxBlendColour(r, bg, alpha);
    g = wxBlendColour(g, bg, alpha);
    b = wxBlendColour(b, bg, alpha);

    return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b);
}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:34,代码来源:srchctlg.cpp


示例4: bg_color_updated

void Overlay::bg_color_updated(const wxColor& bg)
{
    if (0.299*bg.Red() + 0.587*bg.Green() + 0.114*bg.Blue() < 128)
        color_.Set(192, 192, 192);
    else
        color_.Set(64, 64, 64);
}
开发者ID:darckense,项目名称:fityk,代码行数:7,代码来源:plot.cpp


示例5: entityColorAsString

 String entityColorAsString(const wxColor& color, const Assets::ColorRange::Type colorRange) {
     StringStream result;
     if (colorRange == Assets::ColorRange::Byte) {
         result << int(color.Red()) << " " << int(color.Green()) << " " << int(color.Blue());
     } else if (colorRange == Assets::ColorRange::Float) {
         result << float(color.Red()) / 255.0f << " " << float(color.Green()) / 255.0f << " "<< float(color.Blue()) / 255.0f;
     }
     return result.str();
 }
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:9,代码来源:EntityColor.cpp


示例6: wxColor

wxColor CodeEdit::GetInverse(const wxColor& color)
{

    unsigned char r = color.Red();
    unsigned char g = color.Green();
    unsigned char b = color.Blue();

    return wxColor( r ^ 0xFF, g ^ 0xFF, b ^ 0xFF );

}
开发者ID:Halfbrick,项目名称:decoda,代码行数:10,代码来源:CodeEdit.cpp


示例7: createImageFromText

wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const wxColor& col)
{
    //wxDC::DrawLabel() doesn't respect alpha channel => calculate alpha values manually:

    if (text.empty())
        return wxImage();

    wxBitmap newBitmap(getTextExtent(text, font)); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
    {
        wxMemoryDC dc(newBitmap);
        dc.SetBackground(*wxWHITE_BRUSH);
        dc.Clear();

        dc.SetTextForeground(*wxBLACK); //for use in calcAlphaForBlackWhiteImage
        dc.SetTextBackground(*wxWHITE); //
        dc.SetFont(font);

        //assert(!contains(text, L"&")); //accelerator keys not supported here; see also getTextExtent()
        wxString textFmt = replaceCpy(text, L"&", L"", false);

        //for some reason wxDC::DrawText messes up "weak" bidi characters even when wxLayout_RightToLeft is set! (--> arrows in hebrew/arabic)
        //=> use mark characters instead:
        const wchar_t rtlMark = L'\u200F';
        if (wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft)
            textFmt = rtlMark + textFmt + rtlMark;

        dc.DrawText(textFmt, wxPoint());
    }

    wxImage output(newBitmap.ConvertToImage());
    output.SetAlpha();

    //calculate alpha channel
    calcAlphaForBlackWhiteImage(output);

    //apply actual text color
    unsigned char* dataPtr = output.GetData();
    const int pixelCount = output.GetWidth() * output.GetHeight();
    for (int i = 0; i < pixelCount; ++ i)
    {
        *dataPtr++ = col.Red();
        *dataPtr++ = col.Green();
        *dataPtr++ = col.Blue();
    }
    return output;
}
开发者ID:YY583456235,项目名称:MinFFS,代码行数:46,代码来源:image_tools.cpp


示例8: readColor

bool readColor(const Json::Value& json, const std::string& prop, wxColor& color)
{
    if(json.isMember(prop))
    {
        wxString tempStr = json[prop].asString();
        color.Set(tempStr);
        return true;
    }
    return false;
}
开发者ID:betrixed,项目名称:AGW,代码行数:10,代码来源:helper.cpp


示例9: SetPanelBC

void MadHighlightingDialog::SetPanelBC(const wxColor &color)
{
    if(color==wxNullColour)
    {
        WxStaticTextBCName->SetLabel(wxT("(Automatic)"));
        WxPanelBC->SetBackgroundColour(WxListCtrlBC->GetItemBackgroundColour(0));
        WxPanelBC->ClearBackground();
    }
    else
    {
        wxString cname=wxTheColourDatabase->FindName(color);
        if(cname.IsEmpty())
        {
            cname.Printf(wxT("#%02X%02X%02X"), color.Red(), color.Green(), color.Blue());
        }
        WxStaticTextBCName->SetLabel(cname);
        WxPanelBC->SetBackgroundColour(color);
        WxPanelBC->ClearBackground();
    }
}
开发者ID:KrasnayaPloshchad,项目名称:madedit-mod,代码行数:20,代码来源:MadHighlightingDialog.cpp


示例10: wxColor

wxColor wxGradient::lerp(wxColor c1, wxColor c2, double value)
{
	unsigned char R = (1.0 - value)*c1.Red() + value*c2.Red();
	unsigned char G = (1.0 - value)*c1.Green() + value*c2.Green();
	unsigned char B = (1.0 - value)*c1.Blue() + value*c2.Blue();
	return wxColor(R,G,B);
}
开发者ID:CarlosManuelRodr,项目名称:wxChaos,代码行数:7,代码来源:gradient.cpp


示例11: SetColour

void wxAuiDefaultDockArt::SetColour(int id, const wxColor& colour)
{
    switch (id)
    {
    case wxAUI_DOCKART_BACKGROUND_COLOUR:
        m_backgroundBrush.SetColour(colour);
        break;
    case wxAUI_DOCKART_SASH_COLOUR:
        m_sashBrush.SetColour(colour);
        break;
    case wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR:
        m_inactiveCaptionColour = colour;
        break;
    case wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR:
        m_inactiveCaptionGradientColour = colour;
        break;
    case wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR:
        m_inactiveCaptionTextColour = colour;
        break;
    case wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR:
        m_activeCaptionColour = colour;
        break;
    case wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR:
        m_activeCaptionGradientColour = colour;
        break;
    case wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR:
        m_activeCaptionTextColour = colour;
        break;
    case wxAUI_DOCKART_BORDER_COLOUR:
        m_borderPen.SetColour(colour);
        break;
    case wxAUI_DOCKART_GRIPPER_COLOUR:
        m_gripperBrush.SetColour(colour);
        m_gripperPen1.SetColour(colour.ChangeLightness(40));
        m_gripperPen2.SetColour(colour.ChangeLightness(60));
        break;
    default:
        wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
        break;
    }

    InitBitmaps();
}
开发者ID:CodeTickler,项目名称:wxWidgets,代码行数:43,代码来源:dockart.cpp


示例12:

PMSColor::PMSColor(wxColor col)
    :  blue{col.Blue()}, green{col.Green()}, red{col.Red()}, alpha{col.Alpha()}
{
}
开发者ID:rzaba0,项目名称:polybobin,代码行数:4,代码来源:pmsstructs.cpp


示例13: TransparentColor

static wxColour TransparentColor(wxColor c)
{
    return wxColor(c.Red(), c.Green(), c.Blue(), c.Alpha()*7/24);
}
开发者ID:jongough,项目名称:weather_routing_pi,代码行数:4,代码来源:RouteMapOverlay.cpp


示例14: DarkenColour

wxColor CamArtProvider::DarkenColour(const wxColor& c, INT32 amount)
{
    INT32 r = c.Red(), g = c.Green(), b = c.Blue();
    return wxColour((r*amount)/100, (g*amount)/100, (b*amount)/100);
}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:5,代码来源:cartprov.cpp


示例15: LightenColour

wxColor CamArtProvider::LightenColour(const wxColor& c, INT32 amount)
{
    INT32 r = 255-c.Red(), g = 255-c.Green(), b = 255-c.Blue();
    return wxColour(255-(r*amount)/100, 255-(g*amount)/100, 255-(b*amount)/100);
}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:5,代码来源:cartprov.cpp


示例16: colorAsString

std::string colorAsString(const wxColor& c)
{
    return c.GetAsString().ToStdString();
}
开发者ID:betrixed,项目名称:AGW,代码行数:4,代码来源:helper.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ wxColour类代码示例发布时间:2022-05-31
下一篇:
C++ wxCmdLineParser类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap