Light Switch

By BlueThen on Apr 27, 2008

Light switch, just as what it sounds.

It may look simple from the pictures, BUT IT'S NOT! O.O twitch

There is one error, that I spent HOURS trying to fix...
Sometimes when trying to drag the light switch up or down, it just doesn't drag. I guess that's what happens when you click closer to the middle of the switch.
On:
Image
Off:
Image

;Light Switch 1.0
;Made by BlueThen on April 27, 2008.
;To install, paste this snippet into your remotes (alt + r)
;then type /light or right click the channel or status window and click "Light."
;Drag the light switch for the effect.
alias light window -paoCzdk0 +tnbL @Light -1 -1 400 400 | window -poCzdhk0 +tnbL @light.buf -1 -1 800 800 | light.init
alias -l light.init {
  drawfill @light.buf 0 0 1 1 1 1 | set %light.a 315 | set %light.ta 315
  drawline @light.buf 1 2 0 360 $calc(200 * $cos(315).deg) $calc(360 + (200 * $sin(315).deg))
  drawline @light.buf 1 2 0 440 $calc(200 * $cos(315).deg) $calc(440 + (200 * $sin(315).deg))
  drawline @light.buf 1 2 $calc(200 * $cos(315).deg) $calc(360 + (200 * $sin(315).deg)) $calc(200 * $cos(315).deg) $calc(440 + (200 * $sin(315).deg))
  drawfill @light.buf 1 1 0 400  
  drawtext @light.buf 1 Tahoma 40 400 100 Made By BlueThen | drawtext @light.buf 1 Tahoma 40 400 140 BlueThen.com | drawcopy -m @light.buf 0 0 800 800 @light 0 0 400 400
}
on *:close:@light: { window -c @light.buf | unset %light.a %light.ta %light.h %light.ma %light.c %light.ci }
menu channel,status {
  Light: { light }
}
menu @light {
  sclick: {
    if ($inpoly( $calc($mouse.x *2) , $calc($mouse.y *2) , 0 , 360 , 0 , 440 , $calc(200 * $cos( %light.ta ).deg) , $calc(360 + (200 * $sin( %light.ta ).deg)) , $calc(200 * $cos( %light.ta ).deg) , $calc(440 + (200 * $sin( %light.ta ).deg)))) {
      set %light.h y | set %light.ma $getangle( $calc( $mouse.x *2) , $calc( $mouse.y *2) ,0,400)
    }
  }
  mouse: {
    if (%light.h == y) {
      %light.ta = $calc(%light.a + (%light.ma - ($getangle( $calc( $mouse.x * 2) , $calc( $mouse.y *2) ,0,400))))) | clear @light.buf
      if (%light.ta > 380) %light.ta = 380 | if (%light.ta < 320) %light.ta = 320
      %light.c = $round($calc(255-((%light.ta - 320)*4.2)),0) | %light.c = $rgb(%light.c , %light.c , %light.c) | %light.ci = $calc(16777215 - %light.c)
      drawfill -r @light.buf %light.c %light.c 1 1 1 1
      drawline -r @light.buf %light.ci 2 0 360 $calc(200 * $cos( %light.ta ).deg) $calc(360 + (200 * $sin( %light.ta ).deg))
      drawline -r @light.buf %light.ci 2 0 440 $calc(200 * $cos( %light.ta ).deg) $calc(440 + (200 * $sin( %light.ta ).deg))
      drawline -r @light.buf %light.ci 2 $calc(200 * $cos( %light.ta ).deg) $calc(360 + (200 * $sin( %light.ta ).deg)) $calc(200 * $cos( %light.ta ).deg) $calc(440 + (200 * $sin( %light.ta ).deg))
      drawfill -r @light.buf %light.ci %light.ci 0 400 | drawtext -r @light.buf %light.ci Tahoma 40 400 100 Made By BlueThen
      drawtext -r @light.buf %light.ci Tahoma 40 400 140 BlueThen.com | drawcopy -m @light.buf 0 0 800 800 @light 0 0 400 400
    }
  }
  leave: { if (%light.h == y) { set %light.h n | set %light.a %light.ta } }
  uclick: { if (%light.h == y) { set %light.h n | set %light.a $calc(%light.a + (%light.ma - ($getangle( $calc( $mouse.x * 2) , $calc( $mouse.y *2) ,0,400))))) } }
}
alias getangle {
  set %p1.x $1 | set %p1.y $2 | set %p2.x $3 | set %p2.y $4 | set %p3.x %p2.x | set %p3.y %p1.y
  set %opposite $calc($abs($calc(%p2.x - %p3.x)) + $abs($calc(%p2.y - %p3.y)))
  set %hypotenuse $calc($abs($calc(%p2.x - %p1.x)) + $abs($calc(%p2.y - %p1.y)))) | set %angle $asin($calc( %opposite / %hypotenuse )).deg
  if (%p1.y < %p2.y) set %angle $calc(360 - %angle) | if ((%p1.x > %p2.x) && (%p1.y > %p2.y)) set %angle $calc(180 - %angle)
  elseif ((%p1.x > %p2.x) && (%p1.y < %p2.y)) set %angle $calc(180 +(360 - %angle)) | return %angle

Comments

Sign in to comment.
Blitzjager   -  Jan 18, 2009

I didn't think it would be good but I liked it. I assumed it was a click the switch/invert the colours but the fade surprised me.

Not important but you're missing a bracket on the last line.

 Respond  
BlueThen   -  Apr 28, 2008

Those are simple though, picwins are an actual challenge to me.

 Respond  
Bouncer   -  Apr 28, 2008

Whatever suits your fancy. Just use it to create scripts that are useful to everyone. Sure, yours are a nice diversion, but why not try making a totally l33t Mp3 or an Away System to pwn all others. I know millions have already been made, but that doesn\'t mean you can\'t contribute to the pile :P Make a clone scanner or something. There are some already out there, but not many, and alot of the ones you do find have errors. Try to make the best one out there. If you put your mind to it, I bet you could make alot of great stuff.

 Respond  
BlueThen   -  Apr 28, 2008

\"How about devoting that ingenuity of yours to more useful scripts? :P\" Like what?

 Respond  
Mitchell   -  Apr 28, 2008

I haven\'t tried it yet, but it looks very neat. I give an 8/10

 Respond  
Bouncer   -  Apr 28, 2008

Your scripts are damn good, but you have been doing things with these pictures for a while now. How about devoting that ingenuity of yours to more useful scripts? :P

8/10 from me

 Respond  
Jonesy44   -  Apr 28, 2008

Hahaha ! nice

You relly have this winpic stuff dialed bud :P

 Respond  
Eugenio   -  Apr 27, 2008

lmao its brilliant......pointless........but brilliant

Hours... and hours... of scripting, FOR A FREAKIN SWITCH!!

Now I know how Thomas Edison felt when he tried to invent the light bulb.

lmfao

 Respond  
EL   -  Apr 27, 2008

Lol how many hours in all?.

 Respond  
BlueThen   -  Apr 27, 2008

Hours... and hours... of scripting, FOR A FREAKIN SWITCH!!

Now I know how Thomas Edison felt when he tried to invent the light bulb.

Oh well, atleast I accomplished something. ;o

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.