Username:
Password:
  Home About Us Articles Rules Script Library FAQ Help
Not logged in (register
White Board 2.0 for mIRC

Last Modified: Aug 24 2:21pm (r5)

New version of White Board

- Uses MUCH less bandwidth.
-- Only sends tool #, size, and color when needed.
-- Encodes numbers to Base36
- Has a toolbox dialog.
-- Dialog hides when not viewing the drawing window.
- Opens the dialog and picture window upon entering #whiteboard
- If any one of the three windows closes, it shuts down the script.
- Cleans up all of its global variables when it closes.
- Uses hash tables to buffer commands.
-- Sends up to 325 characters every 500 miliseconds.
-- Buffer count in title bar. If it gets too high, you risk flooding.

To Use:
1) Just join the channel #whiteboard or type /whiteboard #channel
2) Go to the @whiteboard window
3) Draw for all of the other people in #whiteboard

/// To Do:
-Finish the tools.
--Retangle
--Ellipse
--Bucket
--Text
---Add a button to open a special dialog.
-Add Save to BMP menu option.
;#####################################################################
;#################### Notes                      #####################
;#####################################################################

;1) Dot
;2) Smooth Line
;3) Safe Line
;4) Rectangle Outline
;5) Filled Rectangle 
;6) Rounded Rectangle 
;7) Rectangle Focus Outline
;8) Ellipse Outline
;9) Filled Ellipse 
;10) Bucket

;#####################################################################
;#################### Aliases                    #####################
;#####################################################################

alias WhiteBoard {
  if ( %whiteboard.started == 1 ) {
    StopWhiteboard
  }
  if ( $1 != $null ) {
    set %whiteboard.channel $1
    StartWhiteboard
  }
}

alias -l StartWhiteboard {
  if ( %whiteboard.started == 1 ) {
    StopWhiteboard
  }
  set %whiteboard.tool 1
  set %whiteboard.size 1
  set %whiteboard.color 0
  set %whiteboard.bufcnt 0
  set %whiteboard.bufcur 0
  set %whiteboard.ontop $true
  set %whiteboard.tbx 200
  set %whiteboard.tby 150

  if ( %whiteboard.channel == $null ) {
    set %whiteboard.channel = #whiteboard
  }

  if ( $chan(%whiteboard.channel) == $null ) {
    join %whiteboard.channel
  }

  window -Cp +l @whiteboard
  drawfill -rs @whiteboard $RGB(255,255,255) $getdot(@whiteboard,1,1) 1 1

  if ( $dialog(TB) == TB ) {
    dialog -x TB
  }
  dialog -m TB ToolBox %whiteboard.tbx %whiteboard.tby

  .timerWhiteboardWindowCheck 0 1 /WhiteBoardWindowCheck
  .timerWhiteboardActiveCheck -m 0 250 /ActiveCheck
  .timerWhiteboardbuffer -m 0 500 /SendBuffer
  .timerWhiteBoardSmoothLine -m 0 100 /set %whiteboard.smoothadd $true

  set %whiteboard.started 1
  SendSettings
}

alias -l StopWhiteBoard {
  if ( %whiteboard.started = 1 ) {
    set %whiteboard.started 0

    .timerWhiteBoard* off

    if ( $chan(%whiteboard.channel) != $null ) {
      part %whiteboard.channel
    }

    close -@ @whiteboard
    if ($dialog(TB) != $null) {
      dialog -x TB
    }

    unset %whiteboard*

    titlebar $null
  }
}

alias -l AddToBuffer {
  inc %whiteboard.bufcnt
  hadd -m whiteboard item $+ %whiteboard.bufcnt $1-
}

alias -l SendBuffer {
  var %tempbuf
  while ( $len( %tempbuf ) < 325 && %whiteboard.bufcur < %whiteboard.bufcnt ) {
    inc %whiteboard.bufcur
    %tempbuf = %tempbuf $+ . $+ $hget(whiteboard, item $+ %whiteboard.bufcur)
    hdel whiteboard item $+ %whiteboard.bufcur
  }
  if ( %tempbuf != $null ) {
    msg %whiteboard.channel %tempbuf
    titlebar @whiteboard - $hget(whiteboard,0).item items in buffer.
  }
}

alias -l SendSettings {
  AddToBuffer - %whiteboard.tool %whiteboard.size %whiteboard.color
}

