func TestRectangleDrawing(t *testing.T) { if testing.Short() { t.Skip("Skipping lengthier tests during short test run.") } var tests = []StringMap{ { "name": "solidblue", "fill": "blue", "width": "400", "height": "400", }, { "name": "redinsetwithblue", "fill": "blue", "stroke": "red", "stroke-width": "30", "width": "400", "height": "400", }, { "name": "redinsetwithblue2", "fill": "blue", "stroke": "red", "stroke-width": "1", "width": "400", "height": "400", }, { "name": "solidredstrokedgreen", "fill": "red", "width": "100", "height": "100", "x": "50", "y": "50", "stroke": "green", "stroke-width": "15", }, } for _, tt := range tests { r := ssvgc.NewRectangle() for name, value := range tt { r.SetAttribute(name, value) } draw2dimg.SaveToPngFile("output/"+tt["name"]+".png", r.Draw()) } }
func TestSVGDrawing(t *testing.T) { if testing.Short() { t.Skip("Skipping lengthier tests during short test run.") } var rectangleDefinitions = []StringMap{ { "name": "solidblue", "fill": "blue", "width": "200", "height": "200", "x": "0", "y": "0", }, { "name": "solidred", "fill": "red", "width": "100", "height": "100", "x": "50", "y": "50", }, { "name": "solidredstrokedgreen", "fill": "red", "width": "100", "height": "100", "x": "50", "y": "50", "stroke": "green", "stroke-width": "15", }, } var tests = []StringMap{ { "name": "solidbluesvg", "rectangles": "solidblue", "width": "200", "height": "200", "fill": "none", }, { "name": "bluewithredsvg", "rectangles": "solidblue,solidred", "width": "200", "height": "200", "fill": "none", }, { "name": "bluewithredstrokedgreensvg", "rectangles": "solidblue,solidredstrokedgreen", "width": "200", "height": "200", "fill": "none", }, } rectangles := make(map[string]*ssvgc.Rectangle) for _, def := range rectangleDefinitions { r := ssvgc.NewRectangle() for name, value := range def { r.SetAttribute(name, value) } rectangles[def["name"]] = r } for _, tt := range tests { s := &ssvgc.SVG{} for name, value := range tt { s.SetAttribute(name, value) } for _, rect := range strings.Split(tt["rectangles"], ",") { s.AddElement(rectangles[rect]) } draw2dimg.SaveToPngFile("output/"+tt["name"]+".png", s.Draw()) } }