本文整理汇总了C++中app::Color类的典型用法代码示例。如果您正苦于以下问题:C++ Color类的具体用法?C++ Color怎么用?C++ Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setColor
void HexColorEntry::setColor(const app::Color& color)
{
m_entry.setTextf("%02x%02x%02x",
color.getRed(),
color.getGreen(),
color.getBlue());
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:7,代码来源:hex_color_entry.cpp
示例2: pcOpenEdge
ViewProviderMeshNode::ViewProviderMeshNode() : pcOpenEdge(0), m_bEdit(false)
{
ADD_PROPERTY(LineWidth,(2.0f));
LineWidth.setConstraints(&floatRange);
ADD_PROPERTY(PointSize,(2.0f));
PointSize.setConstraints(&floatRange);
ADD_PROPERTY(OpenEdges,(false));
pOpenColor = new SoBaseColor();
setOpenEdgeColorFrom(ShapeColor.getValue());
pOpenColor->ref();
pcLineStyle = new SoDrawStyle();
pcLineStyle->ref();
pcLineStyle->style = SoDrawStyle::LINES;
pcLineStyle->lineWidth = LineWidth.getValue();
pcPointStyle = new SoDrawStyle();
pcPointStyle->ref();
pcPointStyle->style = SoDrawStyle::POINTS;
pcPointStyle->pointSize = PointSize.getValue();
// read the correct shape color from the preferences
Base::Reference<ParameterGrp> hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh");
App::Color color = ShapeColor.getValue();
unsigned long current = color.getPackedValue();
unsigned long setting = hGrp->GetUnsigned("MeshColor", current);
if ( current != setting )
{
color.setPackedValue((uint32_t)setting);
ShapeColor.setValue(color);
}
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:33,代码来源:ViewProviderMeshNode.cpp
示例3: 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);
}
}
开发者ID:imeteora,项目名称:aseprite,代码行数:26,代码来源:gfx.cpp
示例4: onSetColor
void RgbSliders::onSetColor(const app::Color& color)
{
setAbsSliderValue(0, color.getRed());
setAbsSliderValue(1, color.getGreen());
setAbsSliderValue(2, color.getBlue());
setAbsSliderValue(3, color.getAlpha());
}
开发者ID:JamesLongo,项目名称:aseprite,代码行数:7,代码来源:color_sliders.cpp
示例5:
ViewProviderDimension::ViewProviderDimension()
{
sPixmap = "TechDraw_Dimension";
static const char *group = "Dim Format";
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double fontSize = hGrp->GetFloat("FontSize", 3.5);
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),group,App::Prop_None, "The name of the font to use");
ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,group,(App::PropertyType)(App::Prop_None),"Dimension text size in units");
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Thin");
delete lg; //Coverity CID 174670
ADD_PROPERTY_TYPE(LineWidth,(weight) ,group,(App::PropertyType)(App::Prop_None),"Dimension line weight");
hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
ADD_PROPERTY_TYPE(Color,(fcColor),group,App::Prop_None,"The color of the Dimension");
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:30,代码来源:ViewProviderDimension.cpp
示例6: draw_color
static 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();
if (type == app::Color::MaskType) {
rectgrid(g, rc, gfx::Size(rc.w/4, rc.h/2));
return;
}
else 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));
}
return;
}
g->fillRect(color_utils::color_for_ui(color), rc);
}
开发者ID:1007650105,项目名称:aseprite,代码行数:28,代码来源:gfx.cpp
示例7: getSelectColor
QColor QGCustomText::getSelectColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000));
return fcColor.asValue<QColor>();
}
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:7,代码来源:QGCustomText.cpp
示例8: getBackgroundColor
QColor QGVPage::getBackgroundColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Background", 0x70707000));
return fcColor.asValue<QColor>();
}
开发者ID:peterl94,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:QGVPage.cpp
示例9: getSelectColor
QColor QGIView::getSelectColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroupCol();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000));
m_colSel = fcColor.asValue<QColor>();
return m_colSel;
}
开发者ID:lanigb,项目名称:FreeCAD,代码行数:8,代码来源:QGIView.cpp
示例10: setPyObject
void PropertyColor::setPyObject(PyObject *value)
{
App::Color cCol;
if (PyTuple_Check(value) && PyTuple_Size(value) == 3) {
PyObject* item;
item = PyTuple_GetItem(value,0);
if (PyFloat_Check(item))
cCol.r = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
item = PyTuple_GetItem(value,1);
if (PyFloat_Check(item))
cCol.g = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
item = PyTuple_GetItem(value,2);
if (PyFloat_Check(item))
cCol.b = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
}
else if (PyTuple_Check(value) && PyTuple_Size(value) == 4) {
PyObject* item;
item = PyTuple_GetItem(value,0);
if (PyFloat_Check(item))
cCol.r = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
item = PyTuple_GetItem(value,1);
if (PyFloat_Check(item))
cCol.g = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
item = PyTuple_GetItem(value,2);
if (PyFloat_Check(item))
cCol.b = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
item = PyTuple_GetItem(value,3);
if (PyFloat_Check(item))
cCol.a = (float)PyFloat_AsDouble(item);
else
throw Base::Exception("Type in tuple must be float");
}
else if (PyLong_Check(value)) {
cCol.setPackedValue(PyLong_AsUnsignedLong(value));
}
else {
std::string error = std::string("type must be int or tuple of float, not ");
error += value->ob_type->tp_name;
throw Py::TypeError(error);
}
setValue( cCol );
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:55,代码来源:PropertyStandard.cpp
示例11: 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);
}
}
开发者ID:93i,项目名称:aseprite,代码行数:15,代码来源:cmd_palette_editor.cpp
示例12: 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
示例13: decodeColor
App::Color Cell::decodeColor(const std::string & color, const App::Color & defaultColor)
{
if (color.size() == 7 || color.size() == 9) {
App::Color c;
if (color[0] != '#')
return defaultColor;
unsigned int value = strtoul(color.c_str() + 1, 0, 16);
if (color.size() == 7)
value = (value << 8) | 0xff;
c.setPackedValue(value);
return c;
}
else
return defaultColor;
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:18,代码来源:Cell.cpp
示例14: getNormalColor
QColor QGCustomText::getNormalColor()
{
QColor result;
QGIView *parent;
QGraphicsItem* qparent = parentItem();
if (qparent == nullptr) {
parent = nullptr;
} else {
parent = dynamic_cast<QGIView *> (qparent);
}
if (parent != nullptr) {
result = parent->getNormalColor();
} else {
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
result = fcColor.asValue<QColor>();
}
return result;
}
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:21,代码来源:QGCustomText.cpp
示例15: color_for_layer
raster::color_t color_utils::color_for_layer(const app::Color& color, Layer* layer)
{
raster::color_t pixel_color;
if (color.getType() == app::Color::MaskType) {
pixel_color = layer->getSprite()->getTransparentColor();
}
else {
PixelFormat format = layer->getSprite()->getPixelFormat();
pixel_color = color_for_image(color, format);
}
return fixup_color_for_layer(layer, pixel_color);
}
开发者ID:DocHoncho,项目名称:aseprite,代码行数:14,代码来源:color_utils.cpp
示例16: switch
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;
}
开发者ID:DocHoncho,项目名称:aseprite,代码行数:24,代码来源:color_utils.cpp
示例17: selectColorType
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
示例18: getSheetImage
std::string DrawViewSpreadsheet::getSheetImage(void)
{
std::stringstream result;
App::DocumentObject* link = Source.getValue();
std::string scellstart = CellStart.getValue();
std::string scellend = CellEnd.getValue();
std::vector<std::string> availcolumns = getAvailColumns();
// build rows range and columns range
std::vector<std::string> columns;
std::vector<int> rows;
try {
for (unsigned int i=0; i<scellstart.length(); ++i) {
if (isdigit(scellstart[i])) {
columns.push_back(scellstart.substr(0,i));
rows.push_back(std::atoi(scellstart.substr(i,scellstart.length()-1).c_str()));
}
}
for (unsigned int i=0; i<scellend.length(); ++i) {
if (isdigit(scellend[i])) {
std::string startcol = columns.back();
std::string endcol = scellend.substr(0,i);
bool valid = false;
for (std::vector<std::string>::const_iterator j = availcolumns.begin(); j != availcolumns.end(); ++j) {
if ( (*j) == startcol) {
if ( (*j) != endcol) {
valid = true;
}
} else {
if (valid) {
if ( (*j) == endcol) {
columns.push_back((*j));
valid = false;
} else {
columns.push_back((*j));
}
}
}
}
int endrow = std::atoi(scellend.substr(i,scellend.length()-1).c_str());
for (int j=rows.back()+1; j<=endrow; ++j) {
rows.push_back(j);
}
}
}
} catch (std::exception) {
Base::Console().Error("Invalid cell range for %s\n",getNameInDocument());
return result.str();
}
// create the containing group
std::string ViewName = Label.getValue();
result << getSVGHead();
App::Color c = TextColor.getValue();
result << "<g id=\"" << ViewName << "\">" << endl;
// fill the cells
float rowoffset = 0.0;
float coloffset = 0.0;
float cellheight = 100;
float cellwidth = 100;
std::string celltext;
Spreadsheet::Sheet* sheet = static_cast<Spreadsheet::Sheet*>(link);
std::vector<std::string> skiplist;
for (std::vector<std::string>::const_iterator col = columns.begin(); col != columns.end(); ++col) {
// create a group for each column
result << " <g id=\"" << ViewName << "_col" << (*col) << "\">" << endl;
for (std::vector<int>::const_iterator row = rows.begin(); row != rows.end(); ++row) {
// get cell size
std::stringstream srow;
srow << (*row);
App::CellAddress address((*col) + srow.str());
cellwidth = sheet->getColumnWidth(address.col());
cellheight = sheet->getRowHeight(address.row());
celltext = "";
// get the text
App::Property* prop = sheet->getPropertyByName(address.toString().c_str());
std::stringstream field;
if (prop != 0) {
if (prop->isDerivedFrom((App::PropertyQuantity::getClassTypeId())))
field << static_cast<App::PropertyQuantity*>(prop)->getValue();
else if (prop->isDerivedFrom((App::PropertyFloat::getClassTypeId())))
field << static_cast<App::PropertyFloat*>(prop)->getValue();
else if (prop->isDerivedFrom((App::PropertyString::getClassTypeId())))
field << static_cast<App::PropertyString*>(prop)->getValue();
else
assert(0);
celltext = field.str();
}
// get colors, style, alignment and span
int alignment;
std::string bcolor = "none";
std::string fcolor = c.asCSSString();
std::string textstyle = "";
Spreadsheet::Cell* cell = sheet->getCell(address);
if (cell) {
//.........这里部分代码省略.........
开发者ID:eivindkv,项目名称:free-cad-code,代码行数:101,代码来源:DrawViewSpreadsheet.cpp
示例19: onColorButtonChange
void ColorBar::onColorButtonChange(const app::Color& color)
{
if (color.getType() == app::Color::IndexType)
m_paletteView.selectColor(color.getIndex());
}
开发者ID:richardlalancette,项目名称:aseprite,代码行数:5,代码来源:color_bar.cpp
示例20: set_config_color
void set_config_color(const char* section, const char* name, const app::Color& value)
{
set_config_string(section, name, value.toString().c_str());
}
开发者ID:macartur-tcc,项目名称:aseprite,代码行数:4,代码来源:ini_file.cpp
注:本文中的app::Color类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论