void GraphAggRenderer::fillRect(Point *ulCorner, Point *lrCorner, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.move_to(ulCorner->x(), ulCorner->y()); ps.line_to(lrCorner->x(), ulCorner->y()); ps.line_to(lrCorner->x(), lrCorner->y()); ps.line_to(ulCorner->x(), lrCorner->y()); ps.line_to(ulCorner->x(), ulCorner->y()); ps.end_poly(); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void GraphAggRenderer::fillPolygon(Point *points, int pointCount, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.move_to(points[0].x(), points[0].y()); for (int i = 1; i < pointCount; ++i) { ps.line_to(points[i].x(), points[i].y()); } ps.end_poly(agg::path_flags_close); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void GraphAggRenderer::fillEllipse(Point *center, float width, float height, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::ellipse e1; e1.init(center->x(), center->y(), width, height, 100); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.concat_path(e1); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void stroke(agg::rgba8 const& s) { path_attributes& attr = cur_attr(); double a = attr.stroke_color.opacity(); attr.stroke_color = s; attr.stroke_color.opacity(a * s.opacity()); attr.stroke_flag = true; }
// Attribute setting functions. void fill(agg::rgba8 const& f) { path_attributes& attr = cur_attr(); double a = attr.fill_color.opacity(); attr.fill_color = f; attr.fill_color.opacity(a * f.opacity()); attr.fill_flag = true; }
//------------------------------------------------------------------------ void path_renderer::fill_gradient(svg_gradient& gradient) { path_attributes& cur = cur_attr(); if (cur.gradient != nullptr) { delete cur.gradient; } cur.gradient = gradient.clone(); }
//------------------------------------------------------------------------ void path_renderer::fill(const rgba8& f) { path_attributes& attr = cur_attr(); int32u alpha = (f.a * attr.fill_color.a ) / 255; attr.fill_color = f; attr.fill_color.a = alpha; attr.fill_flag = true; }
void end_path() { if(attributes_.size() == 0) { throw std::runtime_error("end_path : The path was not begun"); } path_attributes attr = cur_attr(); unsigned idx = attributes_[attributes_.size() - 1].index; attr.index = idx; attributes_[attributes_.size() - 1] = attr; }
//------------------------------------------------------------------------ void path_renderer::end_path() { if(m_attr_storage.size() == 0) { throw exception("end_path : The path was not begun"); } path_attributes attr = cur_attr(); unsigned idx = m_attr_storage[m_attr_storage.size() - 1].index; attr.index = idx; m_attr_storage[m_attr_storage.size() - 1] = attr; pop_attr(); }
void path_renderer::set_gradient_brush_to_path(const char* gr_id) { if(m_all_gradients.size() == 0) return; path_attributes& attr = cur_attr(); unsigned cnt = m_all_gradients.size(); for (unsigned i=0;i<cnt;i++) { if (strcmp(m_all_gradients[i].id_string, gr_id) == 0) { attr.gradient_brush = &m_all_gradients[i]; break; } } }
//------------------------------------------------------------------------ void path_renderer::end_path() { if(m_attr_storage.size() == 0) { gdx_log_error("gdx","end_path : The path was not begun"); } path_attributes& attr = cur_attr(); unsigned idx = m_attr_storage[m_attr_storage.size() - 1].index; attr.index = idx; m_attr_storage[m_attr_storage.size() - 1] = attr; if(attr.gradient) { if (m_attr_storage[m_attr_storage.size() - 1].gradient) { delete m_attr_storage[m_attr_storage.size() - 1].gradient; } m_attr_storage[m_attr_storage.size() - 1].gradient = attr.gradient->clone(); } pop_attr(); }
void line_cap(agg::line_cap_e cap) { cur_attr().line_cap = cap; }
void line_join(agg::line_join_e join) { cur_attr().line_join = join; }
void opacity(double op) { cur_attr().stroke_opacity = op; cur_attr().fill_opacity = op; }
void stroke_opacity(double op) { cur_attr().stroke_opacity = op; }
void fill_opacity(double op) { cur_attr().fill_opacity = op; }
void add_stroke_gradient(mapnik::gradient const& grad) { path_attributes& attr = cur_attr(); attr.stroke_gradient = grad; }
void begin_path() { unsigned idx = source_.start_new_path(); attributes_.add(path_attributes(cur_attr(), idx)); }
void stroke_width(double w) { cur_attr().stroke_width = w; }
bool display() { return cur_attr().display_flag; }
void display(bool flag) { cur_attr().display_flag = flag; }
//------------------------------------------------------------------------ void path_renderer::begin_path() { push_attr(); unsigned idx = m_storage.start_new_path(); m_attr_storage.add(path_attributes(cur_attr(), idx)); }
void visibility(bool flag) { cur_attr().visibility_flag = flag; }
void even_odd(bool flag) { cur_attr().even_odd_flag = flag; }
void miter_limit(double ml) { cur_attr().miter_limit = ml; }
void fill_none() { cur_attr().fill_flag = false; }
agg::trans_affine& transform() { return cur_attr().transform; }
void stroke_none() { cur_attr().stroke_flag = false; }
bool visibility() { return cur_attr().visibility_flag; }
void add_fill_gradient(mapnik::gradient const& grad) { path_attributes& attr = cur_attr(); attr.fill_gradient = grad; }