alias -l WhiteBoardWindowCheck {
  if ( $window(@Whiteboard) == $null ) {
    StopWhiteBoard
  }
}

alias -l ActiveCheck {
  if ( $active == @whiteboard ) {
    if ( %whiteboard.ontop == $false ) {
      dialog -m TB ToolBox %whiteboard.tbx %whiteboard.tby -1 -1
      dialog -s TB %whiteboard.tbx %whiteboard.tby -1 -1
      set %whiteboard.ontop $true
    }
    if ( $dialog(TB).x != %whiteboard.tbx ) { set %whiteboard.tbx $dialog(TB).x }
    if ( $dialog(TB).y != %whiteboard.tby ) { set %whiteboard.tby $dialog(TB).y }
  } 
  else {
    if ( %whiteboard.ontop == $true ) {
      dialog -x TB
      set %whiteboard.ontop $false
    }
  }
}

alias -l BoundValue {
  var %val $calc(0 + $1)
  if ( %val <= $calc(0 + $2) ) {
    return $2
  }
  elseif ( %val >= $calc(0 + $3) ) {
    return $3
  }
  else {
    return %val
  }
}

alias -l HandleCommand {
  var %nick $1
  var %cmd $2-

  if ( $gettok(%cmd, 1, 32) == - ) {
    set %whiteboard.tool. [ $+ [ %nick ] ]  $BoundValue($gettok(%cmd,2,32), 1, 10)
    set %whiteboard.size. [ $+ [ %nick ] ]  $BoundValue($gettok(%cmd,3,32), 1, 100)
    set %whiteboard.color. [ $+ [ %nick ] ]  $BoundValue($gettok(%cmd,4,32), 0, 16777215)
  } 
  else {
    var %tool %whiteboard.tool. [ $+ [ $nick ] ]
    var %size %whiteboard.size. [ $+ [ $nick ] ]
    var %color %whiteboard.color. [ $+ [ $nick ] ]
    var %lastx %whiteboard.lastx. [ $+ [ $nick ] ]
    var %lasty %whiteboard.lasty. [ $+ [ $nick ] ]

    if ( %tool == 1 ) {
      drawdot -r @whiteboard %color %size $base($gettok(%cmd, 1, 32), 36, 10) $base($gettok(%cmd, 2, 32), 36, 10)
      set %whiteboard.lastx. [ $+ [ $nick ] ] $base($gettok(%cmd, 1, 32), 36, 10)
      set %whiteboard.lasty. [ $+ [ $nick ] ] $base($gettok(%cmd, 2, 32), 36, 10)
    }
    elseif ( %tool == 2 || %tool == 3 ) {
      drawline -r @whiteboard %color %size %lastx %lasty $base($gettok(%cmd, 1, 32), 36, 10) $base($gettok(%cmd, 2, 32), 36, 10)
      set %whiteboard.lastx. [ $+ [ $nick ] ] $base($gettok(%cmd, 1, 32), 36, 10)
      set %whiteboard.lasty. [ $+ [ $nick ] ] $base($gettok(%cmd, 2, 32), 36, 10)
    }
  }
}

alias -l SetRGBToColorAndHex {
  var %num
  if ( $did(TB, 14, 1).text != $null ) { 
    %num = $BoundValue($did(TB, 14, 1).text, 0, 255)
    did -r TB 14
    did -a TB 14 %num
  }
  if ( $did(TB, 16, 1).text != $null ) { 
    %num = $BoundValue($did(TB, 16, 1).text, 0, 255)
    did -r TB 16
    did -a TB 16 %num
  }
  if ( $did(TB, 18, 1).text != $null ) { 
    %num = $BoundValue($did(TB, 18, 1).text, 0, 255)
    did -r TB 18
    did -a TB 18 %num
  }

  var %r $base($BoundValue($did(TB, 14, 1).text, 0, 255), 10, 16)
  var %g $base($BoundValue($did(TB, 16, 1).text, 0, 255), 10, 16)
  var %b $base($BoundValue($did(TB, 18, 1).text, 0, 255), 10, 16)

  if ( $len(%r) = 1 ) { %r = 0 $+ %r }
  if ( $len(%g) = 1 ) { %g = 0 $+ %g }
  if ( $len(%b) = 1 ) { %b = 0 $+ %b }

  set %whiteboard.color $base(%b $+ %g $+ %r, 16, 10)

  did -r TB 20
  did -a TB 20 %r $+ %g $+ %b
}

