Break On $APPLICATION = "KiXtart PiXaso Painter" $VERSION = "1.1" $AUTHOR = "by Shawn Tassie (www.kixtart.org)" $COPYRIGHT = "Copyright (c) 2002 - Freeware Bounce Technology (c) Chris (cj) Matheson LiteBrite (c) Milton Bradley Inc. Kixtart v@KIX (c) Ruud Van Velson" $DrawWidth = 1 ; thin thickness $FillStyle = 1 ; solid ; ; LiteBrite Constants ; $CELLWIDTH = 12 $CELLHEIGHT = 12 $CIRCLERADIUS = 5 $MAXCOL = 44 $MAXROW = 31 $XOFFSET = 0 $YOFFSET = 0 $MAXX = $MAXCOL * $CELLWIDTH + $XOFFSET $MAXY = $MAXROW * $CELLHEIGHT + $YOFFSET SRND((-1)*@TICKS) ; Randomize $Form = CreateObject("Kixtart.Form") $Form.Caption = $APPLICATION $Form.Width = 640 $Form.Height = 490 $Form.FontName = "arial" $Form.FontSize = 10 $Form.Center $Clear = $Form.CommandButton("Clear",555,20,70,25) $Clear.OnClick = "Clear_Click" $Clear.Default = 1 $Line = $Form.ToggleButton("Line",555,80,70) $Line.OnClick = "Line_Click" $Line.FontBold = 1 $Brite = $Form.ToggleButton("LiteBrite",555,110,70) $Brite.OnClick = "Brite_Click" $Brite.FontBold = 0 $Pixaso = $Form.ToggleButton("Pixaso!",555,200,70,25) $Pixaso.OnClick = "Pixaso_Click" $Circles = $Form.CommandButton("Circles",555,230,70,25) $Circles.OnClick = "Circles_Click" $Boxes = $Form.CommandButton("Boxes",555,260,70,25) $Boxes.OnClick = "Boxes_Click" $Options = $Form.CommandButton("Options...",555,355,70,25) $Options.OnClick = "Options_Click" $About = $Form.CommandButton("About",555,385,70,25) $About.OnClick = "TkAboutBox($$APPLICATION,$$VERSION,$$AUTHOR,$$COPYRIGHT)" $Exit = $Form.CommandButton("Exit",555,415,70,25) $Exit.OnClick = "Exit_Click" $Canvas = $Form.PictureBox("",10,10,534,378) $Canvas.BackColor = 0 $Canvas.ForeColor = $Form.RGB(255,255,255) $Canvas.OnMouseMove = "Canvas_MouseMove" $Canvas.OnMouseDown = "Canvas_MouseDown" $Canvas.OnMouseUp = "Canvas_MouseUp" $Canvas.DrawWidth = 1 $Color = $Form.Label("",10,395,48,48) $Color.BorderStyle = 1 $Color.BackColor = $Form.RGB(0,255,0) $Palette = $Form.PictureBox("",73,395,473,48) $Palette.OnClick = "Palette_Click" $Canvas.ForeColor = $Color.BackColor $Left = 0 $Top = 0 $Palette.FillStyle = 1 For $b = 0 to 255 Step 51 For $g = 0 to 255 Step 51 For $r = 0 to 255 Step 51 $Palette.FillColor = ($b*256*256)+($g*256)+$r $Palette.Rectangle($Left,$Top,14,8) $Left = $Left + 13 if $Left = 468 $Left = 0 $Top = $Top + 7 EndIf Next Next Next $startpoint_x = -1 $startpoint_y = -1 $endpoint_x = -1 $endPoint_y = -1 $line_mode = 0 $brite_mode = 1 ; OPTIONS Line_Click() $Clear.SetFocus $Form.Show While $Form.Visible $=Execute($Form.DoEvents) = 0 Loop Exit 1 Function Clear_Click $Canvas.BackColor = 0 EndFunction Function Line_Click $mode = $line_mode $line.Font.bold = 1 $line.value = 1 $brite.Font.bold = 0 $brite.value = 0 EndFunction Function Brite_Click $mode = $brite_mode $line.Font.bold = 0 $line.value = 0 $brite.Font.bold = 1 $brite.value = 1 EndFunction function pixaso_click if $pixaso.Caption = "Pixaso!" $pixaso.Font.Bold = 1 $pixaso.Caption = "Running" pixaso($canvas,1) else $pixaso.Font.Bold = 0 $pixaso.Caption = "Pixaso!" pixaso($canvas,0) endif endfunction function exit_click quit() endfunction Function Canvas_MouseMove() If $Mode = $Line_Mode $Canvas.ForeColor = $Color.BackColor $endpoint_x = $canvas.mousex $endpoint_y = $canvas.mousey if ($startpoint_x <> -1 ) $canvas.currentx = $startpoint_x $canvas.currenty = $startpoint_x $canvas.line($startpoint_x,$startpoint_y,$endpoint_x,$endpoint_y) $startpoint_x = $endpoint_x; $startpoint_y = $endpoint_y; endif else if $drawing addcell($canvas.mousex,$canvas.mousey,$color.backcolor) endif endif endfunction function canvas_mousedown() if $mode = $line_mode $startpoint_x = $canvas.mousex $startpoint_y = $canvas.mousey else $drawing = 1 addcell($canvas.mousex,$canvas.mousey,$color.backcolor) endif endfunction Function Canvas_MouseUp() If $Mode = $Line_Mode $Startpoint_x = -1 $Startpoint_y = -1 Else $Drawing = 0 EndIf EndFunction function palette_click $canvas.forecolor = $palette.point($palette.mousex,$palette.mousey) $color.backcolor = $canvas.forecolor ; $palette.point($palette.mousex,$palette.mousey) endfunction function addcell($x,$y,$c) dim $col,$row if $drawing if ( $x > $XOFFSET and $x < $MAXX and $y > $YOFFSET and $y < $MAXY ) $row = ($y - $YOFFSET) / $CELLHEIGHT $col = ($x - $XOFFSET) / $CELLWIDTH $canvas.forecolor = $c $canvas.fillstyle = $fillstyle ; solid $canvas.fillcolor = $c $cx = $col*$CELLWIDTH+$XOFFSET+$CELLWIDTH/2 $cy = $row*$CELLHEIGHT+$YOFFSET+$CELLHEIGHT/2 $canvas.circle($cx,$cy,$CIRCLERADIUS) if $c $canvas.forecolor = &FFFFFF $canvas.fillcolor = &FFFFFF $canvas.circle($cx,$cy-1,2) endif endif endif endfunction function pixaso($form,$state) ; ; The pixaso asynchronous event loop ; ; Peforms doevents(1) [1=nowait] and simultaneously ; draws randomly colored lines on the form ; specified. Calling this function with $state ; set to 1 (true) starts the event loop. Called ; a second time with $state set to 0 (false) ; terminates the function. Bascially, this function ; 'hijacks' the main script event loop. The global ; variable $_pixaso controls the looping mechanism ; dim $x1,$y1,$x2,$y2,$s dim $x1d,$y1d,$x2d,$y2d dim $width,$height dim $red,$green,$blue if not $state $_pixaso = 0 ; turn off the running thread return endif $_pixaso = 1 $width = $Form.scalewidth $height = $Form.scaleheight $x1=rnd($width) $y1=rnd($height) $x2=rnd($width) $y2=rnd($height) $s = 3 ; speed (pixel jumps per draw) ; initialize deltas $x1d = 1 $y1d = 2 $x2d = -1 $y2d = -2 while $_pixaso $= execute($Form.doevents(1)) $red=$red+1 if $red > 255 $red=rnd(255) endif $blue=$blue+1 if $blue > 255 $blue=rnd(255) endif $green=$green+1 if $green > 255 $green=rnd(255) endif $Form.forecolor = $Form.rgb($red,$green,$blue) $Form.line($x1, $y1, $x2, $y2) $x1=$x1+$x1d if $x1 > $width $x1d=0-(rnd($s)+1) endif if $x1<0 $x1d=rnd($s)+1 ; 2 endif $y1=$y1+$y1d if $y1>$height $y1d=0-(rnd($s)+1) endif if $y1<0 $y1d=rnd($s)+1 endif $x2=$x2+$x2d if $x2>$width $x2d=0-(rnd($s)+1) endif if $x2<0; $x2d=rnd($s)+1 endif $y2=$y2+$y2d if $y2>$height $y2d=0-(rnd($s)+1) endif if $y2<0; $y2d=rnd($s)+1 endif Loop EndFunction Function Circles_Click ; ; Draws a random number of randomly colored circles ; on the canvas ; $Canvas.fillstyle = $fillstyle For $i = 0 to RND(15)+5 $Canvas.ForeColor = $Canvas.RGB(RND(255),RND(255),RND(255)) $Canvas.FillColor = $Canvas.RGB(RND(255),RND(255),RND(255)) $Canvas.Circle(RND($Canvas.Width),RND($Canvas.Height),RND($Canvas.Width)/5) Next EndFunction Function Boxes_Click ; ; Draws a random number of randomly colored boxes ; on the canvas ; $Canvas.FillStyle = $FillStyle For $i = 0 To RND(15)+5 $Canvas.ForeColor = $Canvas.RGB(RND(255),RND(255),RND(255)) $Canvas.FillColor = $Canvas.RGB(RND(255),RND(255),RND(255)) $Canvas.Rectangle(RND($Canvas.Width),RND($Canvas.Height),RND($Canvas.Width)/3,RND($Canvas.Height)/3) Next EndFunction Function Options_Click ; ; Allows user to change the following ; (global) script variables: ; ; $DrawWidth ; $FillStyle ; Dim $Form Dim $Frame1,$Thin,$Medium,$Thick Dim $Frame2,$Hollow,$Solid Dim $Ok $Form = CreateObject("Kixtart.Form") $Form.BorderStyle = 1 $Form.Caption = "Options" $Form.Width = 240 $Form.Height = 200 $Form.Center $Form.FontName = "Arial" $Form.FontSize = 10 $Frame1 = $Form.Frame $Frame1.Caption = "DrawWidth" $Frame1.Left = 10 $Frame1.Top = 10 $Frame1.Width = 100 $Frame1.Height = 90 $Thin = $Frame1.OptionButton $Thin.Caption = "Thin" $Thin.Left = 10 $Thin.Top = 20 $Thin.Width = 75 $Thin.Height = 20 $Thin.Value = $DrawWidth = 1 $Thin.OnClick = "$$DrawWidth = 1" $Medium = $Frame1.OptionButton $Medium.Caption = "Medium" $Medium.Left = 10 $Medium.Top = 40 $Medium.Width = 75 $Medium.Height = 20 $Medium.Value = $DrawWidth = 3 $Medium.OnClick = "$$DrawWidth = 3" $Thick = $Frame1.OptionButton $Thick.Caption = "Thick" $Thick.Left = 10 $Thick.Top = 60 $Thick.Width = 75 $Thick.Height = 20 $Thick.value = $DrawWidth = 6 $Thick.OnClick = "$$DrawWidth = 6" $Frame2 = $Form.Frame $Frame2.Caption = "FillStyle" $Frame2.Left = 120 $Frame2.Top = 10 $Frame2.Width = 100 $Frame2.Height = 90 $Hollow = $Frame2.OptionButton $Hollow.Caption = "Hollow" $Hollow.Left = 10 $Hollow.Top = 20 $Hollow.Width = 75 $Hollow.Height = 20 $Hollow.Value = $FillStyle = 0 $Hollow.OnClick = "$$FillStyle=0" $Solid = $Frame2.OptionButton $Solid.Caption = "Solid" $Solid.Left = 10 $Solid.Top = 40 $Solid.Width = 75 $Solid.Height = 20 $Solid.Value = $FillStyle = 1 $Solid.OnClick = "$$FillStyle = 1" $Ok = $Form.CommandButton("OK",80,120,70,25) $Ok.Default = 1 $Ok.OnClick = "$$Form.Hide" $Form.Show While $Form.Visible $=Execute($Form.DoEvents) Loop $Canvas.DrawWidth = $DrawWidth EndFunction Function TkInputBox ( Optional $Prompt, Optional $Title, Optional $Default, Optional $Left, Optional $Top ) ; ; TkInputBox is part of the Kixforms Toolkit ; Dim $Form,$Label,$TextBox,$Ok,$Cancel Dim $Okayed,$Canceled $Form = CreateObject("Kixtart.Form") $Form.Caption = $Title $Form.Width = 363 $Form.Height = 163 $Form.Center $Label = $Form.Label($Prompt,10,20,200,75) $Ok = $Form.CommandButton("OK",275,20,71,21) $Ok.Default = 1 ; True $Ok.OnClick = "$$Okayed=1" $Cancel = $Form.CommandButton("Cancel",275,50,71,21) $Cancel.Cancel = 1 ; True $Cancel.OnClick = "$$Canceled=1" $TextBox = $Form.TextBox($Default,10,100,334,21) $Form.Show While $Form.Visible And Not $Okayed And Not $Canceled $=Execute($Form.DoEvents) Loop If $Okayed $TkInputBox = $TextBox.Text Else $TkInputBox = "" Endif EndFunction Function TkAboutBox( $Name, $Version, $Author, $Message) ; ; TkInputBox() is part of the Kixforms Toolkit. ; ; Displays a dialog box containing script name, version, ; author name and a general information. User must press ; the OK button to dismiss. ; ; Dim $Form Dim $Script,$Vers,$Auth,$Msg Dim $Ok $Form = CreateObject("Kixtart.Form") $Form.ScaleWidth = 400 $Form.ScaleHeight = 260 $Form.BorderStyle = 1 $Form.Center $Form.Caption = "About "+$Name $Form.FontName = "MS Sans Serif" $Form.FontSize = 10 $Script = $Form.Label("",10,20,$Form.ScaleWidth-20,40) $Script.FontSize = 18 $Script.FontBold = 1 $Script.Caption = $Name $Script.Alignment = 2 $Vers = $Form.Label("",10,70,$Form.ScaleWidth-20,20) $Vers.Caption = "Version $version" $Vers.Alignment = 2 $Auth = $Form.Label("",10,100,$Form.ScaleWidth-20,20) $Auth.Caption = $Author $Auth.Alignment = 2 $Msg = $Form.Label("",10,130,$Form.ScaleWidth-20,80) $Msg.Caption = $Message $Msg.Alignment = 2 $Ok = $Form.CommandButton("OK",160,220,75,25) $Ok.OnClick = "$$Form.Hide" $Ok.Default = 1 $Form.Show While $Form.Visible $=Execute($Form.DoEvents) Loop EndFunction