Thread: drawLine()
View Single Post
  #1  
Old 01-21-2008, 10:48 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
drawLine()

PHP Code:
//#CLIENTSIDE
public function drawLine(index, xy1, xy2, color, thickness, layer) {
  
with(findimg(index)) {
    
polygon = {
      
xy1[0], xy2[1], xy2[0], xy1[1],
      
xy2[0]+thickness, xy1[1]+thickness, xy1[0]+thickness, xy2[1]+thickness
    
};
    
layer = layer;
    
red = color[0];
    
green = color[1];
    
blue = color[2];
    
alpha = color[3];
  }
} 
Basic example:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
drawLine(200, {15, 20}, {31, 18}, {1, 0, 0, 0.99}, 0.3, 2);
  
// will draw a red line from 15,20 to 31,18 with a thickness of 0.3 tiles
} 
Basicly you give the function: index, xy1[], xy2[], color[], thickness and layer

The function will draw polygon from xy1 to xy2, thickness of the line is based on the 4th param (if layer is 4 or lower, it is given in tiles. If 5 or higher thickness is in pixels (This goes to coordinats to (xy1 and xy2))

A nifty little function that I thought I could share
__________________

Last edited by Chompy; 01-21-2008 at 11:11 PM..
Reply With Quote