void RenderContext::draw_text(litehtml::uint_ptr hdc, const litehtml::tchar_t* text, litehtml::uint_ptr hFont, litehtml::web_color color, const litehtml::position& pos ) { CntxFont* fnt = (CntxFont*)hFont; int x = pos.left(); int y = pos.top();// - ext.descent; fnt->font.setColor(NColor(color.alpha,color.red,color.green,color.blue)); fnt->font.draw( _picture, text, Point(x,y), true, false); int tw = 0; if(fnt->underline || fnt->strikeout) { tw = text_width(text, hFont); } if(fnt->underline) { int h = fnt->font.getTextSize(text).height(); Decorator::drawLine( _picture, Point(x, y + h + 1),Point(x + tw,y + h + 1), NColor(color.alpha, color.red, color.green, color.blue)); } if(fnt->strikeout) { Size tex = fnt->font.getTextSize("x"); int ln_y = y - tex.height() / 2.0; Decorator::drawLine( _picture, Point(x, y + ln_y - 1),Point(x + tw, y + ln_y - 1), NColor(color.alpha, color.red, color.green, color.blue)); } }
/** \param other Color to add to this color \return Addition of the two colors, clamped to 0..255 values */ NColor operator+(const NColor& other) const { return NColor( (std::min)( getAlpha() + other.getAlpha(), 255 ), (std::min)(getRed() + other.getRed(), 255), (std::min)(getGreen() + other.getGreen(), 255), (std::min)(getBlue() + other.getBlue(), 255)); }
void SplashScreen::initialize() { Engine& engine = Engine::instance(); _d->textPic = Picture( Size( 800, 30 ), 0, true ); _d->fadetx = Picture( engine.screenSize(), 0, true ); _d->fadetx.fill( NColor(0xff, 0, 0, 0), Rect() ); }
/** \param other: Other color \param d: value between 0.0f and 1.0f \return Interpolated color. */ NColor getInterpolated(const NColor &other, float d) const { d = math::clamp(d, 0.f, 1.f); const float inv = 1.0f - d; return NColor((unsigned int)floor(other.getAlpha()*inv + getAlpha()*d), (unsigned int)floor(other.getRed()*inv + getRed()*d), (unsigned int)floor(other.getGreen()*inv + getGreen()*d), (unsigned int)floor(other.getBlue()*inv + getBlue()*d)); }
NColor GraphicsPatternRadial::GetColorAndDistance(int index, double &distance) { if (index < 0) throw new XException((Text)"Index " + index + " out of bounds", __FILE__, __LINE__, __func__); int numColors = GetColorsCount(); if (index >= numColors) throw new XException((Text)"Index " + index + " out of bounds (" + numColors + ")", __FILE__, __LINE__, __func__); double r = 0, g = 0, b = 0, a = 0; cairo_pattern_get_color_stop_rgba(pattern, index, &distance, &r, &g, &b, &a); return NColor(r, g, b, a); }
void RenderContext::draw_list_marker( litehtml::uint_ptr hdc, const litehtml::list_marker& marker ) { if(!marker.image.empty()) { /*litehtml::tstring url; make_url(marker.image.c_str(), marker.baseurl, url); lock_images_cache(); images_map::iterator img_i = m_images.find(url.c_str()); if(img_i != m_images.end()) { if(img_i->second) { draw_txdib((cairo_t*) hdc, img_i->second, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height); } } unlock_images_cache();*/ } else { switch(marker.marker_type) { case litehtml::list_style_type_circle: { //draw_ellipse((cairo_t*) hdc, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height, marker.color, 0.5); } break; case litehtml::list_style_type_disc: { //fill_ellipse((cairo_t*) hdc, marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height, marker.color); } break; case litehtml::list_style_type_square: if(hdc) { _picture.fill( NColor(marker.color.alpha, marker.color.red, marker.color.green, marker.color.blue), Rect(marker.pos.x, marker.pos.y, marker.pos.x+marker.pos.width, marker.pos.y+marker.pos.height)); } break; default: /*do nothing*/ break; } } }
static const NString kKeyDate = "Test Date"; static const NString kKeyColor = "Test Color"; // Values static const NString kValueString1 = "First String"; static const NString kValueString2 = "Second String"; static const bool kValueBoolean1 = true; static const bool kValueBoolean2 = false; static const SInt64 kValueNumber1 = -2342; static const Float64 kValueNumber2 = kNPi; static const UInt8 kValueData1[] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A }; static const UInt8 kValueData2[] = { 0x3C, 0xE7, 0xC7, 0x32, 0xE3, 0xD8, 0x52 }; static const NDate kValueDate1 = NDate(-886538221); static const NDate kValueDate2 = NDate( 268617632); static const NColor kValueColor1 = NColor(1.0f, 0.8f, 0.4f, 0.2f); static const NColor kValueColor2 = NColor(0.1f, 0.2f, 0.3f, 0.4f); // Property lists static const NString kPropertyListXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n" "<dict>\n" " <key>Test Array</key>\n" " <array>\n" " <string>First String</string>\n" " <true/>\n" " <integer>-2342</integer>\n" " <date>1972-11-28T03:22:59Z</date>\n" " <data>TmVOYzAwMDEAAADzeNqzsa/IzVEoSy0qzszPs1Uy1DNQUkjNS85PycxLt1UKDXHTtVCyt+Oy\n"
// Include files //---------------------------------------------------------------------------- #include "NGeometryUtilities.h" #include "NCoreGraphics.h" #include "NCGShading.h" #include "NCGColor.h" //============================================================================ // Public constants //---------------------------------------------------------------------------- // Shadings const NShadingSample kShadingBlackWhite[] = { { 0.0f, NColor(0.0f, 0.0f, 0.0f) }, { 1.0f, NColor(1.0f, 1.0f, 1.0f) } }; const NShadingSample kShadingWhiteBlack[] = { { 0.0f, NColor(1.0f, 1.0f, 1.0f) }, { 1.0f, NColor(0.0f, 0.0f, 0.0f) } }; const NShadingSample kShadingFrontRow[] = { { 0.0f, NColor(0.000f, 0.000f, 0.000f) }, { 0.5f, NColor(0.000f, 0.000f, 0.000f) }, { 1.0f, NColor(0.298f, 0.298f, 0.298f) } }; //============================================================================ // NCGShading::NCGShading : Constructor.
void RenderContext::set_color(Picture* cr, litehtml::web_color color) { _color = NColor(color.alpha, color.red, color.green, color.blue); }