Exemplo n.º 1
0
		bool paint::apply(const element* parent, render_context& ctx) const
		{
			switch(color_attrib_) {
			case ColorAttrib::NONE:
				// Nothing to do if there is no color.
				return false;
			case ColorAttrib::CURRENT_COLOR: {
				auto cc = ctx.get_current_color();
				ASSERT_LOG(cc != NULL, "Current color specified as color source, but there is no current color value.");
				cairo_set_source_rgb(ctx.cairo(), cc->r(), cc->g(), cc->b());
				return true;
			}
			case ColorAttrib::FUNC_IRI:
				ASSERT_LOG(false, "XXX: todo: lookup FUNC_IRI to get color value");
				return true;
			case ColorAttrib::ICC_COLOR:
				ASSERT_LOG(false, "XXX: todo: ICC_COLOR to get color value");
				return true;
			case ColorAttrib::INHERIT:
				// XXX: Nothing to do?
				return true;
			case ColorAttrib::VALUE:
				double opacity = ctx.opacity_top();
				cairo_set_source_rgba(ctx.cairo(), color_value_.r(), color_value_.g(), color_value_.b(), opacity);
				return true;
			}
			return false;
		}
Exemplo n.º 2
0
			void handle_apply(render_context& ctx) override {
				if(std::abs(cx_) < DBL_EPSILON && std::abs(cy_) < DBL_EPSILON) {
					cairo_rotate(ctx.cairo(), angle_);
				} else {
					cairo_translate(ctx.cairo(), cx_, cy_);
					cairo_rotate(ctx.cairo(), angle_);
					cairo_translate(ctx.cairo(), -cx_, -cy_);
				}
			}
Exemplo n.º 3
0
		void linear_gradient::handle_set_source(render_context& ctx) const
		{
			cairo_pattern_t* pattern = cairo_pattern_create_linear(
				x1_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
				y1_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
				x2_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
				y2_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER));
			apply_stops(ctx, pattern);
			auto status = cairo_pattern_status(pattern);
			ASSERT_LOG(status == CAIRO_STATUS_SUCCESS, "Linear Gradient pattern couldn't be created: " << cairo_status_to_string(status));

			pattern_.reset(pattern, [](cairo_pattern_t* p) { cairo_pattern_destroy(p); });
			apply_transforms(pattern);
			cairo_set_source(ctx.cairo(), pattern);
		}
Exemplo n.º 4
0
		void parse::render(render_context& ctx) const
		{
			cairo_set_source_rgb(ctx.cairo(), 0.0, 0.0, 0.0);
			cairo_set_line_cap(ctx.cairo(), CAIRO_LINE_CAP_BUTT);
			cairo_set_line_join(ctx.cairo(), CAIRO_LINE_JOIN_MITER);
			cairo_set_miter_limit(ctx.cairo(), 4.0);
			cairo_set_fill_rule(ctx.cairo(), CAIRO_FILL_RULE_WINDING);
			cairo_set_line_width(ctx.cairo(), 1.0);
			ctx.fill_color_push(paint_ptr(new paint(0,0,0,255)));
			ctx.stroke_color_push(paint_ptr(new paint()));
			ctx.opacity_push(1.0);
			ctx.letter_spacing_push(0);
			ctx.fa().push_font_size(12);

			for(auto p : svg_data_) {
				p->render(ctx);
			}

			ctx.letter_spacing_pop();
			ctx.opacity_pop();
			ctx.stroke_color_pop();
			ctx.fill_color_pop();
		}
Exemplo n.º 5
0
			void handle_apply(render_context& ctx) override {
				cairo_translate(ctx.cairo(), x_, y_);
			}
Exemplo n.º 6
0
			void handle_apply(render_context& ctx) override {
				cairo_transform(ctx.cairo(), &mat_);
			}
Exemplo n.º 7
0
			void handle_apply(render_context& ctx) override {
				cairo_scale(ctx.cairo(), sx_, sy_);
			}