mPaint — File Browser

mPaintv1.1 / mPaintv1.1 / mPaint / mpaint.mrc

mpaint.mrc — 34.56 KB — Download this file

alias mpversion return 1.1

;mPaint 1.1 by fnt

;www.mircscripts.org

;skins
alias mpbut {
  if (%mpskin) var %x = $shortfn(%mpskin)
  else var %x = $shortfn($scriptdirskins\original.mpaint)
  return $mpfile(skins\ $+ $remove($read(%x,1),;))
}
alias mpcolor {
  if (%mpskin) var %x = $shortfn(%mpskin)
  else var %x = $shortfn($scriptdirskins\original.mpaint)
  return $remove($read(%x,2),;)
}
alias -l mp-skin {
  if (%mpskin) var %x = $shortfn(%mpskin)
  else var %x = $shortfn($scriptdirskins\original.mpaint)
  .load -rs %x
  $1-
  .unload -rs %x
}

;language
alias mplan {
  if (%mplang == por) {
    goto $1
    :a | return mPaint versão $mpversion por fnt
    :b | return Novas versões em www.mircscripts.org
    :c | return Sobre...
    :1 | return A area selecionada contém
    :2 | return pontos. Isso pode demorar alguns segundos, deseja continuar?
    :3 | return CARREGANDO
    :4 | return &Inserir Texto
    :5 | return &Sombra
    :6 | return &Cancelar
    :7 | return Use a tecla [+] ou [-] para mudar o tamanho
    :s | return segs
    :8 | return Tamanho do pincel
    :9 | return A imagem selecionada é maior do que a tela do mPaint, deseja ajustá-la?
    :10 | return &Idiomas:
    :11 | return &Temas:
    :12 | return Configuração
    :13 | return &Servidor
    :14 | return &Cliente
    :15 | return &Pintar
    :16 | return &Sobre
    :17 | return &Negrito
    :18 | return &Sublinhado
    :t | return Transparência
    :ia | return Caminho da imagem:
    :dw | return Importando
    :ie | return Ocorreu um erro:
    :rc | return Recebido:
    :dc | return Download completo!
    :im | return &Importar
    :ff | return Do &Arquivo...
    :fw | return Da &Internet...
  }
  else {
    goto $1
    :a | return mPaint version $mpversion by fnt
    :b | return New versions at www.mircscripts.org
    :c | return About...
    :1 | return The selected area contains
    :2 | return points. This can delay some seconds. Really wants to continue?
    :3 | return LOADING...
    :4 | return &Insert Text
    :5 | return &Drop Shadow
    :6 | return &Cancel
    :7 | return Use the button [+] or [-] to change the size
    :s | return secs
    :8 | return Pencil size
    :9 | return The selected image is greater that the screen of mPaint, wants to adjust?
    :10 | return &Languages:
    :11 | return &Skins:
    :12 | return Configuration
    :13 | return &Server
    :14 | return &Client
    :15 | return &Paint
    :16 | return &About
    :17 | return &Bold
    :18 | return &Underline
    :t | return Transparency
    :ia | return Image address:
    :dw | return Downloading
    :ie | return Import error:
    :rc | return Received:
    :dc | return Download Completed!
    :im | return &Import
    :ff | return From &File...
    :fw | return From &Web...
  }
}

;identifiers
alias -l mpfile return $shortfn($scriptdir $+ $1-)
alias -l mpr return $rgb($1,$1,$1)
alias -l mppal return $mpfile(paleta.png)

;events
on *:close:@mPaint:mp-close
on *:keydown:@mPaint:107,109:{
  if ($keyval = 107) && (%mp.size < 10) inc %mp.size
  if ($keyval = 109) && (%mp.size > 1) dec %mp.size
  if ($window(@mp-bor) && (%mp.func == bor)) {
    drawcopy @mp-bor 0 0 450 350 @parea 0 0
    drawrect -rf @parea $getdot(@mpaint,38,186) 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
      $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
    drawrect -ri @parea 0 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
      $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
    mp-copy
  }
}
on *:load:echo $colour(info) -a *** mPaint $mpversion by fnt [use /mpaint]

