MCPcopy Create free account
hub / github.com/MapServer/MapServer / agg2RenderPolygonHatched

Function agg2RenderPolygonHatched

mapagg.cpp:922–967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920}
921
922int agg2RenderPolygonHatched(imageObj *img, shapeObj *poly, double spacing, double width, double angle, colorObj *color) {
923
924 msComputeBounds(poly);
925
926 /*
927 * we create a hatch pattern that is the size of the shapeObj's bounds, expanded by the width
928 * of the stroke we want to apply to the lines to account for end-caps artifacts
929 */
930 int pw=(int)(poly->bounds.maxx-poly->bounds.minx+width*2)+1;
931 int ph=(int)(poly->bounds.maxy-poly->bounds.miny+width*2)+1;
932
933 //create a rectangular hatch of size pw,ph starting at 0,0
934 //the created hatch is of the size of the shape's bounding box
935 mapserver::path_storage hatch = createHatch(pw,ph,angle,spacing);
936
937 //translate the hatch so it overlaps the current shape
938 hatch.transform(mapserver::trans_affine_translation(poly->bounds.minx-width,poly->bounds.miny-width));
939
940
941
942 //render the hatch clipped by the shape
943 mapserver::conv_stroke <mapserver::path_storage > stroke(hatch);
944 stroke.width(width);
945 stroke.line_cap(mapserver::butt_cap);
946
947 polygon_adaptor polygons(poly);
948
949 AGG2Renderer *r = AGG_RENDERER(img);
950
951 mapserver::rasterizer_scanline_aa<> ras1,ras2;
952 mapserver::scanline_storage_aa8 storage;
953 mapserver::scanline_storage_aa8 storage1;
954 mapserver::scanline_storage_aa8 storage2;
955 mapserver::scanline_p8 sl1,sl2;
956 ras1.filling_rule(mapserver::fill_non_zero);
957 ras1.add_path(stroke);
958 mapserver::render_scanlines(ras1, r->sl_line, storage1);
959 ras2.filling_rule(mapserver::fill_even_odd);
960 ras2.add_path(polygons);
961 mapserver::render_scanlines(ras2,r->sl_poly,storage2);
962 mapserver::sbool_combine_shapes_aa(mapserver::sbool_and, storage1, storage2, sl1, sl2, r->sl_line, storage);
963 r->m_renderer_scanline.color(aggColor(color));
964 mapserver::render_scanlines ( storage, r->sl_poly, r->m_renderer_scanline );
965 return MS_SUCCESS;
966
967}
968
969int msHatchPolygon(imageObj *img, shapeObj *poly, double spacing, double width, double angle, colorObj *color) {
970 assert(MS_RENDERER_PLUGIN(img->format));

Callers

nothing calls this directly

Calls 11

msComputeBoundsFunction · 0.85
createHatchFunction · 0.85
render_scanlinesFunction · 0.85
sbool_combine_shapes_aaFunction · 0.85
transformMethod · 0.45
widthMethod · 0.45
line_capMethod · 0.45
filling_ruleMethod · 0.45
add_pathMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected