to make this work do you ned to have GD library installed in php? dave
2010/1/26 Bjørn Magnhildøen <[email protected]> > it's mostly done by iterations of superimposing b/w images with a > transparent background. > see core code below. i'm using php so the generation is also done > online, as 'larding' - line-stretching. some effects come from php's > inability to handle transparent images, ie. i have to use some > imagefill function ('paint bucket') to fill it with a transparent > color, which has the effect also of erasing lines (if you hit fill on > the wrong pixel, black instead of white) as seen clearly in the more > complex drawings, which has up to thousand iterations. > i'll put the code in the gallery somewhere. > > <?php > /* > $new_image = image resource identifier such as returned by > imagecreatetruecolor(). must be passed by reference > $image_source = image resource identifier returned by > imagecreatefromjpeg, imagecreatefromgif and imagecreatefrompng. must > be passed by reference > */ > function setTransparency($new_image,$image_source) > { > global $im, $im2; > > $transparencyIndex = imagecolortransparent($image_source); > $transparencyColor = array('red' => 255, 'green' => 255, > 'blue' => 255); > > if ($transparencyIndex >= 0) { > $transparencyColor = > imagecolorsforindex($image_source, $transparencyIndex); > } > > $transparencyIndex = imagecolorallocate($new_image, > $transparencyColor['red'], $transparencyColor['green'], > $transparencyColor['blue']); > imagefill($new_image, 0, 0, $transparencyIndex); > imagecolortransparent($new_image, $transparencyIndex); > > } > > function myimagefill($im, $x, $y, $color) { > while ($i++ < 100 and $j < 10) { > $x2 = mt_rand(0,$x); > $y2 = mt_rand(0,$y); > $rgb = imagecolorat($im, $x2, $y2); > $r = ($rgb >> 16) & 0xFF; > $g = ($rgb >> 8) & 0xFF; > $b = $rgb & 0xFF; > // if ($r == 0 and $g == 0 and $b == 2) { > imagefill($im, $x2, $y2, $color); > // $j++; > // } > } > return $im; > } > > function myprocess() { > global $im, $im2, $png, $i, $x, $y; > $cf = trim($png[mt_rand(0,sizeof($png)-1)]); > $im2 = imagecreatefrompng($cf); > $white = imagecolorallocate($im2, 255, 255, 255); > imagecolortransparent($im2, $white); > $im2size = getimagesize($cf); > $x2 = $im2size[0]; > $y2 = $im2size[1]; > if ($x2 < 150 or $y2 < 150) return; > $x3 = mt_rand(0,$x+$x2); > $y3 = mt_rand(0,$y+$y2); > $x4 = $x3 - $x2; > $y4 = $y3 - $y2; > imagefill($im2, 0, 0, $white); > $im2 = myimagefill($im2, $x2, $y2, $white); > imagecolortransparent($im2, $white); > setTransparency($im2, $im); //original > imagecopymerge($im, $im2, $x4, $y4, 0, 0, $x2, $y2, 100); > imagedestroy($im2); > } > > function makepng() { > global $i, $im,$x,$y,$loops,$navn,$png; > $im = imagecreatetruecolor($x,$y); > $white = imagecolorallocate($im, 255, 255, 255); > imagecolortransparent($im, $white); > for ($i=0;$i<=$loops;$i++) { > myprocess(); > imagecolortransparent($im, $white); > } > $navn = "larding-data/tmp.png"; > imagepng($im, $navn); > imagedestroy($im); > } > ?> > > On Tue, Jan 26, 2010 at 11:16 AM, Pall Thayer <[email protected]> wrote: > > You should post the scripts somewhere. > > > > Pall > > > > 2010/1/26 Bjørn Magnhildøen <[email protected]>: > >> the material is originally hand scribbled, and then processed through > scripts. > >> i wanted to code a doodle machine in the beginning but couldn't get it > >> to do anything interesting (in my view), so i tried doing it via real > >> doodles instead and building up from those as patterns. > >> thanks, bjørn > >> > >> On Tue, Jan 26, 2010 at 10:45 AM, dave miller <[email protected]> > wrote: > >>> these are great - are the drawings generated by code? or hand > scribbled? > >>> dave > >>> > >>> 2010/1/26 <[email protected]> > >>>> > >>>> http://noemata.net/time().mt_rand/ > >>>> _______________________________________________ > >>>> NetBehaviour mailing list > >>>> [email protected] > >>>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour > >>> > >>> > >>> _______________________________________________ > >>> NetBehaviour mailing list > >>> [email protected] > >>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour > >>> > >> _______________________________________________ > >> NetBehaviour mailing list > >> [email protected] > >> http://www.netbehaviour.org/mailman/listinfo/netbehaviour > >> > > > > > > > > -- > > ***************************** > > Pall Thayer > > artist > > http://www.this.is/pallit > > ***************************** > > _______________________________________________ > > NetBehaviour mailing list > > [email protected] > > http://www.netbehaviour.org/mailman/listinfo/netbehaviour > > > _______________________________________________ > NetBehaviour mailing list > [email protected] > http://www.netbehaviour.org/mailman/listinfo/netbehaviour >
_______________________________________________ NetBehaviour mailing list [email protected] http://www.netbehaviour.org/mailman/listinfo/netbehaviour
