Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   drawLine() (https://forums.graalonline.com/forums/showthread.php?t=78427)

napo_p2p 01-24-2008 06:43 AM

findimg() vs. showimg() is just a matter from preference. one isn't more OO than the other; one isn't more 'GS2' than the other. they are pretty much equivalent.

For example, taking
Quote:

Originally Posted by Kristi (Post 1371570)
showimg is a fine function. I personally do something like
this.whatevz = showimg(whatevz);
then generally reference the variable when i want to change anything
this.whatevz.red = rad;

i would do something along the lines of:
PHP Code:

with (findimg(1)) {
  
//whatevz
  
thiso.whatevz this;


but either way is just as good.

salesman 03-13-2009 11:58 PM

I came across this thread when trying to find out if there was a built in drawLine() function. However, I needed the width of the line to be the same regardless of angle and made this:

PHP Code:

//DrawLine( img_index, start_x, start_y, target_x, target_y, width_in_tiles, red, green, blue, alpha)
public function DrawLineindsxsytxtywidrgbalph ) {
  
temp.ang getangle(tx sxty sy) + (pi/2);
  
temp.wid = ( wid == NULL .1 wid );

  
with findImg(ind) ) {
    
polygon = {
      
sxsy,
      
txty,
      
tx cos(ang)*widty sin(ang)*wid,
      
sx cos(ang)*widsy sin(ang)*wid
    
};
    
red = ( || );
    
green = ( || );
    
blue = ( || );
    
alpha = ( alph <= || alph alph);
    
layer 3;
  }


An example:
PHP Code:

DrawLine(20025254545);
//Draws a black line of width .1 tiles from 25,25 to 45,45 

or if you want to specify color, width and alpha:
PHP Code:

DrawLine(20025254545.3100.5);
//Draws a semi-transparent red line of width .3 tiles from 25,25 to 45,45 



All times are GMT +2. The time now is 01:12 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.