View Single Post
  #1  
Old 02-21-2011, 09:01 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Line drawing tool

Published by request. Draws lines using Chompy's and Sales' DrawLine() function. Hold ctrl and drag yer mouse through Graal, wee~

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.draw false;
  
this.ox nil;
  
this.oy nil;
  
this.iIndex 0;
}

// erase drawn lines
function onEraseLines()
  
hideImgs(0199);

// mouse stuff
function GraalControl.onMouseDown(kmod) {
  if (
kmod in |48|) { // ctrl
    
this.draw true;
    
this.ox mousex;
    
this.oy mousey;
    
    
cancelEvents("EraseLines");
  }
}

function 
GraalControl.onMouseUp() {
  if (!
this.draw)
    return;
  
  
this.draw false;
  
cancelEvents("EraseLines");
  
scheduleEvent(3"EraseLines"nil);
}

function 
GraalControl.onMouseDragged() {
  if (!
this.draw)
    return;
  
  
temp.dx abs(this.ox mousex);
  
temp.dy abs(this.oy mousey);
  
temp.d  = (temp.dx temp.dy 2) ^ 0.5;
  if (
temp.0.1) {
    
temp.this.iIndex;
    
temp.0.5;
    
    
DrawLine(temp.ithis.oxthis.oymousexmousey16);
    
changeImgColors(temp.i1111);
    
changeImgVis(temp.i3);
    
    
this.iIndex++;
    
this.iIndex %= 200;
    
    
this.ox mousex;
    
this.oy mousey;
  }
}


// draw-a-line - thanks Chompy & Sales
// http://forums.graalonline.com/forums/showthread.php?t=78427
function DrawLine(idxsxsytxtyw) {
  
= (== nil 16 w);
  
temp.ang getangle(tx sxty sy) + pi 2;
  
  
showPoly(idx,
    { 
sxsy,
      
txty,
      
tx cos(ang) * wty sin(ang) * w,
      
sx cos(ang) * wsy sin(ang) * w  });

Reply With Quote