shamuraq Posted May 27, 2009 Share Posted May 27, 2009 Hi Guys, I manage to randomise a rectangle(length and height) in .svg format. 1. How do i now randomise the number of rectangles produced? 2. Since i want to give the power to the randomised height and width, how do i set the canvas size to be dynamic so that the output will not reach the end of the canvas? //Creating canvas echo '<svg width="310" height="140" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">'; //Declaring Color of Fill & Borders //Transform tells svg parser where in the canvas to start drawing. Drawing starts from top-left corner //with x and y axis respectively $color = rand(000000,999999);//Declaring random color echo '<g style="stroke:black;fill:#'."$color".';stroke-width:2" transform="translate(10,10)">'; //Dynamically Drawing Rectangle at random values? $w1 = rand(50,100); $h1 = rand(10,30); //Originally from: echo '<rect x="10" y="10" width="100" height="30" style="stroke-width:4"/>'; $box = '<rect x="10" y="10" width='.'"'."$w1".'"'.' height='.'"'."$h1".'"'.'/>'; echo "$box"; echo '</g>'; echo '</svg>'; ?> Thanx in advance... Link to comment https://forums.phpfreaks.com/topic/159911-multiple-images-dynamic-svg/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.