/* Pixeltool - by nudalz April 6th 2k7 (v1.1) Pixeltool (or pt for short) is a picture window script that lets you draw along a re-sizable grid, giant 'pixels' or blocks. The pictures you make can then be saved, loaded, and sent to channels/people (in text form). It is possible to send your current art without saving. To use: /pt to open Pixeltool (you can also open by right clicking inside a channel or query) /pt X Y to create a custom grid of X Y block size (also done by right clicking dialog) Inside Pixeltool is (your) 16 mIRC colours, & beneath is the selected colour. Pick a new colour by simply clicking, and left-click & drag inside the grid to draw. Right clicking inside Pixeltool brings up various options (new/resize/fill grid/open file/load art/save art). Right clicking inside a query or channel window brings up other options (open pt/send current art to active/send saved art to active). Note: There is one known problem & that is having a picture smaller than 15px vertical. If your picture is smaller than that, it is best you resize your picture after you finish drawing then save (Drawing while smaller than 15px may also cause serious problems). Have fun -nudalz @ buttstories.com Version hist: 1.1 - Now uses a /pt/ folder in mIRC directory to store art files (this folder is created upon loading). *Note* The script itself can still be saved and loaded from anywhere; same for art files. If you have an older version it is best you move them into /pt/ to avoid .txt mixups (but don't have to). - Improved titlebar. - Added quick resize option. - Added a "Play Random Art" function in channel/query right-click. This uses /play on a random text file from /pt/ folder. - Replaced $qt(...) with $+(",...,") in all cases to allow earlier versions of mIRC to function proper when saving/playing current art. 1.0 - Public release */ alias pt { if (!$2) tokenize 32 20 20 hadd -m pt x $calc(($1 *10)) hadd pt y $calc(($2 *10)) if (!$window(@Pixeltool)) hadd pt c $color(15) window -Cdfk0pw0 +ft @Pixeltool 0 0 $calc($hget(pt,x) +30) $hget(pt,y) drawrect -fr @Pixeltool $color(0) 1 30 0 $hget(pt,x) $hget(pt,y) pt.title pt.ui pt.grid $1 $2 } alias -l pt.re { hadd pt x $calc(($1 *10)) hadd pt y $calc(($2 *10)) if (!$window(@Pixeltool)) hadd pt c $color(15) window -fp @Pixeltool -1 -1 $calc($hget(pt,x) +30) $hget(pt,y) pt.ui pt.grid $1 $2 } alias -l pt.title { renwin @Pixeltool @Pixeltool $iif($1-,- $1-,- Untitled) } alias -l pt.ui { drawrect -fr @Pixeltool $rgb(250,250,250) 1 0 0 30 $hget(pt,y) drawrect -cr @Pixeltool $rgb(235,235,235) 1 0 0 30 $hget(pt,y) var %c = 0, %n = 1, %x = 4, %y = 3 while (%n <= 8) { drawrect -r @Pixeltool $rgb(100,100,100) 1 %x %y 10 10 drawfill -r @Pixeltool $color(%c) $rgb(100,100,100) $calc(%x +1) $calc(%y +1) inc %x 12 inc %c drawrect -r @Pixeltool $rgb(100,100,100) 1 %x %y 10 10 drawfill -r @Pixeltool $color(%c) $rgb(100,100,100) $calc(%x +1) $calc(%y +1) dec %x 12 inc %y 12 inc %c inc %n } drawrect -r @Pixeltool $rgb(100,100,100) 1 9 100 12 12 drawfill -r @Pixeltool $hget(pt,c) $rgb(100,100,100) 10 101 drawtext -bcr @Pixeltool $rgb(100,100,100) $rgb(250,250,250) terminal 7 2 $calc($hget(pt,y) -35) 27 6 V1.1 drawtext -r @Pixeltool $rgb(100,100,100) terminal 7 6 $calc($hget(pt,y) -17) x: $+ $calc($hget(pt,x) /10) drawtext -r @Pixeltool $rgb(100,100,100) terminal 7 6 $calc($hget(pt,y) -8) y: $+ $calc($hget(pt,y) /10) } alias -l pt.grid { var %x = 0, %y = 0 while (%y <= $1) { drawline -r @Pixeltool $rgb(235,235,235) 1 $calc((%y *10) +30) 0 $calc((%y *10) +30) $hget(pt,y) inc %y } while (%x <= $2) { drawline -r @Pixeltool $rgb(235,235,235) 1 30 $calc(%x *10) $calc($hget(pt,x) +30) $calc(%x *10) inc %x } } alias -l pt.draw { if ($inrect($2,$3,0,0,30,$hget(pt,y)) == $true) { if ($hget(pt,m)) hdel pt m var %a = $getdot(@Pixeltool,$2,$3) if ((%a == $rgb(100,100,100)) || (%a == $rgb(235,235,235)) || (%a == $rgb(250,250,250))) halt else { hadd pt c %a drawfill -r @Pixeltool %a $rgb(100,100,100) 10 102 } } else drawfill -r @Pixeltool $hget(pt,c) $rgb(235,235,235) $2 $3 } alias -l pt.load { var %c = $chr(35), %f = $$1-, %l = 1, %o, %y = 1 pt.re $len($strip($read(%f,1))) $lines(%f) pt.title $nopath(%f) while ($read(%f,%l)) { noop $regex(c,$pt.lf($v1),/(\d{1,2}\.\d{1,2})/g) noop $regex(l,$pt.lf($v1),/(#+)/g) var %x = 31, %m = 1, %n = 1 while (%m <= $regml(c,0)) { %o = 1 while (%o <= $len($regml(l,%n))) { drawfill -r @Pixeltool $color($gettok($regml(c,%m),1,46)) $rgb(235,235,235) %x %y inc %x 10 inc %o } inc %n inc %m } inc %y 10 inc %l } } alias -l pt.save { if ($1 == 1) { var %f = $$2- | if ($isfile(%f)) write -c $+(",%f,") | if ($numtok($nopath(%f),46) == 1) %f = $+(%f,.txt) | pt.title $nopath(%f) } else var %f = $$2 var %c = $chr(35), %o, %s, %t, %x, %y = 1 while (%y <= $hget(pt,y)) { %x = 31 while (%x <= $calc($hget(pt,x) +30)) { %t = $pt.c($getdot(@Pixeltool,%x,%y)) if (%o == %t) %s = %s $+ %c else %s = $+(%s,$chr(3),%t,$chr(44),%t,%c) %o = %t if (%x == $calc($hget(pt,x) +21)) { if ($1 == 1) write $qt(%f) %s else msg %f %s unset %s unset %o } inc %x 10 } inc %y 10 } } ;misc fixing aliases alias -l pt.c { var %c = 0 | while (%c <= 15) { if ($1 == $color(%c)) { return %c | break } | inc %c } } alias -l pt.lf { return $replace($$1-,$chr(44),$chr(46),$chr(3),$null) } alias -l pt.rclick { ;rclick fix hadd pt cur-x $calc($ceil($calc($mouse.x /10)) -3) hadd pt cur-y $ceil($calc($mouse.y /10)) } menu @Pixeltool { mouse:{ if ($hget(pt,m)) pt.draw $hget(pt,c) $mouse.x $mouse.y if ($inrect($mouse.x,$mouse.y,31,1,$hget(pt,x),$hget(pt,y)) == $true) drawtext -bcr @Pixeltool $rgb(100,100,100) $rgb(250,250,250) terminal 7 2 $calc($hget(pt,y) -26) 27 6 $+($base($calc($ceil($calc($mouse.x /10)) -3),10,10,2),$chr(44),$base($ceil($calc($mouse.y /10)),10,10,2)) else drawtext -bcr @Pixeltool $rgb(100,100,100) $rgb(250,250,250) terminal 7 2 $calc($hget(pt,y) -26) 27 6 ??? } sclick:{ hinc pt m | pt.draw $hget(pt,c) $mouse.x $mouse.y } uclick:hdel pt m leave:drawtext -bcr @Pixeltool $rgb(100,100,100) $rgb(250,250,250) terminal 7 2 $calc($hget(pt,y) -26) 27 6 ??? $pt.rclick New .20x20:{ close -@ @Pixeltool | pt 20 20 } .30x30:{ close -@ @Pixeltool | pt 30 30 } .50x50:{ close -@ @Pixeltool | pt 50 50 } .Custom:{ if ($regex($input(Enter in values for X Y (i.e. 75 50),e,Pixeltool - New),/^(\d+\s\d+)$/)) { close -@ @Pixeltool | pt $regml(1) } } Resize .20x20:pt.re 20 20 .30x30:pt.re 30 30 .50x50:pt.re 50 50 .Custom:if ($regex($input(Enter in values for X Y (i.e. 75 50),e,Pixeltool - Resize),/^(\d+\s\d+)$/)) pt.re $regml(1) .- .To X,Y ( $+ $+($hget(pt,cur-x),$chr(44),$hget(pt,cur-y)) $+ ):{ pt.re $hget(pt,cur-x) $hget(pt,cur-y) hdel -w pt cur* } Fill Grid .With Selected Colour:{ var %x, %y = 1 while (%y <= $hget(pt,y)) { %x = 31 while (%x <= $calc($hget(pt,x) +30)) { drawfill -r @Pixeltool $hget(pt,c) $rgb(235,235,235) %x %y inc %x 10 } inc %y 10 } } - Open Art:if ($sfile($mircdirpt\ *.txt)) run $qt($v1) - Load Art:pt.load $sfile($mircdirpt\ *.txt,Load Art,Load) Save Art:pt.save 1 $sfile($mircdirpt\ *.txt,Save As,Save) } menu Channel,Query { Pixeltool .Open Pixeltool 1.1:pt .Play Current Art (to $active $+ ):pt.save 2 $active .Play Saved Art (to $active $+ ) $+ ...:if ($sfile($mircdirpt\ *.txt)) .play $active $+(",$v1,") .Play Random Art (to $active $+ ): if ($findfile($mircdirpt\,*.txt,0)) .play $active $+(",$findfile($mircdirpt\,*.txt,$rand(1,$v1)),") } on *:close:@Pixeltool:{ if ($window(@Pixeltool).title == - Untitled) pt.save 1 pt\pt-last.txt | hfree pt } on *:load:mkdir pt