alias -l InitToolBox {
  did -r TB 8
  if ( %whiteboard.tool == 1 ) {
    did -b TB 8
    did -c TB 2
  } 
  else if ( %whiteboard.tool == 2 ) {
    did -b TB 8
    did -c TB 3
  } 
  else if ( %whiteboard.tool == 3 ) {
    did -b TB 8
    did -c TB 4
  }
  else if ( %whiteboard.tool == 4 || %whiteboard.tool == 5 || %whiteboard.tool == 6 || %whiteboard.tool == 7 ) {
    did -c TB 5
    did -e TB 8   
    did -a TB 8 Regular
    did -a TB 8 Filled
    did -a TB 8 Rounded
    did -a TB 8 Dotted
    if ( %whiteboard.tool == 4 ) {
      did -c TB 8 1
    } 
    else if ( %whiteboard.tool == 5 ) {
      did -c TB 8 2
    }
    else if ( %whiteboard.tool == 6 ) {
      did -c TB 8 3
    }
    else if ( %whiteboard.tool == 7 ) {
      did -c TB 8 4
    }
  }
  else if ( %whiteboard.tool == 8 || %whiteboard.tool == 9 ) {
    did -c TB 6
    did -e TB 8   
    did -a TB 8 Regular
    did -a TB 8 Filled
    if ( %whiteboard.tool == 8 ) {
      did -c TB 8 1
    } 
    else if ( %whiteboard.tool == 9 ) {
      did -c TB 8 2
    }
  }
  else if ( %whiteboard.tool == 10 ) {
    did -c TB 7
  }

  if ( $pos($chan(%whiteboard.channel).mode,m) > 0 ) {
    did -c TB 22
  } 
  else {
    did -u TB 22
  }

  if ( $me isop %whiteboard.channel ) {
    did -e TB 22
    did -e TB 25
  }
  else {
    did -b TB 22
    did -b TB 25
  }

  var %hex $base(%whiteboard.color, 10, 16)
  %hex = $str(0,$calc(6 - $len(%hex))) $+ %hex

  var %r $base($right(%hex, 2), 16, 10)
  var %g $base($mid(%hex, 3,2), 16, 10)
  var %b $base($left(%hex, 2), 16, 10)

  echo ... %whiteboard.color %hex %r %g %b

  did -r TB 14
  did -r TB 16
  did -r TB 18
  did -a TB 14 %r
  did -a TB 16 %g
  did -a TB 18 %b

  SetRGBToColorAndHex

  did -r TB 10
  did -a TB 10 %whiteboard.size
  did -c TB 11 %whiteboard.size
}

;#####################################################################
;#################### Channel Events             #####################
;#####################################################################

on 1:TEXT:.*:#: {
  if ( $chan == %whiteboard.channel ) {
    var %i 1
    while ($gettok($1-,%i,46) != $null) {
      HandleCommand $nick $ifmatch
      inc %i
    }
  }
}

on 1:TEXT:*clear:#: {
  if ( $chan == %whiteboard.channel ) {
    if ( $nick isop %whiteboard.channel ) {
      drawrect -f @whiteboard $RGB(255,255,255) 1 0 0 10000 10000
      drawfill -rs @whiteboard $RGB(255,255,255) $getdot(@whiteboard,1,1) 1 1
    }
  }
}

on 1:JOIN:#: {
  if ( $nick == $me && %whiteboard.channel == $null && $chan == #whiteboard ) {
    StartWhiteboard 
  }
  else if ( $chan == %whiteboard.channel ) {
    SendSettings 
  }
}

on 1:PART:%whiteboard.channel: {
  if ( $chan == %whiteboard.channel ) {
    if ( $nick == $me ) {
      StopWhiteBoard 
    }
  }
}

on 1:MODE:#: {
  if ( $chan == %whiteboard.channel ) {
    InitToolBox
  }
}

on 1:OP:#: {
  if ( $chan == %whiteboard.channel ) {
    InitToolBox
  }
}

on 1:DEOP:#: {
  if ( $chan == %whiteboard.channel ) {
    InitToolBox
  }
}

;#####################################################################
;#################### Paint Window               #####################
;#####################################################################

