#version 3.7; global_settings { assumed_gamma 1.0 } //------------------------------------------ // Macros for generating Scalable Vector Graphic (SVG) files // Bill Walker - 2016 //------------------------------------------ #include "colors.inc" #include "debug.inc" Set_Debug (true) #include "math.inc" #include "rand.inc" #include "shapes.inc" #include "shapes3.inc" #include "transforms.inc" //############################################### #declare XImageSize = 1366; #declare YImageSize = 768; //############################################### // ***** Before raytracing, set render resolution for POV-Ray output file ***** //#declare YImageSize = -YImageSize; light_source { color rgb <1, 1, 1>} #declare Camera_Origin = camera { location <0, 0, 0> //right x*image_width/image_height look_at <0, 0, 0.01>} #declare Camera_Angle = camera { location <5 , 10, -15.0> //right x*image_width/image_height //look_at <0, 0, 0> look_at <5, 5, 5>} #declare Camera_Front = camera { location //right x*image_width/image_height look_at } #declare Camera_Rear = camera { location <0.0, -100.0, -300.0> //right x*image_width/image_height look_at <0, 0, 0>} #declare Camera_Top = camera { location <0, 8.0, 0> //right x*image_width/image_height look_at <0, 0, 0>} #declare Camera_Iso = camera { location <-50, 0, 0> //right x*image_width/image_height look_at <0, 0, 0>} #declare Camera_Bottom = camera { location <0, -1, -0.1> //right x*image_width/image_height look_at <0, 0, 0>} #declare Camera_Point = camera { location <1.5, 0, -1> //right x*image_width/image_height look_at <1.5, 0, 0>} #declare Camera_Orthographic = camera { orthographic location sky <0, 1, 0> right up <0, YImageSize, 0> look_at } // having z=1 here seems to be be important for the ortho camera to work properly camera {Camera_Orthographic} sky_sphere { pigment {White} } //======================================================================================================================= //plane { <0,1,0>, 0 texture { pigment{color Black}} } cylinder { <-1366, 0, 0>, <1366, 0, 0>, 5 pigment {color Red}} // X-axis cylinder { <0, 0, -768>, <0, 0, 768>, 5 pigment {color Red}} // Y-axis #declare Zplane = 100; #declare Layer = 0.01; #ifndef (SVG_File) #fopen SVG_File "POV-SVG_Test1.svg" write #end // Write svg file header // #write (SVG_File, "") #write (SVG_File, "\n") // Line break #write (SVG_File, "") // SVG COMMENT #write (SVG_File, "\n") // Line break //###################################################################################### // BEGIN OBJECT DEFINITIONS //###################################################################################### // LINE #write(SVG_File, "") // SVG COMMENT #write(SVG_File, "\n") // Line break // define attributes for object // #local Object = "line"; #local X1 = 250; #local Y1 = 50; #local X2 = 400; #local Y2 = 200; #local Stroke_width = 4; #local Stroke = "blue"; #local LineColor = pigment {Blue}; // write Line to file #write (SVG_File,"<", Object, " x1=\"", X1, "\" y1=\"", Y1, "\" x2=\"", X2, "\" y2=\"", Y2, "\" stroke-width=\"", Stroke_width, "\" stroke=\"", Stroke, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break // Define analogous objects in POV-Ray cylinder {, Stroke_width/2 texture {LineColor}} //============================SVG Object Separator===================================== // POLYLINE #write (SVG_File, "") // SVG COMMENT #write (SVG_File, "\n") // Line break // define attributes for object // #local Object = "polyline"; // NUMBER OF POINTS #local Points = 4; #local Polyline = array [Points] {<250, 150, Zplane>, <250, 200, Zplane>, <400, 200, Zplane>, <400, 100, Zplane> }; #local Elements = dimension_size (Polyline, 1); #local Fill = "none"; #local Stroke_width = 4; #local Stroke = "red"; #local LineColor = pigment {Red}; // write polyline to file #write (SVG_File, "<", Object, " points=\"") #local loop = 0; #while (loop < Elements) #local Vector = Polyline [loop]; #write (SVG_File, Vector.x, ",", Vector.y, " " ) // Define analogous objects in POV-Ray #if (loop = 0) #else cylinder {, Stroke_width/2 texture {LineColor}} #end #local Lastvector = Vector; #local loop = loop + 1; #end // end while #write (SVG_File, "\" stroke=\"", Stroke, "\" stroke-width=\"", Stroke_width, "\" fill=\"", Fill, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break //============================SVG Object Separator===================================== // RECTANGLE #write(SVG_File, "") // SVG COMMENT #write(SVG_File, "\n") // Line break // define attributes for object // #local Object = "rect"; #local X = 25; #local Y = 20; #local Width = 200; #local Height = 200; #local Fill = "lime"; #local Stroke_width = 4; #local Stroke = "pink"; #local Color = pigment {color rgb <0, 0, 0>}; // write rectangle to file #write (SVG_File,"<", Object, " x=\"", X, "\" y=\"", Y, "\" width=\"", Width, "\" height=\"", Height, "\" fill=\"", Fill, "\" stroke-width=\"", Stroke_width, "\" stroke=\"", Stroke, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break // Define analogous objects in POV-Ray box { pigment {Red}} // Large red box for outline box { pigment {Green}} // Smaller inset box for fill //============================SVG Object Separator===================================== // Rounded Corner Rectangle #write (SVG_File, "") // SVG COMMENT #write (SVG_File, "\n") // Line break // define attributes for object // #local Object = "rect"; #local X = 250; #local Y = 20; #local RX = 20; #local RY = 20; #local Width = 150; #local Height = 150; #local Fill = "red"; #local Stroke_width = 5; #local Stroke = "black"; #local Color = pigment {color rgb <0, 0, 0>}; // write rounded rectangle to file #write (SVG_File,"<", Object, " x=\"", X, "\" y=\"", Y, "\" rx=\"", RX, "\" ry=\"", RY, "\" width=\"", Width, "\" height=\"", Height, "\" fill=\"", Fill, "\" stroke-width=\"", Stroke_width, "\" stroke=\"", Stroke, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break // Define analogous objects in POV-Ray // Corner #local Corner = object {Segment_of_Torus (RX, Stroke_width/2, -90) texture {Color}} #local TL = object {Corner rotate <0, -90, 0> rotate <-90, 0, 0> scale <1, RY/RX, 1> translate } #local TR = object {Corner rotate <0, 0.0, 0> rotate <-90, 0, 0> scale <1, RY/RX, 1> translate } #local BL = object {Corner rotate <0, -180, 0> rotate <-90, 0, 0> scale <1, RY/RX, 1> translate } #local BR = object {Corner rotate <0, 90, 0> rotate <-90, 0, 0> scale <1, RY/RX, 1> translate } #local Top = cylinder {, Stroke_width/2 texture {Color}} #local Bottom = cylinder {, Stroke_width/2 texture {Color}} #local Left = cylinder {, Stroke_width/2 texture {Color}} #local Right = cylinder {, Stroke_width/2 texture {Color}} #local RoundedRectangle = union { object {TL} object {TR} object {BL} object {BR} object {Top} object {Bottom} object {Left} object {Right} } object {RoundedRectangle} //============================SVG Object Separator===================================== // CIRCLE #write(SVG_File, "") // SVG COMMENT #write(SVG_File, "\n") // Line break // define attributes for object // #local Object = "circle"; #local X = 125; #local Y = 125; #local Radius = 75; #local Fill = "orange"; #local FillColor = pigment {Orange}; #local Stroke_width = 1; #local Stroke = "black"; #local LineColor = pigment {Black}; // write circle to file #write (SVG_File,"<", Object, " cx=\"", X, "\" cy=\"", Y, "\" r=\"", Radius, "\" fill=\"", Fill, "\" stroke-width=\"", Stroke_width, "\" stroke=\"", Stroke, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break // Define analogous objects in POV-Ray torus { Radius, Stroke_width/2 texture {LineColor} scale <1, 1, 1> rotate<90, 0, 0> translate} disc {, <0, 0, 1>, Radius, 0 texture {FillColor}} //cylinder {, Radius texture {FillColor}} //============================SVG Object Separator===================================== // Ellipse #write(SVG_File, "") // SVG COMMENT #write(SVG_File, "\n") // Line break // define attributes for object // #local Object = "ellipse"; #local X = 50; #local Y = 350; #local RX = 25; #local RY = 50; #local Fill = "yellow"; #local FillColor = pigment {Yellow}; #local Stroke_width = 4; #local Stroke = "purple"; #local LineColor = pigment {Violet}; // write ellipse to file #write (SVG_File,"<", Object, " cx=\"", X, "\" cy=\"", Y, "\" rx=\"", RX, "\" ry=\"", RY, "\" fill=\"", Fill, "\" stroke=\"", Stroke, "\" stroke-width=\"", Stroke_width, "\" />") #write (SVG_File, "\n") // Line break #write (SVG_File, "\n") // Line break // Define analogous objects in POV-Ray torus { 100, Stroke_width/2 scale rotate<90, 0, 0> translate texture {LineColor} } disc {<0, 0, 0>, <0, 0, 1>, 100, 0 scale translate texture {FillColor}} //cylinder {, Radius texture {FillColor}} //============================SVG Object Separator===================================== // PATH // // // // //###################################################################################### // END OBJECT DEFINITIONS //###################################################################################### // write end of SVG file #write(SVG_File,"") #fclose SVG_File