All pastes #217786 Raw Edit

Stuff

public text v1 · immutable
#217786 ·published 2006-10-23 20:47 UTC
rendered paste body
alias F9 window -apk0 @paint | set %size 10 | set %color $rgb(0,0,0) | set %original $getdot(@paint,1,1)
alias drawcurvy { drawdot -r @paint %color %size $mouse.x $mouse.y }
menu @paint {
  leave:{
    if (%lineon) { unset $v1 }
    if (%circleon) { unset $v1 }
    if (%roundedon) { unset $v1 }
    if (%texton) { unset $v1 }
    if (%squareon) { unset $v1 }
    .timermycurvyline off
  }
  sclick:{
    set %leftclick $mouse.x $mouse.y
    if (%eyedropperon) { set %color $getdot(@paint,$mouse.x,$mouse.y) | halt }
    if (%lineon) { halt }
    if (%circleon) { halt }
    if (%roundedon) { halt }
    if (%texton) { halt }
    if (%squareon) { halt }
    else { .timermycurvyline -m 0 -5 drawcurvy }
  }
  uclick:{
    if (%eyedropperon) { unset %eyedropperon | halt } 
    if (%lineon) { drawline -r @paint %color %size %leftclick $mouse.x $mouse.y | unset %lineon | halt }
    if (%texton) { drawtext -r @paint %color %leftclick $?="What text?" | unset %texton | halt }
    if (%squareon) {
      if ($gettok(%leftclick,1,32) < $mouse.x) { var %width = $calc($mouse.x - $gettok(%leftclick,1,32)) }
      else { var %width = $+(-,$calc($gettok(%leftclick,1,32) - $mouse.x)) }
      if ($gettok(%leftclick,2,32) < $mouse.y) { var %height = $calc($mouse.y - $gettok(%leftclick,2,32)) }
      else { var %height = $+(-,$calc($gettok(%leftclick,2,32) - $mouse.y)) }
      drawrect -rf @paint %color %size %leftclick %width %height
      unset %squareon
      halt 
    }
    if (%circleon) {
      if ($gettok(%leftclick,1,32) < $mouse.x) { var %width = $calc($mouse.x - $gettok(%leftclick,1,32)) }
      else { var %width = $+(-,$calc($gettok(%leftclick,1,32) - $mouse.x)) }
      if ($gettok(%leftclick,2,32) < $mouse.y) { var %height = $calc($mouse.y - $gettok(%leftclick,2,32)) }
      else { var %height = $+(-,$calc($gettok(%leftclick,2,32) - $mouse.y)) }
      drawrect -ref @paint %color %size %leftclick %width %height
      unset %circleon
      halt 
    }
    if (%roundedon) {
      if ($gettok(%leftclick,1,32) < $mouse.x) { var %width = $calc($mouse.x - $gettok(%leftclick,1,32)) }
      else { var %width = $+(-,$calc($gettok(%leftclick,1,32) - $mouse.x)) }
      if ($gettok(%leftclick,2,32) < $mouse.y) { var %height = $calc($mouse.y - $gettok(%leftclick,2,32)) }
      else { var %height = $+(-,$calc($gettok(%leftclick,2,32) - $mouse.y)) }
      drawrect -rdf @paint %color %size %leftclick %width %height
      unset %roundedon
      halt 
    }
    if (%leftclick == $mouse.x $mouse.y) { drawdot -r @paint %color %size %leftclick | .timermycurvyline off }
    else { .timermycurvyline off | unset %leftclick }
  }
  New:clear @paint
  colors
  .Erase:set %color %original
  .Custom Color:colorpick
  .red:set %color $rgb(255,0,0)
  .pink:set %color $rgb(255,105,180)
  .Deep Pink:set %color $rgb(255,20,147)
  .Purple:set %color $rgb(160,32,240)
  .Dark Blue:set %color $rgb(25,25,112)
  .Sky Blue:set %color $rgb(0,191,255)
  .Black:set %color $rgb(0,0,0)
  .Gray:set %color $rgb(190,190,190)
  .Light Green:set %color $rgb(124,252,0)
  .Brown:set %color $rgb(139,69,19)
  .Gold:set %color $rgb(255,215,0)
  .Yellow:set %color $rgb(255,255,0)
  .Orange:set %color $rgb(255,140,0)
  .Green:set %color $rgb(0,255,0)
  .Blue:set %color $rgb(0,0,255)
  Dot Size
  .20:set %size 20
  .15:set %size 15
  .10:set %size 10
  .5:set %size 5
  .Custom Size:{
    var %hmm $?="What size dot?"
    if (%hmm) { set %size %hmm }
    else { set %size 10 }
  }
  Tools
  .EyeDropper:set %eyedropperon on
  .Square:set %squareon on
  .text:set %texton on
  .Circle:set %Circleon on
  .Rounded Rectangle:set %roundedon on
  .Line:set %lineon on
}
alias colorpick { window -odfpRk0 @preview 50 50 200 200 | dialog -m colorpicker colorpicker }
on *:CLOSE:@paint:{ unset %original }
dialog colorpicker {
  title "Custom Color"
  size $iif(%c.x,%c.x,-1) $iif(%c.y,%c.y,-1) 150 60
  option dbu
  scroll "", 1, 30 10 90 10, range 0 255 horizontal
  scroll "", 2, 30 10 90 20, range 0 255 horizontal
  scroll "", 3, 30 10 90 30, range 0 255 horizontal
  text "Red", 4, 3 12 28 20
  text "Green", 5, 3 22 28 20
  text "Blue", 6, 3 32 28 20
  edit "", 7, 128 11 20 9
  edit "", 8, 128 21 20 9
  edit "", 9, 128 31 20 9
  button "YES! That color!", 10, 2 45 72 10
  button "I want to input the values!", 11, 74 45 73 10
}
on *:CLOSE:@preview:{
  if ($dialog(colorpicker)) { dialog -x $str(colorpicker $chr(32),2) }
  if ($dialog(value_D)) { dialog -x $str(value_D $chr(32),2) }
}
on *:DIALOG:*:*:*:{
  if ($dname == colorpicker) {
    if ($devent == init) {
      did -b $dname 7-9 | drawreplace -r @preview $getdot(@preview,1,1) $rgb($iif($gettok(%c.go,1,32),$gettok(%c.go,1,32),1),$iif($gettok(%c.go,2,32),$gettok(%c.go,2,32),1),$iif($gettok(%c.go,3,32),$gettok(%c.go,3,32),1))
      if (!%c.go) {
        did -ra $dname 7-9 0 
      }
      else {
        did -ra $dname 7 $gettok(%c.go,1,32) | did -ra $dname 8 $gettok(%c.go,2,32) | did -ra $dname 9 $gettok(%c.go,3,32)
        did -c $dname 1 $gettok(%c.go,1,32) | did -c $dname 2 $gettok(%c.go,2,32) | did -c $dname 3 $gettok(%c.go,3,32)
      }
    }
    if ($devent == close) { window -c @preview | unset $+(%,c.,*) }
    if ($devent == scroll) {
      did -ra $dname 7 $did($dname,1).sel
      did -ra $dname 8 $did($dname,2).sel
      did -ra $dname 9 $did($dname,3).sel
      drawreplace -r @preview $getdot(@preview,1,1) $rgb($did($dname,1).sel,$did($dname,2).sel,$did($dname,3).sel)
    }
    if ($devent == sclick) {
      if ($did == 10) {
        set %color $rgb($did($dname,1).sel,$did($dname,2).sel,$did($dname,3).sel)
      }
      if ($did == 11) {
        set %c.x $dialog($dname).x 
        set %c.y $dialog($dname).y
        set %c.go $did($dname,1).sel $did($dname,2).sel $did($dname,3).sel
        dialog -m value_D value_D
        dialog -x $str($dname $chr(32),2)
      }
    }
  }
  if ($dname == value_D) {
    if ($devent == init) { did -ra value_D 7 $gettok(%c.go,1,32) | did -ra value_D 8 $gettok(%c.go,2,32) | did -ra value_D 9 $gettok(%c.go,3,32) }
    if ($devent == close) { window -c @preview | unset $+(%,c.,*) }
    if ($devent == sclick) {
      if ($did == 11) {
        set %c.x $dialog($dname).x 
        set %c.y $dialog($dname).y
        set %c.go $did(7) $did(8) $did(9)
        dialog -m colorpicker colorpicker
        dialog -x $str($dname $chr(32),2)
      }
      if ($did == 12) { drawreplace -r @preview $getdot(@preview,1,1) $rgb($did(7),$did(8),$did(9)) }
      if ($did == 10) { set %color $rgb($did(7),$did(8),$did(9)) }      
    }
  }
}
dialog value_D {
  title "Manual Input Values"
  size $iif(%c.x,%c.x,-1) $iif(%c.y,%c.y,-1) 150 60 
  option dbu
  text "Red", 4, 3 12 28 20
  text "Green", 5, 3 22 28 20
  text "Blue", 6, 3 32 28 20
  edit "", 7, 28 11 20 9
  edit "", 8, 28 21 20 9
  edit "", 9, 28 31 20 9
  button "YES! That color!", 10, 2 45 72 10
  button "Back to custom color", 11, 74 45 73 10
  button "PREVIEW", 12, 49 10 98 31
}