void gdWColorDialog::setColor(const WColor& color) { m_refData->m_color = color; char selection[64]; sprintf(selection, "RGB(%3d, %3d, %3d)", color.red(), color.green(), color.blue()); m_pText->setText(selection); }
WColor WStandardPalette::fontColor(int index) const { WColor c = color(index); if (c.red() + c.green() + c.blue() > 3*128) { return WColor(StandardColor::Black); } else return WColor(StandardColor::White); }
WColor WStandardPalette::fontColor(int index) const { WColor c = color(index); if (c.red() + c.green() + c.blue() > 3*128) { return black; } else return white; }
void gdWColorDialog::addColor(WTableCell* cell, const WColor& color) { cell->decorationStyle().setBackgroundColor(color); cell->resize(20, 20); char toolTip[64]; sprintf(toolTip, "RGB(%3d, %3d, %3d)", color.red(), color.green(), color.blue()); cell->setToolTip(toolTip); const WColor* const javaColor = &color; cell->clicked().connect(boost::bind(&gdWColorDialog::setColor, boost::ref(*this), *javaColor)); }
void WRasterImage::setPixel(int x, int y, const WColor& c) { if (painter_) throw WException("WRasterImage::setPixel(): cannot be used while a " "painter is active"); uint8_t* addr = (uint8_t *)impl_->bitmap_->getAddr(x, y); addr[0] = c.blue(); addr[1] = c.green(); addr[2] = c.red(); addr[3] = c.alpha(); }
WColor::WColor(const WString& name) : default_(false), red_(-1), green_(-1), blue_(-1), alpha_(255), name_(name) { WColor c = Wt::Color::parseCssColor(name.toUTF8()); this->setRgb(c.red(), c.green(), c.blue(), c.alpha()); // setRgb() erases name_ name_ = name; }
void WScatterData::dataFromModel(FloatBuffer& simplePtsArray, FloatBuffer& simplePtsSize, FloatBuffer& coloredPtsArray, FloatBuffer& coloredPtsSize, FloatBuffer& coloredPtsColor) { int N = model_->rowCount(); double xMin = chart_->axis(XAxis_3D).minimum(); double xMax = chart_->axis(XAxis_3D).maximum(); double yMin = chart_->axis(YAxis_3D).minimum(); double yMax = chart_->axis(YAxis_3D).maximum(); double zMin = chart_->axis(ZAxis_3D).minimum(); double zMax = chart_->axis(ZAxis_3D).maximum(); for (int i=0; i < N; i++) { if (colorColumn_ == -1 && model_->data(i,ZSeriesColumn_, MarkerBrushColorRole).empty()) { simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin))); simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin))); simplePtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin))); } else if (colorColumn_ == -1) { coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin))); coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin))); coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin))); WColor color = boost::any_cast<WColor>(model_->data(i,ZSeriesColumn_,MarkerBrushColorRole)); coloredPtsColor.push_back((float)color.red()); coloredPtsColor.push_back((float)color.green()); coloredPtsColor.push_back((float)color.blue()); coloredPtsColor.push_back((float)color.alpha()); } else { coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,XSeriesColumn_)) - xMin)/(xMax - xMin))); coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,YSeriesColumn_)) - yMin)/(yMax - yMin))); coloredPtsArray.push_back((float)((Wt::asNumber(model_->data(i,ZSeriesColumn_)) - zMin)/(zMax - zMin))); WColor color = boost::any_cast<WColor>(model_->data(i,colorColumn_,asColorRole_)); coloredPtsColor.push_back((float)color.red()); coloredPtsColor.push_back((float)color.green()); coloredPtsColor.push_back((float)color.blue()); coloredPtsColor.push_back((float)color.alpha()); } FloatBuffer& sizeArrayAlias = (colorColumn_ == -1 && model_->data(i,ZSeriesColumn_, MarkerBrushColorRole).empty()) ? simplePtsSize : coloredPtsSize; if (sizeColumn_ == -1 && model_->data(i,ZSeriesColumn_,MarkerScaleFactorRole).empty()) { sizeArrayAlias.push_back((float)pointSize_); } else if (sizeColumn_ == -1) { sizeArrayAlias.push_back((float)(Wt::asNumber(model_->data(i,ZSeriesColumn_,MarkerScaleFactorRole)))); } else { sizeArrayAlias.push_back((float)(Wt::asNumber(model_->data(i,sizeColumn_, asSizeRole_)))); } } }
WColor WStandardColorMap::interpolate(const WColor& color1, const WColor& color2, double factor) const { return WColor((int)((1-factor)*color1.red() + factor*color2.red()), (int)((1-factor)*color1.green() + factor*color2.green()), (int)((1-factor)*color1.blue() + factor*color2.blue())); }
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8/////////9/////////A void WGoogleMapEx::addPolyline(const std::vector<WGoogleMap::Coordinate>& points, const WColor& color, int width, double opacity) { // opacity has to be between 0.0 and 1.0 opacity = std::max(std::min(opacity, 1.0), 0.0); std::stringstream strm; strm << "var waypoints = [];"; for (size_t i = 0; i < points.size(); ++i) strm << "waypoints[" << i << "] = new google.maps.LatLng(" << points[i].latitude() << ", " << points[i].longitude() << ");"; strm << "var poly = new google.maps.Polyline(waypoints, \"" << color.cssText() << "\", " << width << ", " << opacity << ");" << jsRef() << ".map.addOverlay(poly);"; doGmJavaScript(strm.str(), true); }
QColor transform(const WColor& color) { return QColor(color.red(), color.green(), color.blue(), color.alpha()); }