menu  @whiteboard {
  ;on mouse move
  mouse: {
    if ( %whiteboard.mousedown && %whiteboard.tool == 2 && %whiteboard.smoothadd ) {
      AddToBuffer $base($mouse.x,10,36) $base($mouse.y,10,36)
      drawline -r @whiteboard %whiteboard.color %whiteboard.size %whiteboard.lastx %whiteboard.lasty $mouse.x $mouse.y
      %whiteboard.lastx = $mouse.x
      %whiteboard.lasty = $mouse.y
    }
  }

  ;on mouse down
  sclick: {
    set %whiteboard.mousedown $true

    if ( %whiteboard.tool == 1 ) {
      AddToBuffer $base($mouse.x,10,36) $base($mouse.y,10,36)
      drawdot -r @whiteboard %whiteboard.color %whiteboard.size $mouse.x $mouse.y
    }
    else if ( %whiteboard.tool == 2 ) {
      var %tempsize %whiteboard.size
      set %whiteboard.tool 1
      set %whiteboard.size 1
      SendSettings
      AddToBuffer $base($mouse.x,10,36) $base($mouse.y,10,36)
      set %whiteboard.tool 2
      set %whiteboard.size %tempsize
      SendSettings
    }
    else if ( %whiteboard.tool == 3 ) {
      AddToBuffer $base($mouse.x,10,36) $base($mouse.y,10,36)
      drawline -r @whiteboard %whiteboard.color %whiteboard.size %whiteboard.lastx %whiteboard.lasty $mouse.x $mouse.y
    }
    %whiteboard.lastx = $mouse.x
    %whiteboard.lasty = $mouse.y
  }

  ;on mouse up
  uclick: {
    set %whiteboard.mousedown $false
  }

  ;one double click
  lbclick: {

  }
}

;#####################################################################
;#################### Dialog stuff and the like. #####################
;#####################################################################

dialog -l ToolBox {
  title "White Board 2.0"
  size -1 -1 128 104
  option dbu notheme

  box "Active Tool", 1, 3 1 61 100
  radio "Dot", 2, 6 9 55 10, push
  radio "Line (Be Careful!)", 3, 6 22 55 10, push
  radio "Safe Line", 4, 6 35 55 10, push
  radio "Retangle", 5, 6 48 55 10, push
  radio "Ellipse", 6, 6 61 55 10, push
  radio "Bucket", 7, 6 74 55 10, push
  combo 8, 6 87 55 11, drop

  box "Tool Size", 9, 66 1 61 31
  edit "1", 10, 69 9 55 10
  scroll "", 11, 69 20 55 8, range 1 100 horizontal bottom

  box "Tool Color", 12, 66 34 61 56
  text "Red:", 13, 69 44 12 8
  edit "0", 14, 87 42 37 10
  text "Green:", 15, 69 56 16 8
  edit "0", 16, 87 54 37 10
  text "Blue:", 17, 69 68 16 8
  edit "0",18, 87 66 37 10
  text "Hex:", 19, 69 79 16 8
  edit "000000", 20, 87 77 37 10

  menu "Options", 21
  item "Moderate Channel", 22, 21

  menu "Clear Board", 23, 21
  item "Clear Yours Only", 24, 23
  item "Clear All", 25, 23
  item "Exit Whiteboard", 26, 21

  menu "Help", 27
  item "Haha, fat chance.", 28, 27
  item "What kind of dork", 29, 27
  item "needs help with a", 30, 27
  item "simple drawing", 31, 27
  item "script?", 32, 27
}

;handles Init dialog
on 1:dialog:TB:init:0: {
  InitToolBox
}

;handles Close dialog
on 1:dialog:TB:close:0: {
  StopWhiteboard
}

;handles Dot radio
on 1:dialog:TB:sclick:2: {
  %whiteboard.tool = 1
  InitToolBox
  SendSettings
}

;handles Line radio
on 1:dialog:TB:sclick:3: {
  %whiteboard.tool = 2
  InitToolBox
  SendSettings
}

;handles Safe Line radio
on 1:dialog:TB:sclick:4: {
  %whiteboard.tool = 3
  InitToolBox
  SendSettings
}

;handles Rectangle radio
on 1:dialog:TB:sclick:5: {
  %whiteboard.tool = 4
  InitToolBox
  SendSettings
}

