Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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");
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
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");
}
Exemplo n.º 6
0
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 );
}
Exemplo n.º 7
0
SVGColor::SVGColor(const String& rgbColor)
    : m_colorType(SVG_COLORTYPE_RGBCOLOR)
{
    setRGBColor(rgbColor);
}
Exemplo n.º 8
0
void setDarkBlue(FILE *f) {
	setRGBColor(f, 0, 0, 11.0 / 256);
}
Exemplo n.º 9
0
void setLightBlue(FILE *f) {
	setRGBColor(f, 19. / 256, 51. / 256, 253. / 256);
}
Exemplo n.º 10
0
void setBlue(FILE * f) {
	setRGBColor(f, 0, 0, 1);
}
Exemplo n.º 11
0
void setGreen(FILE * f) {
	setRGBColor(f, 0, 1, 0);
}
Exemplo n.º 12
0
void setRed(FILE * f) {
	setRGBColor(f, 1, 0, 0);
}
Exemplo n.º 13
0
void setWhite(FILE * f) {
	setRGBColor(f, 1, 1, 1);
}
Exemplo n.º 14
0
void setBlack(FILE * f) {
	setRGBColor(f, 0, 0, 0);
}