void SVGPaint::setPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&, ExceptionCode&) { m_paintType = paintType; if (m_paintType == SVG_PAINTTYPE_URI) setUri(uri); else if (m_paintType == SVG_PAINTTYPE_RGBCOLOR) setRGBColor(rgbPaint); }
void drawCircle(FILE * f, int x, int y, float diameter) { setBlack(f); fprintf(f, "%d %d %f 0 360 arc closepath\n", x, y, diameter + 0.5); fprintf(f, "fill\n"); fprintf(f, "stroke\n"); setRGBColor(f, 1, 1, 1); fprintf(f, "%d %d %f 0 360 arc closepath\n", x, y, diameter); fprintf(f, "fill\n"); fprintf(f, "stroke\n"); }
void SVGColor::setColor(unsigned short colorType, const String& rgbColor, const String& iccColor, ExceptionCode& ec) { if (colorType > SVG_COLORTYPE_CURRENTCOLOR) { ec = SVGException::SVG_WRONG_TYPE_ERR; return; } bool requiresRGBColor = false; bool requiresICCColor = false; SVGColorType type = static_cast<SVGColorType>(colorType); switch (type) { case SVG_COLORTYPE_UNKNOWN: // Spec: It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. ec = SVGException::SVG_INVALID_VALUE_ERR; return; case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR: requiresICCColor = true; case SVG_COLORTYPE_RGBCOLOR: requiresRGBColor = true; break; case SVG_COLORTYPE_CURRENTCOLOR: break; } // Spec: If colorType requires an RGBColor, then rgbColor must be a string that matches <color>; otherwise, rgbColor must be null. if (requiresRGBColor && rgbColor.isEmpty()) { ec = SVGException::SVG_INVALID_VALUE_ERR; return; } // Spec: If colorType requires an SVGICCColor, then iccColor must be a string that matches <icccolor>; otherwise, iccColor must be null. if (requiresICCColor && iccColor.isEmpty()) { ec = SVGException::SVG_INVALID_VALUE_ERR; return; } setNeedsStyleRecalc(); m_colorType = type; if (!requiresRGBColor) { ASSERT(!requiresICCColor); m_color = Color(); return; } if (requiresICCColor) setRGBColorICCColor(rgbColor, iccColor, ec); else setRGBColor(rgbColor, ec); }
void SVGColor::setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode& ec) { if (rgbColor.isEmpty() || iccColor.isEmpty()) { ec = SVGException::SVG_INVALID_VALUE_ERR; return; } // FIXME: No support for ICC colors. We're just ignoring it. setRGBColor(rgbColor, ec); if (ec) return; m_colorType = SVG_COLORTYPE_RGBCOLOR_ICCCOLOR; setNeedsStyleRecalc(); }
void fillCircle(FILE * f, int x, int y, float diameter, float r, float g, float b) { if (r + g + b < 1.5) { setWhite(f); } else { setBlack(f); } fprintf(f, "%d %d %f 0 360 arc closepath\n", x, y, diameter + 0.5); fprintf(f, "fill\n"); fprintf(f, "stroke\n"); setRGBColor(f, r, g, b); fprintf(f, "%d %d %f 0 360 arc closepath\n", x, y, diameter); fprintf(f, "fill\n"); fprintf(f, "stroke\n"); }
void LEDStripe::setHSVColor( int i, int h, int s, int v ) { uint8_t r, g, b; HSVtoRGB( h, s, v, r, g, b ); setRGBColor( i, r, g, b ); }
SVGColor::SVGColor(const String& rgbColor) : m_colorType(SVG_COLORTYPE_RGBCOLOR) { setRGBColor(rgbColor); }
void setDarkBlue(FILE *f) { setRGBColor(f, 0, 0, 11.0 / 256); }
void setLightBlue(FILE *f) { setRGBColor(f, 19. / 256, 51. / 256, 253. / 256); }
void setBlue(FILE * f) { setRGBColor(f, 0, 0, 1); }
void setGreen(FILE * f) { setRGBColor(f, 0, 1, 0); }
void setRed(FILE * f) { setRGBColor(f, 1, 0, 0); }
void setWhite(FILE * f) { setRGBColor(f, 1, 1, 1); }
void setBlack(FILE * f) { setRGBColor(f, 0, 0, 0); }