;handles Rectangle radio
on 1:dialog:TB:sclick:6: {
  %whiteboard.tool = 8
  InitToolBox
  SendSettings
}

;handles Rectangle radio
on 1:dialog:TB:sclick:7: {
  %whiteboard.tool = 10
  InitToolBox
  SendSettings
}

;handles Drop Down
on 1:dialog:TB:sclick:8: {
  if ( %whiteboard.tool == 4 || %whiteboard.tool == 5 || %whiteboard.tool == 6 || %whiteboard.tool == 7 ) {
    if ( if $did(TB, 8, 1).sel == 1 ) {
      %whiteboard.tool = 4
    }
    else if ( $did(TB, 8, 1).sel == 2 ) {
      %whiteboard.tool = 5
    }
    else if ( $did(TB, 8, 1).sel == 3 ) {
      %whiteboard.tool = 6
    }
    else if ( $did(TB, 8, 1).sel == 4 ) {
      %whiteboard.tool = 7
    }
  } 
  else if ( %whiteboard.tool == 8 || %whiteboard.tool == 9 ) {
    if ( if $did(TB, 8, 1).sel == 1 ) {
      %whiteboard.tool = 8
    }
    else if ( $did(TB, 8, 1).sel == 2 ) {
      %whiteboard.tool = 9
    }
  }
  SendSettings
}

;handles txtSize
on 1:dialog:TB:edit:10: {
  var %num
  if ( $did(TB, 10, 1).text != $null ) { 
    %num = $BoundValue($did(TB, 10, 1).text, 1, 100)
    did -r TB 10
    did -a TB 10 %num
  }
  set %whiteboard.size $BoundValue($did(TB, 10, 1).text, 1, 100)
  did -c TB 11 %whiteboard.size
  .timerUpdateSize -m 1 500 /SendSettings
}

;handles the scroll bar
on 1:dialog:TB:scroll:11: {
  set %whiteboard.size $did(TB, 11).sel
  did -r TB 10
  did -a TB 10 $did(TB, 11).sel
  .timerUpdateSize -m 1 500 /SendSettings
}

;handles txtRed
on 1:dialog:TB:edit:14: {
  SetRGBToColorAndHex
  .timerUpdateSize -m 1 1500 /SendSettings
}

;handles txtGreen
on 1:dialog:TB:edit:16: {
  SetRGBToColorAndHex
  .timerUpdateSize -m 1 1500 /SendSettings
}

;handles txtBlue
on 1:dialog:TB:edit:18: {
  SetRGBToColorAndHex
  .timerUpdateSize 1 1500 /SendSettings
}

;handles txtHex
on 1:dialog:TB:edit:20: {
  var %hex = $did(TB, 20, 1).text
  if ( $len(%hex) == 6 || ( $len(%hex) == 7 && $left(%hex, 1) == $chr(35) ) ) {
    if ( $left(%hex, 1) == $chr(35) ) {
      %hex = $right(%hex, 6)
    }

    var %r = $base($left(%hex, 2), 16, 10)
    var %g = $base($mid(%hex, 3,2), 16, 10)
    var %b = $base($right(%hex, 2), 16, 10)

    did -r TB 14
    did -r TB 16
    did -r TB 18
    did -a TB 14 %r
    did -a TB 16 %g
    did -a TB 18 %b

    set %whiteboard.color $RGB(%r, %g, %b)

    .timerUpdateSize -m 1 1500 /SendSettings
  }
}

;handles Clear Your Only menu item
on 1:dialog:TB:menu:24: {
  drawrect -f @whiteboard $RGB(255,255,255) 1 0 0 10000 10000
  drawfill -rs @whiteboard $RGB(255,255,255) $getdot(@whiteboard,1,1) 1 1
}

;handles Clear Your Only menu item
on 1:dialog:TB:menu:25: {
  msg %whiteboard.channel *clear
  drawrect -f @whiteboard $RGB(255,255,255) 1 0 0 10000 10000
  drawfill -rs @whiteboard $RGB(255,255,255) $getdot(@whiteboard,1,1) 1 1
}

;handles Exit menu item
on 1:dialog:TB:menu:26: {
  StopWhiteboard
}

Comments
 
All content Copyright © 2004 - 2008 UtoNet IRC Network
UtoNet is sponsored and hosted by Datinix Systems