static void separableConvolve (const PixelBufferAccess& dst, const ConstPixelBufferAccess& src, int shiftX, int shiftY, const std::vector<float>& kernelX, const std::vector<float>& kernelY) { DE_ASSERT(dst.getWidth() == src.getWidth() && dst.getHeight() == src.getHeight()); TextureLevel tmp (dst.getFormat(), dst.getHeight(), dst.getWidth()); PixelBufferAccess tmpAccess = tmp.getAccess(); int kw = (int)kernelX.size(); int kh = (int)kernelY.size(); // Horizontal pass // \note Temporary surface is written in column-wise order for (int j = 0; j < src.getHeight(); j++) { for (int i = 0; i < src.getWidth(); i++) { Vec4 sum(0); for (int kx = 0; kx < kw; kx++) { float f = kernelX[kw-kx-1]; deUint32 p = readUnorm8<SrcChannels>(src, de::clamp(i+kx-shiftX, 0, src.getWidth()-1), j); sum += toFloatVec(p)*f; } writeUnorm8<DstChannels>(tmpAccess, j, i, toColor(sum)); } } // Vertical pass for (int j = 0; j < src.getHeight(); j++) { for (int i = 0; i < src.getWidth(); i++) { Vec4 sum(0.0f); for (int ky = 0; ky < kh; ky++) { float f = kernelY[kh-ky-1]; deUint32 p = readUnorm8<DstChannels>(tmpAccess, de::clamp(j+ky-shiftY, 0, tmp.getWidth()-1), i); sum += toFloatVec(p)*f; } writeUnorm8<DstChannels>(dst, i, j, toColor(sum)); } } }
void WStandardColorMap::createStrip(WPainter *painter, const WRectF& area) const { painter->save(); painter->setRenderHint(WPainter::Antialiasing, false); int width, height; if (area.isNull()) { width = (int)painter->device()->width().value(); height = (int)painter->device()->height().value(); } else { painter->translate((int)area.x(), (int)area.y()); width = (int)area.width(); height = (int)area.height(); } double valueInterval = (max_ - min_)/height; double offset = valueInterval/2; for (int i=0; i<height; i++) { WColor color = toColor(min_ + offset + i*valueInterval); painter->setBrush(WBrush(color)); WPen linePen(color); linePen.setWidth(1); painter->setPen(linePen); painter->drawLine(0, height-(0.5+i), width, height-(0.5+i)); } painter->restore(); }
GlobalPainter GlobalPainter::fromXML(const QDomElement& e) { GlobalPainter FP; if (e.hasAttribute("backgroundColor")) { FP.backgroundActive(true); FP.background(toColor(e.attribute("backgroundColor"))); } if (e.hasAttribute("nodesColor")) { FP.nodesActive(true); FP.NodesColor = toColor(e.attribute("nodesColor")); FP.NodesProportional = e.attribute("nodesScale").toDouble(); FP.NodesFixed = e.attribute("nodesOffset").toDouble(); } return FP; }
void IvBox::updateStat(int stat) { if(poke().natureBoost(stat) != 0) { QColor themeColor; switch(poke().natureBoost(stat)) { case -1: themeColor = Theme::Color("Teambuilder/statHindered"); break; case 1: themeColor = Theme::Color("Teambuilder/statRaised"); break; } m_statslabel[stat]->setText(toColor(QString::number(poke().stat(stat)), themeColor)); } else { m_statslabel[stat]->setText(QString::number(poke().stat(stat))); } emit statsUpdated(); }
static int Image_color(lua_State* L){ int argc = lua_gettop(L); ge_Image* dest = selfImage(L, &argc); if(!dest){ return luaL_error(L, "Error: geImage.Color([color]) must be with a colon"); } if(argc > 0){ u32 color = *toColor(L, 1); dest->color = color; }else{ *pushNewColor(L) = dest->color; } return 1; }
Font::Font(const GfxState *state, double size) { if ( size<1 ) kdDebug(30516) << "very small font size=" << size << endl; _pointSize = qRound(size); GfxRGB rgb; state->getFillRGB(&rgb); _color = toColor(rgb); GfxFont *font = state->getFont(); GString *gname = (font ? font->getName() : 0); QString name = (gname ? gname->getCString() : 0); // kdDebug(30516) << "font: " << name << endl; name = name.section('+', 1, 1).lower(); if ( name.isEmpty() ) name = "##dummy"; // dummy name init(name); }
void WStandardColorMap::discretise(int numberOfBands) { if (!continuous_ || colors_.size() <= 1) return; double val0 = colors_[0].value(); double interval = ( colors_[colors_.size()-1].value() - colors_[0].value() ) / numberOfBands; std::vector<WStandardColorMap::Pair> newColors; for (int i=0; i<numberOfBands; i++) { // color taken corresponds to value in the middle of the band WStandardColorMap::Pair newCol(val0+i*interval, toColor(val0+i*interval + interval/2)); newColors.push_back(newCol); } colors_ = newColors; continuous_ = false; }
static int Image_pixel(lua_State* L){ int argc = lua_gettop(L); ge_Image* dest = selfImage(L, &argc); if(!dest){ return luaL_error(L, "Error: geImage.Pixel(x, y, [color]) must be with a colon"); } if(argc < 2){ return luaL_error(L, "Argument error: geImage.Pixel(x, y, [color] takes at least 2 arguments."); } int x = luaL_checkint(L, 1); int y = luaL_checkint(L, 2); if(x >= 0 && y >= 0 && x < dest->width && y < dest->height){ if(argc == 3){ dest->data[x + y*dest->textureWidth] = *toColor(L, 3); }else{ *pushNewColor(L) = dest->data[x + y*dest->textureWidth]; } } return 1; }
void EvBox::updateEV(int stat) { int ev = poke().EV(stat); m_sliders[stat]->setValue(ev); m_evs[stat]->blockSignals(true); m_evs[stat]->setText(QString::number(ev)); m_evs[stat]->blockSignals(false); /* first the color : red if the stat is hindered by the nature, black if normal, blue if the stat is enhanced */ QColor color; switch (poke().natureBoost(stat)) { case -1: color = Theme::Color("Teambuilder/statHindered"); break; case 1: color = Theme::Color("Teambuilder/statRaised"); break; } m_stats[stat]->setText(toColor(QString::number(poke().stat(stat)), color)); if (poke().gen() <= 2 && stat == SpAttack) { updateEV(SpDefense); } }
static int drawLineScreen(lua_State* L){ int argc = lua_gettop(L); if(argc != 5) return luaL_error(L, "Argument error: geDrawLineScreen(x0, y0, x1, y1, color) must take five arguments."); geDrawLineScreen( luaL_checknumber(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3), luaL_checknumber(L, 4), *toColor(L, 5) ); return 1; }
void FLIRTDemo::processReading(const AbstractReading* _read){ const LaserReading* lread = dynamic_cast<const LaserReading*>(_read); if (lread){ const std::vector<Point2D>& points = lread->getCartesian(); std::vector< double > signal; std::vector< std::vector<double> > smooth; std::vector< std::vector<double> > diff; std::vector< std::vector<unsigned int> > idx; QVector<double> xpoints(points.size()); for(int i = 0; i < xpoints.size(); i++) xpoints[i] = (double)i; m_chooser->getCurrentDetector()->detect(*lread, m_points, signal, smooth, diff, idx); const std::vector<QColor>& colors = m_plotWidget->getColors(); for(unsigned int i = 0; i < smooth.size(); i++){ QVector<double> smoothV = QVector<double>::fromStdVector(smooth[i]); QVector<double> diffV = QVector<double>::fromStdVector(diff[i]); m_plotWidget->setSmoothData(xpoints, smoothV, i); m_plotWidget->setDifferentialData(xpoints, diffV, i); QVector<double> smoothMarker(idx[i].size()); QVector<double> diffMarker(idx[i].size()); QVector<double> indexes(idx[i].size()); for(unsigned int j = 0; j < idx[i].size(); j++){ smoothMarker[j] = smooth[i][idx[i][j]]; diffMarker[j] = diff[i][idx[i][j]]; indexes[j] = idx[i][j]; } m_plotWidget->setSmoothMarker(indexes, smoothMarker, i); m_plotWidget->setDifferentialMarker(indexes, diffMarker, i); } m_interestPoints.resize(m_points.size()); m_scales.resize(m_points.size()); m_colors.resize(m_points.size(),Color(1.,1.,1.,1.)); for(unsigned int i = 0; i < m_points.size(); i++){ m_points[i]->setDescriptor(m_chooserD->getCurrentDescriptor()->describe(*m_points[i], *lread)); m_interestPoints[i] = &(m_points[i]->getPosition()); m_scales[i] = m_points[i]->getScale(); m_colors[i] = toColor(colors[m_points[i]->getScaleLevel()]); } if(!m_laserRenderer){ m_interestRenderer = new InterestPointRenderer(&m_interestPoints, &m_scales); m_laserRenderer = new LaserReadingRenderer(&lread->getCartesian()); m_supportRenderer = new LaserReadingRenderer(NULL); m_polarRenderer = new PolarGridRenderer(NULL, NULL, NULL); m_supportRenderer->setSize(m_laserRenderer->getSize() + 0.01f); m_descriptorRendererWidget->addRenderer(m_polarRenderer); m_descriptorRendererWidget->addRenderer(m_laserRenderer); m_rendererWidget->addRenderer(m_laserRenderer); m_rendererWidget->addRenderer(m_supportRenderer); m_rendererWidget->addRenderer(m_interestRenderer); m_laserRenderer->setLaserPose(&lread->getLaserPose()); }else { m_laserRenderer->setLaserPoints(&points); m_interestRenderer->setInterestPoints(&m_interestPoints, &m_scales); m_laserRenderer->setLaserPose(&lread->getLaserPose()); } m_polarRenderer->setGrid(NULL, NULL, NULL); m_polarRenderer->setPosition(NULL); m_supportRenderer->setLaserPoints(NULL); m_interestRenderer->setColors(m_colors); m_rendererWidget->setLaserPose(lread->getLaserPose().x, lread->getLaserPose().y); m_reading = lread; } m_plotWidget->replot(); m_rendererWidget->updateGL(); m_descriptorRendererWidget->updateGL(); }
Color RenderThemeNix::platformInactiveSelectionBackgroundColor() const { return toColor(themeEngine()->inactiveSelectionBackgroundColor()); }
void CSSStyleSelector::applySVGRule(int id, DOM::CSSValueImpl* value) { CSSPrimitiveValueImpl* primitiveValue = 0; if (value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValueImpl*>(value); SVGRenderStyle* svgstyle = style->accessSVGStyle(); unsigned short valueType = value->cssValueType(); bool isInherit = parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT; bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT); // What follows is a list that maps the CSS properties into their // corresponding front-end RenderStyle values. Shorthands(e.g. border, // background) occur in this list as well and are only hit when mapping // "inherit" or "initial" into front-end values. switch (id) { // ident only properties case CSS_PROP_ALIGNMENT_BASELINE: { HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setAlignmentBaseline(AB_AUTO); break; case CSS_VAL_BASELINE: svgstyle->setAlignmentBaseline(AB_BASELINE); break; case CSS_VAL_BEFORE_EDGE: svgstyle->setAlignmentBaseline(AB_BEFORE_EDGE); break; case CSS_VAL_TEXT_BEFORE_EDGE: svgstyle->setAlignmentBaseline(AB_TEXT_BEFORE_EDGE); break; case CSS_VAL_MIDDLE: svgstyle->setAlignmentBaseline(AB_MIDDLE); break; case CSS_VAL_CENTRAL: svgstyle->setAlignmentBaseline(AB_CENTRAL); break; case CSS_VAL_AFTER_EDGE: svgstyle->setAlignmentBaseline(AB_AFTER_EDGE); break; case CSS_VAL_TEXT_AFTER_EDGE: svgstyle->setAlignmentBaseline(AB_TEXT_AFTER_EDGE); break; case CSS_VAL_IDEOGRAPHIC: svgstyle->setAlignmentBaseline(AB_IDEOGRAPHIC); break; case CSS_VAL_ALPHABETIC: svgstyle->setAlignmentBaseline(AB_ALPHABETIC); break; case CSS_VAL_HANGING: svgstyle->setAlignmentBaseline(AB_HANGING); break; case CSS_VAL_MATHEMATICAL: svgstyle->setAlignmentBaseline(AB_MATHEMATICAL); break; default: break; } break; } case CSS_PROP_BASELINE_SHIFT: { HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift); if (!primitiveValue) break; if (primitiveValue->getIdent()) { switch (primitiveValue->getIdent()) { case CSS_VAL_BASELINE: svgstyle->setBaselineShift(BS_BASELINE); break; case CSS_VAL_SUB: svgstyle->setBaselineShift(BS_SUB); break; case CSS_VAL_SUPER: svgstyle->setBaselineShift(BS_SUPER); break; default: break; } } else { svgstyle->setBaselineShift(BS_LENGTH); svgstyle->setBaselineShiftValue(primitiveValue); } break; } case CSS_PROP_KERNING: { if (isInherit) { HANDLE_INHERIT_COND(CSS_PROP_KERNING, kerning, Kerning) return; } else if (isInitial) { HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_KERNING, Kerning, Kerning) return; } svgstyle->setKerning(primitiveValue); break; } case CSS_PROP_POINTER_EVENTS: { HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_NONE: svgstyle->setPointerEvents(PE_NONE); break; case CSS_VAL_STROKE: svgstyle->setPointerEvents(PE_STROKE); break; case CSS_VAL_FILL: svgstyle->setPointerEvents(PE_FILL); break; case CSS_VAL_PAINTED: svgstyle->setPointerEvents(PE_PAINTED); break; case CSS_VAL_VISIBLE: svgstyle->setPointerEvents(PE_VISIBLE); break; case CSS_VAL_VISIBLESTROKE: svgstyle->setPointerEvents(PE_VISIBLE_STROKE); break; case CSS_VAL_VISIBLEFILL: svgstyle->setPointerEvents(PE_VISIBLE_FILL); break; case CSS_VAL_VISIBLEPAINTED: svgstyle->setPointerEvents(PE_VISIBLE_PAINTED); break; case CSS_VAL_ALL: svgstyle->setPointerEvents(PE_ALL); break; default: break; } break; } case CSS_PROP_DOMINANT_BASELINE: { HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setDominantBaseline(DB_AUTO); break; case CSS_VAL_USE_SCRIPT: svgstyle->setDominantBaseline(DB_USE_SCRIPT); break; case CSS_VAL_NO_CHANGE: svgstyle->setDominantBaseline(DB_NO_CHANGE); break; case CSS_VAL_RESET_SIZE: svgstyle->setDominantBaseline(DB_RESET_SIZE); break; case CSS_VAL_IDEOGRAPHIC: svgstyle->setDominantBaseline(DB_IDEOGRAPHIC); break; case CSS_VAL_ALPHABETIC: svgstyle->setDominantBaseline(DB_ALPHABETIC); break; case CSS_VAL_HANGING: svgstyle->setDominantBaseline(DB_HANGING); break; case CSS_VAL_MATHEMATICAL: svgstyle->setDominantBaseline(DB_MATHEMATICAL); break; case CSS_VAL_CENTRAL: svgstyle->setDominantBaseline(DB_CENTRAL); break; case CSS_VAL_MIDDLE: svgstyle->setDominantBaseline(DB_MIDDLE); break; case CSS_VAL_TEXT_AFTER_EDGE: svgstyle->setDominantBaseline(DB_TEXT_AFTER_EDGE); break; case CSS_VAL_TEXT_BEFORE_EDGE: svgstyle->setDominantBaseline(DB_TEXT_BEFORE_EDGE); break; default: break; } break; } case CSS_PROP_COLOR_INTERPOLATION: { HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation); svgstyle->setColorInterpolation(colorInterpolationForValue(primitiveValue)); break; } case CSS_PROP_COLOR_INTERPOLATION_FILTERS: { HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters) svgstyle->setColorInterpolationFilters(colorInterpolationForValue(primitiveValue)); break; } case CSS_PROP_COLOR_RENDERING: { HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setColorRendering(CR_AUTO); break; case CSS_VAL_OPTIMIZESPEED: svgstyle->setColorRendering(CR_OPTIMIZESPEED); break; case CSS_VAL_OPTIMIZEQUALITY: svgstyle->setColorRendering(CR_OPTIMIZEQUALITY); break; default: break; } break; } case CSS_PROP_CLIP_RULE: { HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule) if (primitiveValue) svgstyle->setClipRule((primitiveValue->getIdent() == CSS_VAL_NONZERO) ? RULE_NONZERO : RULE_EVENODD); break; } case CSS_PROP_FILL_RULE: { HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule) if (primitiveValue) svgstyle->setFillRule((primitiveValue->getIdent() == CSS_VAL_NONZERO) ? RULE_NONZERO : RULE_EVENODD); break; } case CSS_PROP_STROKE_LINEJOIN: { HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_MITER: svgstyle->setJoinStyle(khtml::MiterJoin); break; case CSS_VAL_ROUND: svgstyle->setJoinStyle(khtml::RoundJoin); break; case CSS_VAL_BEVEL: svgstyle->setJoinStyle(khtml::BevelJoin); break; default: break; } break; } case CSS_PROP_IMAGE_RENDERING: { HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setImageRendering(IR_AUTO); break; case CSS_VAL_OPTIMIZESPEED: svgstyle->setImageRendering(IR_OPTIMIZESPEED); break; case CSS_VAL_OPTIMIZEQUALITY: svgstyle->setImageRendering(IR_OPTIMIZEQUALITY); break; default: break; } break; } case CSS_PROP_SHAPE_RENDERING: { HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setShapeRendering(SR_AUTO); break; case CSS_VAL_OPTIMIZESPEED: svgstyle->setShapeRendering(SR_OPTIMIZESPEED); break; case CSS_VAL_CRISPEDGES: svgstyle->setShapeRendering(SR_CRISPEDGES); break; case CSS_VAL_GEOMETRICPRECISION: svgstyle->setShapeRendering(SR_GEOMETRICPRECISION); break; default: break; } break; } case CSS_PROP_TEXT_RENDERING: { HANDLE_INHERIT_AND_INITIAL(textRendering, TextRendering) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_AUTO: svgstyle->setTextRendering(TR_AUTO); break; case CSS_VAL_OPTIMIZESPEED: svgstyle->setTextRendering(TR_OPTIMIZESPEED); break; case CSS_VAL_OPTIMIZELEGIBILITY: svgstyle->setTextRendering(TR_OPTIMIZELEGIBILITY); break; case CSS_VAL_GEOMETRICPRECISION: svgstyle->setTextRendering(TR_GEOMETRICPRECISION); break; default: break; } break; } // end of ident only properties case CSS_PROP_FILL: { HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint) if (SVGPaintImpl* paint = toPaint(value)) svgstyle->setFillPaint(paint); break; } case CSS_PROP_STROKE: { HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint) if (SVGPaintImpl* paint = toPaint(value)) svgstyle->setStrokePaint(paint); break; } case CSS_PROP_STROKE_WIDTH: { HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth) if (!primitiveValue) return; svgstyle->setStrokeWidth(primitiveValue); break; } case CSS_PROP_STROKE_DASHARRAY: { HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray) if (!primitiveValue && value && value->isValueList()) { CSSValueListImpl* dashes = static_cast<CSSValueListImpl*>(value); svgstyle->setStrokeDashArray(dashes); } break; } case CSS_PROP_STROKE_DASHOFFSET: { HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset) if (!primitiveValue) return; svgstyle->setStrokeDashOffset(primitiveValue); break; } case CSS_PROP_FILL_OPACITY: { HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity) if (!primitiveValue) return; float f = 0.0f; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_PERCENTAGE) f = primitiveValue->floatValue() / 100.0f; else if (type == CSSPrimitiveValue::CSS_NUMBER) f = primitiveValue->floatValue(); else return; svgstyle->setFillOpacity(f); break; } case CSS_PROP_STROKE_OPACITY: { HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity) if (!primitiveValue) return; float f = 0.0f; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_PERCENTAGE) f = primitiveValue->floatValue() / 100.0f; else if (type == CSSPrimitiveValue::CSS_NUMBER) f = primitiveValue->floatValue(); else return; svgstyle->setStrokeOpacity(f); break; } case CSS_PROP_STOP_OPACITY: { HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity) if (!primitiveValue) return; float f = 0.0f; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_PERCENTAGE) f = primitiveValue->floatValue() / 100.0f; else if (type == CSSPrimitiveValue::CSS_NUMBER) f = primitiveValue->floatValue(); else return; svgstyle->setStopOpacity(f); break; } case CSS_PROP_MARKER_START: { HANDLE_INHERIT_AND_INITIAL(startMarker, StartMarker) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setStartMarker(s); break; } case CSS_PROP_MARKER_MID: { HANDLE_INHERIT_AND_INITIAL(midMarker, MidMarker) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setMidMarker(s); break; } case CSS_PROP_MARKER_END: { HANDLE_INHERIT_AND_INITIAL(endMarker, EndMarker) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setEndMarker(s); break; } case CSS_PROP_STROKE_LINECAP: { HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle) if (!primitiveValue) break; switch (primitiveValue->getIdent()) { case CSS_VAL_BUTT: svgstyle->setCapStyle(ButtCap); break; case CSS_VAL_ROUND: svgstyle->setCapStyle(RoundCap); break; case CSS_VAL_SQUARE: svgstyle->setCapStyle(SquareCap); break; default: break; } break; } case CSS_PROP_STROKE_MITERLIMIT: { HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit) if (!primitiveValue) return; float f = 0.0f; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_NUMBER) f = primitiveValue->floatValue(); else return; svgstyle->setStrokeMiterLimit(f); break; } case CSS_PROP_FILTER: { HANDLE_INHERIT_AND_INITIAL(filter, Filter) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setFilter(s); break; } case CSS_PROP_MASK: { HANDLE_INHERIT_AND_INITIAL(maskElement, MaskElement) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setMaskElement(s); break; } case CSS_PROP_CLIP_PATH: { HANDLE_INHERIT_AND_INITIAL(clipPath, ClipPath) if (!primitiveValue) return; String s; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_URI) s = primitiveValue->getStringValue(); else return; svgstyle->setClipPath(s); break; } case CSS_PROP_TEXT_ANCHOR: { HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor) if (primitiveValue) { switch (primitiveValue->getIdent()) { case CSS_VAL_START: svgstyle->setTextAnchor(TA_START); break; case CSS_VAL_MIDDLE: svgstyle->setTextAnchor(TA_MIDDLE); break; case CSS_VAL_END: svgstyle->setTextAnchor(TA_END); break; } } break; } case CSS_PROP_WRITING_MODE: { HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode) if (!primitiveValue) return; switch (primitiveValue->getIdent()) { case CSS_VAL_LR_TB: svgstyle->setWritingMode(WM_LRTB); break; case CSS_VAL_LR: svgstyle->setWritingMode(WM_LR); break; case CSS_VAL_RL_TB: svgstyle->setWritingMode(WM_RLTB); break; case CSS_VAL_RL: svgstyle->setWritingMode(WM_RL); break; case CSS_VAL_TB_RL: svgstyle->setWritingMode(WM_TBRL); break; case CSS_VAL_TB: svgstyle->setWritingMode(WM_TB); break; default: break; } break; } case CSS_PROP_STOP_COLOR: { HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor); SVGColorImpl* c = toColor(value); if (!c) break; QColor col; if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR) col = style->color(); else col = c->color(); svgstyle->setStopColor(col); break; } case CSS_PROP_LIGHTING_COLOR: { HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor); SVGColorImpl* c = toColor(value); if (!c) break; QColor col; if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR) col = style->color(); else col = c->color(); svgstyle->setLightingColor(col); break; } case CSS_PROP_FLOOD_OPACITY: { HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity) if (!primitiveValue) return; float f = 0.0f; int type = primitiveValue->primitiveType(); if (type == CSSPrimitiveValue::CSS_PERCENTAGE) f = primitiveValue->floatValue() / 100.0f; else if (type == CSSPrimitiveValue::CSS_NUMBER) f = primitiveValue->floatValue(); else return; svgstyle->setFloodOpacity(f); break; } case CSS_PROP_FLOOD_COLOR: { QColor col; if (isInitial) col = SVGRenderStyle::initialFloodColor(); else { SVGColorImpl* c = toColor(value); if (!c) break; if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR) col = style->color(); else col = c->color(); } svgstyle->setFloodColor(col); break; } case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL: { HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal) if (!primitiveValue) return; if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) { int orientation = angleToGlyphOrientation(primitiveValue->floatValue()); ASSERT(orientation != -1); svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation); } break; } case CSS_PROP_GLYPH_ORIENTATION_VERTICAL: { HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical) if (!primitiveValue) return; if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) { int orientation = angleToGlyphOrientation(primitiveValue->floatValue()); ASSERT(orientation != -1); svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation); } else if (primitiveValue->getIdent() == CSS_VAL_AUTO) svgstyle->setGlyphOrientationVertical(GO_AUTO); break; } case CSS_PROP_ENABLE_BACKGROUND: // Silently ignoring this property for now // http://bugs.webkit.org/show_bug.cgi?id=6022 break; default: // If you crash here, it's because you added a css property and are not handling it // in either this switch statement or the one in CSSStyleSelector::applyProperty kWarning() << "unimplemented property" << id << getPropertyName(id).string(); return; }
Color RenderThemeNix::platformActiveSelectionForegroundColor() const { return toColor(themeEngine()->activeSelectionForegroundColor()); }
static int Image_create(lua_State *L){ int argc = lua_gettop(L); if (argc != 2 && argc != 3){ return luaL_error(L, "Argument error: geImage.Create(width, height, [background_color]) takes two or three arguments."); } ge_Image* img = geCreateSurface(luaL_checkint(L, 1), luaL_checkint(L, 2), argc==3 ? *toColor(L, 3) : 0x0); *pushNewImage(L) = img; return 1; }
Color RenderThemeNix::platformInactiveListBoxSelectionForegroundColor() const { return toColor(themeEngine()->inactiveListBoxSelectionForegroundColor()); }
Color RenderThemeNix::platformActiveListBoxSelectionBackgroundColor() const { return toColor(themeEngine()->activeListBoxSelectionBackgroundColor()); }
SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* json) { SkeletonData* skeletonData; Json *root, *bones; int i, ii, iii, boneCount; Json* slots; Json* skinsMap; Json* animations; FREE(self->error); CONST_CAST(char*, self->error) = 0; root = Json_create(json); if (!root) { _SkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError()); return 0; } skeletonData = SkeletonData_create(); bones = Json_getItem(root, "bones"); boneCount = Json_getSize(bones); skeletonData->bones = MALLOC(BoneData*, boneCount); for (i = 0; i < boneCount; ++i) { Json* boneMap = Json_getItemAt(bones, i); BoneData* boneData; const char* boneName = Json_getString(boneMap, "name", 0); BoneData* parent = 0; const char* parentName = Json_getString(boneMap, "parent", 0); if (parentName) { parent = SkeletonData_findBone(skeletonData, parentName); if (!parent) { SkeletonData_dispose(skeletonData); _SkeletonJson_setError(self, root, "Parent bone not found: ", parentName); return 0; } } boneData = BoneData_create(boneName, parent); boneData->length = Json_getFloat(boneMap, "length", 0) * self->scale; boneData->x = Json_getFloat(boneMap, "x", 0) * self->scale; boneData->y = Json_getFloat(boneMap, "y", 0) * self->scale; boneData->rotation = Json_getFloat(boneMap, "rotation", 0); boneData->scaleX = Json_getFloat(boneMap, "scaleX", 1); boneData->scaleY = Json_getFloat(boneMap, "scaleY", 1); skeletonData->bones[i] = boneData; skeletonData->boneCount++; } slots = Json_getItem(root, "slots"); if (slots) { int slotCount = Json_getSize(slots); skeletonData->slots = MALLOC(SlotData*, slotCount); for (i = 0; i < slotCount; ++i) { SlotData* slotData; const char* color; Json *attachmentItem; Json* slotMap = Json_getItemAt(slots, i); const char* slotName = Json_getString(slotMap, "name", 0); const char* boneName = Json_getString(slotMap, "bone", 0); BoneData* boneData = SkeletonData_findBone(skeletonData, boneName); if (!boneData) { SkeletonData_dispose(skeletonData); _SkeletonJson_setError(self, root, "Slot bone not found: ", boneName); return 0; } slotData = SlotData_create(slotName, boneData); color = Json_getString(slotMap, "color", 0); if (color) { slotData->r = toColor(color, 0); slotData->g = toColor(color, 1); slotData->b = toColor(color, 2); slotData->a = toColor(color, 3); } attachmentItem = Json_getItem(slotMap, "attachment"); if (attachmentItem) SlotData_setAttachmentName(slotData, attachmentItem->valuestring); skeletonData->slots[i] = slotData; skeletonData->slotCount++; } } skinsMap = Json_getItem(root, "skins"); if (skinsMap) { int skinCount = Json_getSize(skinsMap); skeletonData->skins = MALLOC(Skin*, skinCount); for (i = 0; i < skinCount; ++i) { Json* slotMap = Json_getItemAt(skinsMap, i); const char* skinName = slotMap->name; Skin *skin = Skin_create(skinName); int slotNameCount; skeletonData->skins[i] = skin; skeletonData->skinCount++; if (kdStrcmp(skinName, "default") == 0) skeletonData->defaultSkin = skin; slotNameCount = Json_getSize(slotMap); for (ii = 0; ii < slotNameCount; ++ii) { Json* attachmentsMap = Json_getItemAt(slotMap, ii); const char* slotName = attachmentsMap->name; int slotIndex = SkeletonData_findSlotIndex(skeletonData, slotName); int attachmentCount = Json_getSize(attachmentsMap); for (iii = 0; iii < attachmentCount; ++iii) { Attachment* attachment; Json* attachmentMap = Json_getItemAt(attachmentsMap, iii); const char* skinAttachmentName = attachmentMap->name; const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); const char* typeString = Json_getString(attachmentMap, "type", "region"); AttachmentType type; if (kdStrcmp(typeString, "region") == 0) type = ATTACHMENT_REGION; else if (kdStrcmp(typeString, "regionSequence") == 0) type = ATTACHMENT_REGION_SEQUENCE; else { SkeletonData_dispose(skeletonData); _SkeletonJson_setError(self, root, "Unknown attachment type: ", typeString); return 0; } attachment = AttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName); if (!attachment) { if (self->attachmentLoader->error1) { SkeletonData_dispose(skeletonData); _SkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2); return 0; } continue; } if (attachment->type == ATTACHMENT_REGION || attachment->type == ATTACHMENT_REGION_SEQUENCE) { RegionAttachment* regionAttachment = (RegionAttachment*)attachment; regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale; regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale; regionAttachment->scaleX = Json_getFloat(attachmentMap, "scaleX", 1); regionAttachment->scaleY = Json_getFloat(attachmentMap, "scaleY", 1); regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0); regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; RegionAttachment_updateOffset(regionAttachment); } Skin_addAttachment(skin, slotIndex, skinAttachmentName, attachment); } } } } animations = Json_getItem(root, "animations"); if (animations) { int animationCount = Json_getSize(animations); skeletonData->animations = MALLOC(Animation*, animationCount); for (i = 0; i < animationCount; ++i) { Json* animationMap = Json_getItemAt(animations, i); _SkeletonJson_readAnimation(self, animationMap, skeletonData); } } Json_dispose(root); return skeletonData; }
Color RenderThemeNix::platformInactiveTextSearchHighlightColor() const { return toColor(themeEngine()->inactiveTextSearchHighlightColor()); }
Painter Painter::fromXML(const QDomElement& e, QString filename) { Painter FP; if (e.hasAttribute("zoomUnder") || e.hasAttribute("zoomUpper")) FP.zoomBoundary(e.attribute("zoomUnder","0").toDouble(),e.attribute("zoomUpper","10e6").toDouble()); if (e.hasAttribute("foregroundColor")) { FP.foreground( toColor(e.attribute("foregroundColor")),e.attribute("foregroundScale").toDouble(),e.attribute("foregroundOffset").toDouble()); if (e.hasAttribute("foregroundDashDown")) FP.foregroundDash(e.attribute("foregroundDashDown").toDouble(),e.attribute("foregroundDashUp").toDouble()); } if (e.hasAttribute("fillWithIcon")) FP.foregroundUseIcon(e.attribute("fillWithIcon") == "yes"); if (e.hasAttribute("backgroundColor")) FP.background( toColor(e.attribute("backgroundColor")),e.attribute("backgroundScale").toDouble(),e.attribute("backgroundOffset").toDouble()); if (e.attribute("interior") == "yes") FP.BackgroundInterior = true; if (e.attribute("exterior") == "yes") FP.BackgroundExterior = true; if (e.hasAttribute("touchupColor")) { FP.touchup( toColor(e.attribute("touchupColor")),e.attribute("touchupScale").toDouble(),e.attribute("touchupOffset").toDouble()); if (e.hasAttribute("touchupDashDown")) FP.touchupDash(e.attribute("touchupDashDown").toDouble(),e.attribute("touchupDashUp").toDouble()); } if (e.hasAttribute("fillColor")) FP.foregroundFill(toColor(e.attribute("fillColor"))); if (e.hasAttribute("icon")) { QString iconFilename = e.attribute("icon"); if (!QFileInfo(iconFilename).isAbsolute()) iconFilename = QFileInfo(filename).absolutePath().append("/").append(iconFilename); FP.setIcon(iconFilename,e.attribute("iconScale", "0.0").toDouble(),e.attribute("iconOffset", "0.0").toDouble()); } if (e.attribute("drawTrafficDirectionMarks") == "yes") FP.drawTrafficDirectionMarks(true); if (e.hasAttribute("trafficDirectionMarksColor")) FP.TrafficDirectionMarksColor = toColor((e.attribute("trafficDirectionMarksColor"))); if (e.hasAttribute("labelColor")) { FP.label( toColor(e.attribute("labelColor")),e.attribute("labelScale").toDouble(),e.attribute("labelOffset").toDouble()); FP.setLabelFont(e.attribute("labelFont")); FP.labelTag(e.attribute("labelTag")); if (e.hasAttribute("labelHalo")) FP.labelHalo((e.attribute("labelHalo") == "yes")); if (e.hasAttribute("labelArea")) FP.labelArea((e.attribute("labelArea") == "yes")); if (e.hasAttribute("labelBackgroundColor")) FP.labelBackground(toColor(e.attribute("labelBackgroundColor"))); if (e.hasAttribute("labelBackgroundTag")) FP.labelBackgroundTag(e.attribute("labelBackgroundTag")); } QDomNode n = e.firstChild(); QList<QPair<QString,QString> > Pairs; while (!n.isNull()) { if (n.isElement()) { QDomElement t = n.toElement(); if (t.tagName() == "selector") { if (!t.attribute("key").isEmpty()) Pairs.push_back(qMakePair(t.attribute("key"),t.attribute("value"))); else { FP.setSelector(t.attribute("expr")); return FP; } } } n = n.nextSibling(); } if (Pairs.size() == 1) FP.setSelector(Pairs[0].first+"="+Pairs[0].second); else if (Pairs.size()) { bool Same = true; for (int i=1; i<Pairs.size(); ++i) if (Pairs[0].first != Pairs[i].first) Same = false; if (Same) { QStringList Options; for (int i=0; i<Pairs.size(); ++i) Options.push_back(Pairs[i].second); FP.setSelector("["+ Pairs[0].first +"] isoneof ("+ Options.join(",") + ")"); } else { QStringList Options; for (int i=0; i<Pairs.size(); ++i) Options.push_back(Pairs[i].first+"="+Pairs[i].second); FP.setSelector(Options.join(" or ")); } } return FP; }
Color RenderThemeNix::platformTapHighlightColor() const { return toColor(themeEngine()->tapHighlightColor()); }
Color RenderThemeNix::platformFocusRingColor() const { return toColor(themeEngine()->focusRingColor()); }
static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, SkeletonData *skeletonData) { Animation* animation; Json* bones = Json_getItem(root, "bones"); int boneCount = bones ? Json_getSize(bones) : 0; Json* slots = Json_getItem(root, "slots"); int slotCount = slots ? Json_getSize(slots) : 0; int timelineCount = 0; int i, ii, iii; for (i = 0; i < boneCount; ++i) timelineCount += Json_getSize(Json_getItemAt(bones, i)); for (i = 0; i < slotCount; ++i) timelineCount += Json_getSize(Json_getItemAt(slots, i)); animation = Animation_create(root->name, timelineCount); animation->timelineCount = 0; skeletonData->animations[skeletonData->animationCount] = animation; skeletonData->animationCount++; for (i = 0; i < boneCount; ++i) { timelineCount = 0; Json* boneMap = Json_getItemAt(bones, i); const char* boneName = boneMap->name; int boneIndex = SkeletonData_findBoneIndex(skeletonData, boneName); if (boneIndex == -1) { Animation_dispose(animation); _SkeletonJson_setError(self, root, "Bone not found: ", boneName); return 0; } timelineCount = Json_getSize(boneMap); for (ii = 0; ii < timelineCount; ++ii) { float duration; Json* timelineArray = Json_getItemAt(boneMap, ii); int frameCount = Json_getSize(timelineArray); const char* timelineType = timelineArray->name; if (kdStrcmp(timelineType, "rotate") == 0) { RotateTimeline *timeline = RotateTimeline_create(frameCount); timeline->boneIndex = boneIndex; for (iii = 0; iii < frameCount; ++iii) { Json* frame = Json_getItemAt(timelineArray, iii); RotateTimeline_setFrame(timeline, iii, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0)); readCurve(SUPER(timeline), iii, frame); } animation->timelines[animation->timelineCount++] = (Timeline*)timeline; duration = timeline->frames[frameCount * 2 - 2]; if (duration > animation->duration) animation->duration = duration; } else { int isScale = kdStrcmp(timelineType, "scale") == 0; if (isScale || kdStrcmp(timelineType, "translate") == 0) { float scale = isScale ? 1 : self->scale; TranslateTimeline *timeline = isScale ? ScaleTimeline_create(frameCount) : TranslateTimeline_create(frameCount); timeline->boneIndex = boneIndex; for (iii = 0; iii < frameCount; ++iii) { Json* frame = Json_getItemAt(timelineArray, iii); TranslateTimeline_setFrame(timeline, iii, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale, Json_getFloat(frame, "y", 0) * scale); readCurve(SUPER(timeline), iii, frame); } animation->timelines[animation->timelineCount++] = (Timeline*)timeline; duration = timeline->frames[frameCount * 3 - 3]; if (duration > animation->duration) animation->duration = duration; } else { Animation_dispose(animation); _SkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineType); return 0; } } } } for (i = 0; i < slotCount; ++i) { timelineCount = 0; Json* slotMap = Json_getItemAt(slots, i); const char* slotName = slotMap->name; int slotIndex = SkeletonData_findSlotIndex(skeletonData, slotName); if (slotIndex == -1) { Animation_dispose(animation); _SkeletonJson_setError(self, root, "Slot not found: ", slotName); return 0; } timelineCount = Json_getSize(slotMap); for (ii = 0; ii < timelineCount; ++ii) { float duration; Json* timelineArray = Json_getItemAt(slotMap, ii); int frameCount = Json_getSize(timelineArray); const char* timelineType = timelineArray->name; if (kdStrcmp(timelineType, "color") == 0) { ColorTimeline *timeline = ColorTimeline_create(frameCount); timeline->slotIndex = slotIndex; for (iii = 0; iii < frameCount; ++iii) { Json* frame = Json_getItemAt(timelineArray, iii); const char* s = Json_getString(frame, "color", 0); ColorTimeline_setFrame(timeline, iii, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), toColor(s, 3)); readCurve(SUPER(timeline), iii, frame); } animation->timelines[animation->timelineCount++] = (Timeline*)timeline; duration = timeline->frames[frameCount * 5 - 5]; if (duration > animation->duration) animation->duration = duration; } else if (kdStrcmp(timelineType, "attachment") == 0) { AttachmentTimeline *timeline = AttachmentTimeline_create(frameCount); timeline->slotIndex = slotIndex; for (iii = 0; iii < frameCount; ++iii) { Json* frame = Json_getItemAt(timelineArray, iii); Json* name = Json_getItem(frame, "name"); AttachmentTimeline_setFrame(timeline, iii, Json_getFloat(frame, "time", 0), name->type == Json_NULL ? 0 : name->valuestring); } animation->timelines[animation->timelineCount++] = (Timeline*)timeline; duration = timeline->frames[frameCount - 1]; if (duration > animation->duration) animation->duration = duration; } else { Animation_dispose(animation); _SkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineType); return 0; } } } return animation; }
/// <summary> /// Color 型に変換します。 /// </summary> /// <param name="alpha"> /// アルファ値 [0, 255] /// </param> /// <returns> /// 変換した値 /// </returns> Color toColor(const uint32 alpha) const noexcept { return toColor().setA(alpha); }