;aliases
alias mpaint {
  if (!%mp.size) set %mp.size 2
  window -Ckpdhf +btn @mPaint 0 0 506 382 $mpfile(mpico.ico)
  drawfill -r @mpaint $mpcolor 1 1 1
  drawtext -or @mpaint $rgb(250,250,250) "comic" 16 201 186 $mplan(3)
  drawtext -or @mpaint $rgb(150,150,150) "comic" 16 200 185 $mplan(3)
  window -fhp +d @mp2 0 0 506 382
  window -fhp +d @mp3 0 0 506 382
  drawfill -r @mp2 $mpcolor 1 1 1
  window -fhp +d @parea 0 0 450 350
  drawfill -r @parea $rgb(255,255,255) 1 1 1
  mp-resupdraw
  drawrect -r @mp2 $mpr(192) 1 258 3 1 20
  drawrect -r @mp2 $mpr(250) 1 259 3 1 20
  set %mp.func sel
  set %mp.mode 1
  mp-megadraw
  drawrect -r @mp2 $mpr(192) 1 2 147 45 1
  drawrect -r @mp2 $mpr(250) 1 2 148 45 1
  drawrect -r @mp2 $mpr(192) 1 2 167 45 1
  drawrect -r @mp2 $mpr(250) 1 2 168 45 1
  drawbutton @mp2 2 172 22 22 c 0
  drawbutton @mp2 25 172 22 22 c 16777215
  drawrect -rf @mp2 $mpr(100) 1 4 198 42 155
  drawrect -rf @mp2 $mpr(240) 1 4 198 41 154
  drawbutton @mp2 2 357 22 22 N 27
  drawpic -s @mp2 5 199 40 153 $mppal
  drawrect -r @mp2 $mpr(192) 1 2 26 45 1
  drawrect -r @mp2 $mpr(250) 1 2 27 45 1
  drawrect -r @mp2 $mpr(192) 1 429 3 1 20
  drawrect -r @mp2 $mpr(250) 1 430 3 1 20
  drawrect -r @mp2 $mpr(192) 1 50 26 452 352
  mp-copy
}
;tbit.dll by Oliver
alias -l mp-drawtransp {
  .window -phf @unlikely_window_name -1 -1 $7 $8
  .drawcopy $1 $2 $3 $7 $8 @unlikely_window_name 0 0
  .drawsave -b24 @unlikely_window_name temp1.bmp
  .drawcopy $4 $5 $6 $7 $8 @unlikely_window_name 0 0
  .drawsave -b24 @unlikely_window_name temp2.bmp
  .window -c @unlikely_window_name
  var %s = $dll($mpfile(tblit.dll), tblit, temp1.bmp temp2.bmp $9)
  .drawpic $1 $2 $3 tblit.bmp
  .remove temp1.bmp
  .remove temp2.bmp
  .remove tblit.bmp
}
alias -l mp-megadraw {
  if (%mpskin) var %x = $shortfn(%mpskin)
  else var %x = $shortfn($scriptdirskins\original.mpaint)
  .load -rs %x
  var %a = %mp.func, %f = MPDRAWBUTTON
  ;sel
  %f @mp2 2 30 22 22 $iif(%a = sel,n,N) 16
  ;pen
  %f @mp2 25 30 22 22 $iif(%a = pen,n,N) 17
  ;bor
  %f @mp2 2 53 22 22 $iif(%a = bor,n,N) 18
  ;tin
  %f @mp2 25 53 22 22 $iif(%a = tin,n,N) 19
  ;spr
  %f @mp2 2 76 22 22 $iif(%a = spr,n,N) 20
  ;tex
  %f @mp2 25 76 22 22 $iif(%a = tex,n,N) 21
  ;lin
  %f @mp2 2 99 22 22 $iif(%a = lin,n,N) 22
  ;qua
  %f @mp2 25 99 22 22 $iif(%a = qua,n,N) 23
  ;are
  %f @mp2 2 122 22 22 $iif(%a = are,n,N) 24
  ;cir
  %f @mp2 25 122 22 22 $iif(%a = cir,n,N) 25
  ;getcolor
  %f @mp2 25 357 22 22 $iif(%a = getcolor,n,N) 26
  %f @mp2 2 150 14 14 $iif(%mp.mode = 1,n,N) 0
  %f @mp2 17 150 14 14 $iif(%mp.mode = 2,n,N) 1
  %f @mp2 32 150 14 14 $iif(%mp.mode = 3,n,N) 2
  .unload -rs %x
}
alias -l mp-resupdraw {
  if (%mpskin) var %x = $shortfn(%mpskin)
  else var %x = $shortfn($scriptdirskins\original.mpaint)
  .load -rs %x
  var %f = MPDRAWBUTTON
  ;mais contraste
  ;mp-effect -b @Parea $rgb(0,0,0) 0 0 450 350 20
  %f @mp2 2 2 22 22 N 0
  ;menos contraste
  ;mp-effect -b @Parea $rgb(255,255,255) 0 0 450 350 20 
  %f @mp2 25 2 22 22 N 1
  ;inserir mascara
  ;mp-effect -m @Parea $rgb(0,0,0) 0 0 450 350 50
  %f @mp2 48 2 22 22 N 2
  ;preto e branco
  ;mp-effect -p @Parea 0 0 450 350
  %f @mp2 71 2 22 22 N 3
  ;pencil
  ;mp-effect -l @Parea 0 0 450 350
  %f @mp2 94 2 22 22 N 4
  ;inverter
  ;mp-effect -i @Parea 0 0 450 350
  %f @mp2 117 2 22 22 N 5
  ;inverção colorida
  ;mp-effect -n @Parea 0 0 450 350 $$rgb($dll($mpfile(color.dll),Color,65535))
  %f @mp2 140 2 22 22 N 6
  ;inverter na horizontal
  ;mp-effect -h @Parea 10 10 430 330
  %f @mp2 163 2 22 22 N 7
  ;inverter na vertical
  ;mp-effect -v @Parea 10 10 430 330
  %f @mp2 186 2 22 22 N 8
  ;girar 90º
  ;mp-effect -r @Parea 0 0 450 350 $rgb(255,255,255)
  %f @mp2 209 2 22 22 N 9
  ;substituir cores
  ;mp-effect -t @Parea 00 00 450 350 $rgb(255,0,0) $rgb(255,255,255)
  %f @mp2 232 2 22 22 N 10
  ;desfazer
  %f @mp2 263 2 22 22 N 15
  ;importar
  %f @mp2 403 2 22 22 N 12
  ;novo
  %f @mp2 434 2 22 22 N 14
  ;abrir
  %f @mp2 457 2 22 22 N 13
  ;salvar
  %f @mp2 480 2 22 22 N 11
  .unload -rs %x
}
alias -l mp-stfunc {
  if ($1 == spr) {
    var %w = 1
    while ($calc($mouse.y -12+ %w) <= $mouse.y) {
      var %x = $calc($mouse.x - %w)
      while (%x <= $calc($mouse.x + %w)) {
        $iif($r(1,2) = 1,drawdot -r @parea $getdot(@mpaint,12,186) 1 $calc(%x -51) $calc($mouse.y -12 + %w -27))
        inc %x 2
      }
      inc %w 2
    }
    var %w = 1
    while ($calc($mouse.y + %w) <= $calc($mouse.y +12)) {
      var %x = $calc($mouse.x - %w)
      while (%x <= $calc($mouse.x + %w)) {
        $iif($r(1,2) = 1,drawdot -r @parea $getdot(@mpaint,12,186) 1 $calc(%x -51) $calc($mouse.y + $calc(12- %w) -27))
        inc %x 2
      }
      inc %w 2
    }
    mp-copy
  }
  elseif ($1 == pen) {
    if (%mp.pen.mx) {
      if ($mouse.x > %mp.pen.mx) var %x = dir, %ix = %mp.pen.mx, %fx = $mouse.x
      else var %x = esq, %ix = $mouse.x, %fx = %mp.pen.mx
      if ($mouse.y > %mp.pen.my) var %y = bai, %iy = %mp.pen.my, %fy = $mouse.y
      else var %y = cim, %iy = $mouse.y, %fy = %mp.pen.my
      var %a = $calc($iif(%mp.pen.mx > $mouse.x,%mp.pen.mx - $mouse.x,$mouse.x - %mp.pen.mx))
      var %b = $calc($iif(%mp.pen.my > $mouse.y,%mp.pen.my - $mouse.y,$mouse.y - %mp.pen.my))
      if (%a > %b) {
        if (%x == dir) {
          if (%y = bai) var %iiy = %iy, %iif = inc
          else var %iiy = %fy, %iif = dec
        }
        else {
          if (%y = bai) var %iiy = %fy, %iif = dec
          else var %iiy = %iy, %iif = inc
        }
        var %w = $calc(%b / %a)
        while (%ix < %fx) {
          drawdot -r @mp-pen $getdot(@mpaint,12,186) %mp.size $calc(%ix - 51) $calc(%iiy - 27)
          inc %ix
          %iif %iiy %w
        }
      }
      else {
        if (%y == cim) {
          if (%x = dir) var %iix = %fx, %iif = dec
          else var %iix = %ix, %iif = inc
        }
        else {      
          if (%x = esq) var %iix = %fx, %iif = dec
          else var %iix = %ix, %iif = inc
        }
        var %w = $calc(%a / %b)
        while (%iy < %fy) {
          drawdot -r @mp-pen $getdot(@mpaint,12,186) %mp.size $calc(%iix - 51) $calc(%iy - 27)
          inc %iy
          %iif %iix %w
        }
      }
    }
    drawdot -r @mp-pen $getdot(@mpaint,12,186) %mp.size $calc($mouse.x - 51) $calc($mouse.y - 27)
    drawcopy -t @mp-pen $calc($getdot(@mpaint,38,186) +10) 0 0 450 350 @parea 0 0
    drawcopy @parea 0 0 450 350 @mp3 51 27
    drawcopy @mp3 0 0 506 382 @mpaint 0 0
    set %mp.pen.mx $mouse.x
    set %mp.pen.my $mouse.y
  }
  else {
    if ($dialog(mptext)) && (%mp.func != tex) dialog -c mptext mptext
    if ($window(@mp-pen)) window -c @mp-pen
    if (%mp.bor) unset %mp.bor
    if (%mp.spr) unset %mp.spr
    if (%mp.line.xy) unset %mp.line.xy
    if (%mp.qua.x) { unset %mp.qua.x | unset %mp.qua.y }
    if (%mp.are.x) { unset %mp.are.x | unset %mp.are.y }
  }
}
alias -l mp-close {
  if ($window(@mp-effect)) window -c @mp-effect
  if ($window(@mp-effect2)) window -c @mp-effect2
  if ($1 == -e) return
  if ($window(@mpaint)) window -c @mPaint
  if ($window(@mp2)) window -c @mP2
  if ($window(@mp3)) window -c @mP3
  if ($window(@parea)) window -c @parea
  if ($window(@mp-redo)) window -c @mp-redo
  if ($window(@mp-pen)) window -c @mp-pen
  if ($window(@mp-bor)) window -c @mp-bor
  if ($window(@mp-import)) window -c @mp-import
  if ($dialog(mptext)) dialog -c mptext mptext
  unset %mp.*
}
alias -l drawbutton { mp-skin MPDRAWBUTTON $1- }
alias -l mp-copy {
  drawcopy @mp2 0 0 506 382 @mp3 0 0
  drawcopy @parea 0 0 450 350 @mp3 51 27
  drawcopy @mp3 0 0 506 382 @mpaint 0 0
  if (%mp.selection) unset %mp.selection
}
alias -l mp-redo { if (!$window(@mp-redo)) window -fhp +d @mp-redo 0 0 450 350 | drawcopy @parea 0 0 450 350 @mp-redo 0 0 450 350 }
alias -l mp-plusinfo { titlebar @mPaint - $mplan(7) | .timer 1 3 if ($window(@mpaint)) { .titlebar @mpaint } }

;menus
menu @mpaint {
  mouse:{
    if ($window(@mp-import)) {
      var %w = $window(@mp-import).bw, %h = $window(@mp-import).bh
      drawcopy @mp-redo 0 0 450 350 @parea 0 0
      drawcopy @mp-import 0 0 %w %h @parea $calc(($mouse.x -51)- (%w /2)) $calc(($mouse.y -27)- (%h /2)) %w %h
      mp-copy
    }
    elseif ($window(@mp-pen)) && (%mp.func == pen) {
      mp-stfunc pen
    }
    elseif ($window(@mp-bor) && (%mp.func == bor)) {
      drawcopy @mp-bor 0 0 450 350 @parea 0 0
      drawrect -rf @parea $getdot(@mpaint,38,186) 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
        $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
      drawrect -ri @parea 0 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
        $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
      if (%mp.bor) {
        drawrect -rf @mp-bor $getdot(@mpaint,38,186) 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
          $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
      }
      mp-copy
    }
    elseif (%mp.spr) && (%mp.func == spr) mp-stfunc spr
    elseif (%mp.line.xy) && ($window(@mp-pen)) && (%mp.func == lin) {
      drawcopy @mp-pen 0 0 450 350 @parea 0 0
      drawline -r @parea $getdot(@mpaint,12,186) %mp.size %mp.line.xy $calc($mouse.x -51) $calc($mouse.y -27)
      mp-copy
    }
    elseif (%mp.qua.x) && ($window(@mp-pen)) && (%mp.func == qua) {
      drawcopy @mp-pen 0 0 450 350 @parea 0 0
      if (%mp.mode == 2) || (%mp.mode == 3) {
        drawrect -rf @parea $getdot(@mpaint,38,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      if (%mp.mode == 1) || (%mp.mode == 2) {
        drawrect -r @parea $getdot(@mpaint,12,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      mp-copy
    }
    elseif (%mp.qua.x) && ($window(@mp-pen)) && (%mp.func == are) {
      drawcopy @mp-pen 0 0 450 350 @parea 0 0
      if (%mp.mode == 2) || (%mp.mode == 3) {
        drawrect -rfd @parea $getdot(@mpaint,38,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      if (%mp.mode == 1) || (%mp.mode == 2) {
        drawrect -rd @parea $getdot(@mpaint,12,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      mp-copy
    }
    elseif (%mp.qua.x) && ($window(@mp-pen)) && (%mp.func == cir) {
      drawcopy @mp-pen 0 0 450 350 @parea 0 0
      if (%mp.mode == 2) || (%mp.mode == 3) {
        drawrect -rfe @parea $getdot(@mpaint,38,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      if (%mp.mode == 1) || (%mp.mode == 2) {
        drawrect -re @parea $getdot(@mpaint,12,186) %mp.size %mp.qua.x %mp.qua.y $calc(($mouse.x -51) - %mp.qua.x) $calc(($mouse.y -27) - %mp.qua.y)
      }
      mp-copy
    }
  }
  drop:{
    if ($mouse.x > 51) && ($mouse.y > 27) && ($mouse.x < 501) && ($mouse.y < 377) {
      if (%mp.func == sel) && (%mp.clickx) && (%mp.clickx != $mouse.x) && (%mp.clicky != $mouse.y) {
        set %mp.click2x $mouse.x
        set %mp.click2y $mouse.y
        drawrect -ri @mpaint $rgb(0,0,0) 1 %mp.clickx %mp.clicky $calc(%mp.click2x - %mp.clickx) $calc(%mp.click2y - %mp.clicky)

        if (%mp.clickx > %mp.click2x) {
          var %a = %mp.clickx
          set %mp.clickx %mp.click2x
          set %mp.click2x %a
        }
        if (%mp.clicky > %mp.click2y) {
          var %a = %mp.clicky
          set %mp.clicky %mp.click2y
          set %mp.click2y %a
        }
        set %mp.selection $calc(%mp.clickx -51) $calc(%mp.clicky -27) $calc(%mp.click2x - %mp.clickx) $calc(%mp.click2y - %mp.clicky)
      }
      else { unset %mp.clickx | unset %mp.clicky }
    }
  }
  sclick:{
    ;change color
    if ((%mp.func == getcolor)) || (($mouse.x > 5) && ($mouse.y > 200) && ($mouse.x < 46) && ($mouse.y < 353)) {
      drawbutton @mp2 2 172 22 22 c $getdot(@mpaint,$mouse.x,$mouse.y)
      if (%mp.func == getcolor) set %mp.func pen
      goto end
    }
    if ($window(@mp-import)) {
      window -c @mp-import
    }
    elseif ($mouse.x > 50) && ($mouse.y > 26) && ($mouse.x < 502) && ($mouse.y < 378) {
      set %mp.clickx $mouse.x | set %mp.clicky $mouse.y
      if (%mp.func == pen) {
        mp-redo
        unset %mp.pen.*
        window -fhp +d @mp-pen 0 0 450 350
        drawfill -r @mp-pen $calc($getdot(@mpaint,38,186) +10) 1 1 1
        mp-stfunc pen
      }
      elseif ($window(@mp-bor) && (%mp.func == bor)) {
        drawcopy @mp-bor 0 0 450 350 @parea 0 0
        mp-redo
        drawrect -rf @mp-bor $getdot(@mpaint,38,186) 1 $calc($mouse.x -51- (%mp.size *10/2)) $&
          $calc($mouse.y -27- (%mp.size *10/2)) $calc(%mp.size * 10) $calc(%mp.size * 10)
        drawcopy @mp-bor 0 0 450 350 @parea 0 0
        set %mp.bor 1
      }
      elseif (%mp.func == tin) {
        mp-redo
        drawfill -rs @parea $getdot(@mpaint,12,186) $getdot(@mpaint,$mouse.x,$mouse.y) $&
          $calc($mouse.x -51) $calc($mouse.y -27)
      }
      elseif (%mp.func == spr) {
        mp-redo
        mp-stfunc spr
        set %mp.spr 1
      }
      elseif (%mp.func == tex) {
        mp-redo
        set %mp.text.xy $calc($mouse.x -51) $calc($mouse.y -27)
        if (!$dialog(mptext)) dialog -dm mptext mptext
        else dialog -v mptext mptext
      }
      elseif (%mp.func == lin) {
        if (!%mp.line.xy) {
          mp-redo
          window -fhp +d @mp-pen 0 0 450 350
          drawcopy @parea 0 0 450 350 @mp-pen 0 0
          set %mp.line.xy $calc($mouse.x -51) $calc($mouse.y -27)
        }
      }
      elseif (%mp.func == qua) || (%mp.func == are) || (%mp.func == cir) {
        mp-redo
        set %mp.qua.x $calc($mouse.x -51)
        set %mp.qua.y $calc($mouse.y -27)
        window -fhp +d @mp-pen 0 0 450 350
        drawcopy @parea 0 0 450 350 @mp-pen 0 0
      }
      goto end
    }
    if ($window(@mp-bor)) { drawcopy @mp-bor 0 0 450 350 @parea 0 0 | window -c @mp-bor }
    ;botões laterais
    if ($mouse.x > 27) && ($mouse.y > 360) && ($mouse.x < 46) && ($mouse.y < 379) set %mp.func getcolor
    elseif ($mouse.x > 4) && ($mouse.y > 33) && ($mouse.x < 23) && ($mouse.y < 52) set %mp.func sel
    elseif ($mouse.x > 27) && ($mouse.y > 33) && ($mouse.x < 46) && ($mouse.y < 52) {
      mp-plusinfo 
      set %mp.func pen
    }
    elseif ($mouse.x > 4) && ($mouse.y > 55) && ($mouse.x < 23) && ($mouse.y < 75) {
      mp-plusinfo
      set %mp.func bor
      if (!$window(@mp-bor)) window -fhp +d @mp-bor 0 0 450 350
      drawcopy @parea 0 0 450 350 @mp-bor 0 0 450 350
    }
    elseif ($mouse.x > 27) && ($mouse.y > 55) && ($mouse.x < 46) && ($mouse.y < 75) set %mp.func tin
    elseif ($mouse.x > 4) && ($mouse.y > 78) && ($mouse.x < 23) && ($mouse.y < 98) set %mp.func spr
    elseif ($mouse.x > 27) && ($mouse.y > 78) && ($mouse.x < 46) && ($mouse.y < 98) set %mp.func tex
    elseif ($mouse.x > 4) && ($mouse.y > 102) && ($mouse.x < 23) && ($mouse.y < 121) { mp-plusinfo | set %mp.func lin }
    elseif ($mouse.x > 27) && ($mouse.y > 102) && ($mouse.x < 46) && ($mouse.y < 121) { mp-plusinfo | set %mp.func qua }
    elseif ($mouse.x > 4) && ($mouse.y > 124) && ($mouse.x < 23) && ($mouse.y < 144) { mp-plusinfo | set %mp.func are }
    elseif ($mouse.x > 27) && ($mouse.y > 124) && ($mouse.x < 46) && ($mouse.y < 144) { mp-plusinfo | set %mp.func cir }
    elseif ($mouse.x > 4) && ($mouse.y > 360) && ($mouse.x < 23) && ($mouse.y < 379) {
      drawbutton @mpaint 2 357 22 22 n 27
      var %a = $dll($mpfile(color.dll),Color,65535)
      drawbutton @mp2 2 172 22 22 c %a
      window -a @mpaint
    }
    elseif ($mouse.x > 4) && ($mouse.y > 153) && ($mouse.x < 17) && ($mouse.y < 173) set %mp.mode 1
    elseif ($mouse.x > 18) && ($mouse.y > 153) && ($mouse.x < 33) && ($mouse.y < 173) set %mp.mode 2
    elseif ($mouse.x > 35) && ($mouse.y > 153) && ($mouse.x < 68) && ($mouse.y < 173) set %mp.mode 3
    ;barra superior
    elseif ($mouse.x > 5) && ($mouse.y > 4) && ($mouse.x < 23) && ($mouse.y < 24) {
      drawbutton @mpaint 2 2 22 22 n 0
      if (%mp.selection) mp-effect -b @Parea $rgb(0,0,0) %mp.selection 20
      else mp-effect -b @Parea $rgb(0,0,0) 0 0 450 350 20
    }
    elseif ($mouse.x > 26) && ($mouse.y > 4) && ($mouse.x < 47) && ($mouse.y < 24) {
      drawbutton @mpaint 25 2 22 22 n 1
      if (%mp.selection) mp-effect -b @Parea $rgb(255,255,255) %mp.selection 20
      else mp-effect -b @Parea $rgb(255,255,255) 0 0 450 350 20
    }
    elseif ($mouse.x > 50) && ($mouse.y > 4) && ($mouse.x < 70) && ($mouse.y < 24) {
      drawbutton @mpaint 48 2 22 22 n 2
      var %a = $dll($mpfile(color.dll),Color,65535)
      window -a @mpaint
      var %b = $input($mplan(t) (1-100):,seoqk10,@mPaint,mPaint)
      if (%b < 0) || (%b > 100) { var %b = 50 }
      if (%mp.selection) mp-effect -b @Parea %a %mp.selection %b
      else mp-effect -b @Parea %a 0 0 450 350 %b
    }
    elseif ($mouse.x > 73) && ($mouse.y > 4) && ($mouse.x < 93) && ($mouse.y < 24) {
      drawbutton @mpaint 71 2 22 22 n 3
      if (%mp.selection) mp-effect -p @Parea %mp.selection
      else mp-effect -p @Parea 0 0 450 350
    }
    elseif ($mouse.x > 97) && ($mouse.y > 4) && ($mouse.x < 116) && ($mouse.y < 24) {
      drawbutton @mpaint 94 2 22 22 n 4
      if (%mp.selection) mp-effect -l @Parea %mp.selection
      else mp-effect -l @Parea 1 1 450 350
    }
    elseif ($mouse.x > 120) && ($mouse.y > 4) && ($mouse.x < 138) && ($mouse.y < 24) {
      drawbutton @mpaint 117 2 22 22 n 5
      if (%mp.selection) mp-effect -i @Parea %mp.selection
      else mp-effect -i @Parea 0 0 450 350
    }
    elseif ($mouse.x > 142) && ($mouse.y > 4) && ($mouse.x < 162) && ($mouse.y < 24) {
      drawbutton @mpaint 140 2 22 22 n 6
      if (%mp.selection) mp-effect -n @Parea %mp.selection $$rgb($dll($mpfile(color.dll),Color,65535))
      else mp-effect -n @Parea 0 0 450 350 $$rgb($dll($mpfile(color.dll),Color,65535))
      window -a @mpaint
    }
    elseif ($mouse.x > 164) && ($mouse.y > 4) && ($mouse.x < 184) && ($mouse.y < 24) {
      drawbutton @mpaint 163 2 22 22 n 7
      if (%mp.selection) mp-effect -h @Parea %mp.selection
      else mp-effect -h @Parea 0 0 450 350
    }
    elseif ($mouse.x > 188) && ($mouse.y > 4) && ($mouse.x < 208) && ($mouse.y < 24) {
      drawbutton @mpaint 186 2 22 22 n 8
      if (%mp.selection) mp-effect -v @Parea %mp.selection
      else mp-effect -v @Parea 0 0 450 350
    }
    elseif ($mouse.x > 212) && ($mouse.y > 4) && ($mouse.x < 231) && ($mouse.y < 24) {
      drawbutton @mpaint 209 2 22 22 n 9
      if (%mp.selection) mp-effect -r @Parea %mp.selection $getdot(@mpaint,38,186)
      else mp-effect -r @Parea 0 0 450 350 $getdot(@mpaint,38,186)
    }
    elseif ($mouse.x > 235) && ($mouse.y > 4) && ($mouse.x < 254) && ($mouse.y < 24) {
      drawbutton @mpaint 232 2 22 22 n 10
      if (%mp.selection) mp-effect -t @Parea %mp.selection $getdot(@mpaint,38,186) $getdot(@mpaint,12,186)
      else mp-effect -t @Parea 0 0 450 350 $getdot(@mpaint,38,186) $getdot(@mpaint,12,186)
    }
    elseif ($mouse.x > 265) && ($mouse.y > 5) && ($mouse.x < 285) && ($mouse.y < 24) {
      if ($window(@mp-redo)) {
        drawbutton @mpaint 263 2 22 22 n 15
        window -fhp +d @mp-redo2 0 0 450 350
        drawcopy @parea 0 0 450 350 @mp-redo2 0 0 450 350
        drawcopy @mp-redo 0 0 450 350 @parea 0 0 450 350
        drawcopy @mp-redo2 0 0 450 350 @mp-redo 0 0 450 350
        window -c @mp-redo2
      }
    }
    elseif ($mouse.x > 405) && ($mouse.y > 5) && ($mouse.x < 425) && ($mouse.y < 24) {
      drawbutton @mpaint 403 2 22 22 n 12
      mp-importmenu
    }
    elseif ($mouse.x > 435) && ($mouse.y > 5) && ($mouse.x < 455) && ($mouse.y < 24) {
      drawbutton @mpaint 434 2 22 22 n 14
      clear @parea
      if ($window(@mp-redo)) window -c @mp-redo
      drawfill -r @parea $getdot(@mpaint,38,186) 1 1 1
      unset %mp.open
    }
    if ($mouse.x > 458) && ($mouse.y > 4) && ($mouse.x < 478) && ($mouse.y < 24) {
      drawbutton @mpaint 457 2 22 22 n 13
      set %mp.open $sfile($mircdir*.bmp,mPaint)
      if (%mp.open) && ($exists(%mp.open)) {
        clear @parea 
        drawpic @parea 0 0 " $+ %mp.open $+ "
      }
      mp-copy
    }
    if ($mouse.x > 482) && ($mouse.y > 6) && ($mouse.x < 502) && ($mouse.y < 24) {
      drawbutton @mpaint 480 2 22 22 n 11
      var %mp.save = $sfile($iif(%mp.open,%mp.open,$mircdir*.bmp),mPaint)
      if (%mp.save) {
        if ($right(%mp.save,3) == jpg) { drawsave -q100 @parea " $+ %mp.save $+ " }
        else { drawsave -b32 @parea " $+ %mp.save $+ $iif($right(%mp.save,4) == .bmp,",.bmp") }
      }
      set %mp.open %mp.save
    }
    if (%mp.func = bor) && (!$window(@mp-bor)) {
      window -fhp +d @mp-bor 0 0 450 350
      drawcopy @parea 0 0 450 350 @mp-bor 0 0 450 350
    }
    :end
    mp-megadraw | mp-copy
    ;editbox @mpaint if ($mouse.x > $mouse.x $+ ) && ($mouse.y > $mouse.y $+ )
  }
  uclick:mp-stfunc
  leave:mp-stfunc
  rclick:{
    ;change the second color
    if ((%mp.func == getcolor)) || (($mouse.x > 5) && ($mouse.y > 200) && ($mouse.x < 46) && ($mouse.y < 353)) {
      drawbutton @mp2 25 172 22 22 c $getdot(@mpaint,$mouse.x,$mouse.y)
      if (%mp.func == getcolor) set %mp.func pen
      mp-megadraw | mp-copy
    }

    if ($mouse.x < 51) || ($mouse.y < 27) || ($mouse.x > 501) || ($mouse.y > 377) {
      elseif ($mouse.x > 4) && ($mouse.y > 360) && ($mouse.x < 23) && ($mouse.y < 379) {
        drawbutton @mpaint 2 357 22 22 n 27
        var %a = $dll($mpfile(color.dll),Color,65535)
        drawbutton @mp2 25 172 22 22 c %a
        window -a @mpaint
      }

      mp-megadraw | mp-copy
      ;editbox @mpaint $editbox(@mpaint) && ($mouse.x < $mouse.x $+ ) && ($mouse.y < $mouse.y $+ )
    }
  }
}
menu menubar {
  -
  mPaint $mpversion
  . $mplan(15) :mpaint
  ;.-
  ;.Online
  ;.. $mplan(13) :mpaint server
  ;.. $mplan(14) :mpaint client
  ;.-
  . $mplan(12) :dialog -m mpconfig mpconfig
  .-
  . $mplan(16) :dialog -m mpabout mpabout
}

;effects
alias -l mp-effect {
  set %mp.time $ctime
  mp-close -e
  window -fhp +d @mp-effect 0 0 450 350
  window -fhp +d @mp-effect2 0 0 450 350
  mp-redo
  ;replace colors
  if ($1 == -t) { drawreplace -r $2 $7 $8 $3 $4 $5 $6 }
  ;rotate
  elseif ($1 == -r) {
    drawcopy $2 $3 $4 $5 $6 @mp-effect 0 0
    drawrect -rf $2 $7 1 $3 $4 $5 $6
    drawrot -b @mp-effect $mpr(255) 90 0 0 $5 $6
    drawcopy -t @mp-effect $mpr(255) 1 0 $6 $5 $2 $3 $4
  }
  ;vertical invert
  elseif ($1 == -v) {
    var %x = 1
    while (%x < $calc($4 + $6)) { 
      drawcopy $2 $3 $calc($4 + %x -1) $5 1 @mp-effect $3 $calc($4 +( $6 - %x ))
      inc %x
    }
    drawcopy @mp-effect $3 $4 $5 $6 $2 $3 $4
  }
  ;horizontal invert
  elseif ($1 == -h) {
    var %x = 1
    while (%x < $calc($3 + $5)) {
      drawcopy $2 $calc($3 + %x -1) $4 1 $6 @mp-effect $calc($3 +( $5 - %x )) $4
      inc %x
    }
    drawcopy @mp-effect $3 $4 $5 $6 $2 $3 $4
  }
  ;mask & contrast
  elseif ($1 == -b) {
    drawcopy $2 $4 $5 $6 $7 @mp-effect 0 0
    drawfill -r @mp-effect2 $3 $3 1 1
    mp-drawtransp @mp-effect 0 0 @mp-effect2 0 0 450 350 $8
    drawcopy @mp-effect 0 0 $6 $7 $2 $4 $5
  }
  ;black and white
  elseif ($1 == -p) {
    var %y = $4, %w = 0, %p = $calc(100/ $6)
    if (%p < 1) {
      if (!$input($mplan(1) $calc($5 * $6) $mplan(2),yws,@mPaint,mPaint)) {
        return
      }
    }
    while (%y < $calc($4 + $6)) {
      var %x = $3
      while (%x <= $calc($3 + $5)) {
        var %a = $rgb($getdot($2,%x,%y))
        var %a = $round($calc(( $gettok(%a,1,44) + $gettok(%a,2,44) + $gettok(%a,3,44) )/3),0)
        drawdot -r @mp-effect $mpr(%a) 1 %x %y
        inc %x
      }
      drawcopy -t @mp-effect $rgb(255,255,255) $3 $4 $5 $6 $2 $3 $4
      mp-copy
      inc %w %p
      titlebar @mpaint $+($int(%w),%)
      inc %y
    }
    titlebar @mpaint
  }
  ;pencil
  elseif ($1 == -l) {
    set %b $input($mplan(8) (1-5):,seoqk10,@mPaint,mPaint)
    if (%b) && (%b > 0) && (%b < 6) inc %b 2
    else set %b 3
    var %y = $4, %w = 0
    while (%y < $calc($4 + $6)) {
      var %x = $3
      while (%x <= $calc($3 + $5)) {
        var %a = $getdot($2,%x,%y)
        drawdot -r @mp-effect %a %b %x %y
        inc %x %b
      }
      drawcopy -t @mp-effect $rgb(255,255,255) $3 $4 $5 $6 $2 $3 $4
      mp-copy
      inc %y %b
    }
  }
  ;invert
  elseif ($1 == -i) drawrect -rif $2 0 1 $3 $4 $5 $6
  ;colored invert
  elseif ($1 == -n) drawrect -rif $2 $7 1 $3 $4 $5 $6
  ;mp-close -e
  mp-copy
  titlebar @mpaint - $calc($ctime - %mp.time) $mplan(s)
  .timer 1 2 if ($window(@mpaint)) { .titlebar @mpaint }
}
alias -l mp-import {
  if (!$1) var %mp.import = $shortfn($sfile($mircdir*.bmp,mPaint))
  else var %mp.import $1-
  if (%mp.import) && ($exists(%mp.import)) {
    if ($pic(%mp.import).width > 450) && ($pic(%mp.import).height > 350) && ($input($mplan(9),yws,@mPaint,mPaint)) {
      if ($pic(%mp.import).width > $pic(%mp.import).height) {
      var %w = 450, %h = $int($calc((450* $pic(%mp.import).height) / $pic(%mp.import).width)) }
      else { var %h = 350, %w = $int($calc((350* $pic(%mp.import).width) / $pic(%mp.import).height)) }
    }
    else { var %h = $pic(%mp.import).height, %w = $pic(%mp.import).width }
    mp-redo
    window -fhp +d @mp-import 0 0 %w %h
    drawpic -s @mp-import 0 0 %w %h %mp.import
  }
  mp-copy
}
alias -l mp-importmenu {
  var %x = dll $mpfile(flatpopz.dll)
  %x XpStyle
  %x FlatCoords $mouse.dx $mouse.dy
  %x FlatAppend 1 > 0 > 0 > +bx > $mplan(im) > 1
  %x FlatAppend 0 > 0 > 0 > + > -
  %x FlatAppend 2 > 0 > 0 > + > $mplan(ff)  > 1
  %x FlatAppend 3 > 0 > 0 > + > $mplan(fw)  > 1
  var %y = $dll($mpfile(flatpopz.dll),Activate,$window(@mpaint).hwnd)
  dll -u $mpfile(flatpopz.dll)
  if (%y = 2) mp-import
  elseif (%y = 3) mp-webimport $input($mplan(ia),eogsq,@mpaint,mPaint,http://)
}



;dialogs
dialog mptext {
  title "mPaint"
  size -1 -1 261 206
  icon 1, 0 -2 266 40
  edit "", 2, 4 46 254 22
  combo 3, 6 76 190 100, size drop
  combo 4, 202 76 54 100, size drop editable
  check "", 5, 19 102 88 20
  check "", 9, 19 120 58 20
  check "", 10, 19 138 77 20
  button "", 6, 58 174 72 26, default
  button "", 8, 138 174 64 26, cancel
  box "", 7, -10 160 284 100
}
on *:dialog:mptext:sclick:6:{
  if ($did(2)) && ($did(4) isnum) {
    var %a = $+($iif($did(mptext,9).state == 1,),$iif($did(mptext,10).state == 1,),$did(2))
    if ($did(mptext,5).state == 1) {
      drawtext -rp @parea $getdot(@mpaint,38,186) $+(",$did(3),") $did(4) $calc($gettok(%mp.text.xy,1,32) +1) $calc($gettok(%mp.text.xy,2,32) +1) %a
      drawtext -rp @parea $getdot(@mpaint,38,186) $+(",$did(3),") $did(4) $calc($gettok(%mp.text.xy,1,32) +2) $calc($gettok(%mp.text.xy,2,32) +2) %a
    }
    drawtext -rp @parea $getdot(@mpaint,12,186) $+(",$did(3),") $did(4) %mp.text.xy %a
  }
  mp-copy
  dialog -c mptext mptext
}
on *:dialog:mptext:init:0:{
  if (!$window(@mpaint)) { dialog -c $dname $dname | halt }
  did -a mptext 6 $mplan(4)
  did -a mptext 5 $mplan(5)
  did -a mptext 8 $mplan(6)
  did -a mptext 9 $mplan(17)
  did -a mptext 10 $mplan(18)
  window -hpaf @mp-temp 0 0 266 40
  mp-skin MPDIALOGTEXTTOP
  drawsave @mp-temp $mpfile(temp.bmp)
  window -c @mp-temp
  did -g mptext 1 $mpfile(temp.bmp)
  .remove $mpfile(temp.bmp)
  var %x = did -a mptext 3
  %x Arial | %x Arial Black | %x Comic Sans MS | %x Courier | %x Courier New | %x Fixedsys
  %x Lucida Console | %x MS Sans Serif | %x Symbol | %x System | %x Tahoma | %x Terminal
  %x Times New Roman | %x Verdana | %x Webdings
  did -a mptext 4 8 | did -a mptext 4 9 | did -a mptext 4 10 | did -a mptext 4 11
  var %x = 5 | while (%x < 66) { did -a mptext 4 $calc(%x +7) | inc %x 2 }
  did -c mptext 3 1 | did -c mptext 4 5
}
dialog mpconfig {
  title "mPaint"
  size -1 -1 261 139
  icon 1, 0 -2 266 40
  button "&OK", 8, 107 107 44 26, ok
  box "", 7, -10 93 284 100
  box "", 2, 4 43 116 47
  combo 3, 11 61 102 71, size drop
  box "", 4, 127 43 131 47
  combo 5, 134 61 117 71, size drop
}
on *:dialog:mpconfig:sclick:*:{
  if ($did == 3) set %mplang $left($did(mpconfig,3),3)
  if ($did == 5) set %mpskin $scriptdirskins\ $+ $did(mpconfig,5)
}
on *:dialog:mpconfig:init:0:{
  if (!%mpskin) set %mpskin $scriptdirskins\original.mpaint
  did -a $dname 2 $mplan(10)
  did -a $dname 4 $mplan(11)
  window -hpaf @mp-temp 0 0 266 40
  mp-skin MPDIALOGCONFIGTOP
  drawsave @mp-temp $mpfile(temp.bmp)
  window -c @mp-temp
  did -g $dname 1 $mpfile(temp.bmp)
  .remove $mpfile(temp.bmp)
  did -a $dname 3 English
  did -a $dname 3 Português
  if (%mplang == por)  did -c $dname 3 2
  else did -c $dname 3 1
  noop $findfile($scriptdirskins\,*.mpaint,0,did -a $dname 5 $nopath($1-))
  var %x = 1
  while (%x <= $did(5).lines) {
    if ($did(mpconfig,5,%x) == $nopath(%mpskin)) did -c $dname 5 %x
    inc %x
  }
}
dialog mpabout {
  title "mPaint"
  size -1 -1 261 146
  icon 1, 0 -2 266 40
  button "&OK", 8, 107 116 44 26, ok
  box "", 7, -10 102 284 100
  text "", 2, 3 46 255 16, center
  text "fantal@email.com", 3, 3 61 255 16, center
  text "", 4, 3 86 255 16, center
}
on *:dialog:mpabout:init:*:{
  did -a $dname 2 $mplan(a)
  did -a $dname 4 $mplan(b)
  window -hpaf @mp-temp 0 0 266 40
  mp-skin MPDIALOGABOUTTOP
  drawsave @mp-temp $mpfile(temp.bmp)
  window -c @mp-temp
  did -g $dname 1 $mpfile(temp.bmp)
  .remove $mpfile(temp.bmp)
}
alias -l mp-webimport {
  if ($left($1,7) == http://) {
    set %mp.host $remove($gettok($right($1,-7),1,47),www.)
    set %mp.file $+($chr(47),$gettok($right($1,-7),2-,47))
  }
  else {
    set %mp.host $remove($gettok($1,1,47),www.)
    set %mp.file $+($chr(47),$gettok($1,2-,47))
  }
  if ($sock(mpweb)) { return }
  sockopen mpweb %mp.host 80
  titlebar @mpaint - $mplan(dw) $gettok(%mp.file,-1,47) $+ ...
}
on *:sockopen:mpweb:{
  if ($sockerr) {
    .titlebar @mpaint - $mplan(ie) $sockerr
    .timer 1 3 if ($window(@mpaint)) { .titlebar @mpaint }
    return
  }
  write -c $gettok(%mp.file,-1,47)
  unset %mp.length %mp.ready
  sockwrite -n mpweb GET %mp.file HTTP/1.0
  sockwrite -n mpweb Accept: */*
  sockwrite -n mpweb Host: %mp.host
  sockwrite -n mpweb
}
on *:sockread:mpweb:{
  if (%mp.ready != 1) {
    var %f
    sockread %f
    while ($sockbr) {
      if (Content-length: * iswm %f) { set %mp.length $gettok(%f,2,32) }
      elseif (* !iswm %f) {
        set %mp.ready 1
        set %mp.rcvd $sock($sockname).rcvd
        break
      }
      sockread %f
    }
  }
  sockread 4096 &d
  while ($sockbr) {
    titlebar @mPaint - $mplan(rc) $+($int($calc(100* ($sock($sockname).rcvd - %mp.rcvd) / %mp.length)),$chr(37))
    bwrite $gettok(%mp.file,-1,47) -1 -1 &d
    sockread 4096 &d
  }
}
on *:sockclose:mpweb:{
  .titlebar @mpaint - $mplan(dc)
  .timer 1 3 if ($window(@mpaint)) { .titlebar @mpaint }
  mp-import $shortfn($mircdir $+ $gettok(%mp.file,-1,47))
}