Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #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()

Graal Script Code:
//#CLIENTSIDE
public function drawLine(indexxy1xy2colorthicknesslayer) {
  
with(findimg(index)) {
    
polygon = {
      
xy1[0], xy2[1], xy2[0], xy1[1],
      
xy2[0]+thicknessxy1[1]+thicknessxy1[0]+thicknessxy2[1]+thickness
    
};
    
layer layer;
    
red color[0];
    
green color[1];
    
blue color[2];
    
alpha color[3];
  }

Basic example:
Graal Script Code:
//#CLIENTSIDE
function onCreated() {
  
drawLine(200, {1520}, {3118}, {1000.99}, 0.32);
  
// 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
  #2  
Old 01-21-2008, 11:05 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Hmm... does the thickness take into account the direction of the line? From reading it it doesn't seem it, maybe that'd be a good addition.
Reply With Quote
  #3  
Old 01-21-2008, 11:12 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
The fancy one you have should be drawline2(), and just have a simple drawline(x1, y1, x2, y2) like in Java and have setcolor() and stuff seperate :o
__________________
Reply With Quote
  #4  
Old 01-21-2008, 11:13 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
Quote:
Originally Posted by DustyPorViva View Post
Hmm... does the thickness take into account the direction of the line? From reading it it doesn't seem it, maybe that'd be a good addition.
Hmm, yeah, I edited it :o

It now works, but it makes some sharp corners:
..______
./......../
/_____/ (Where you remove the dots (pm, this is a zoomed version of the line ))

I could add some checking to see which direction it is going based on the gived coords tho..
__________________
Reply With Quote
  #5  
Old 01-21-2008, 11:51 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
I think Graal should have brush functionality much like C#. ;(
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 01-22-2008, 12:06 AM
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
Quote:
Originally Posted by coreys View Post
I think Graal should have brush functionality much like C#. ;(
__________________
Reply With Quote
  #7  
Old 01-22-2008, 03:19 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Why will people do something like

Graal Script Code:
withfindimg200 ) )
{
  
image "block.png";
  
10;
  
20;

instead of just
Graal Script Code:
showimg"block.png"1020 ); 
__________________
Reply With Quote
  #8  
Old 01-22-2008, 03:42 AM
Rapidwolve24 Rapidwolve24 is offline
North*
Join Date: Oct 2007
Location: Massachusetts
Posts: 178
Rapidwolve24 is on a distinguished road
Send a message via AIM to Rapidwolve24 Send a message via MSN to Rapidwolve24
Quote:
Originally Posted by cbkbud View Post
Why will people do something like

Graal Script Code:
withfindimg200 ) )
{
  
image "block.png";
  
10;
  
20;

instead of just
Graal Script Code:
showimg"block.png"1020 ); 
I think he did it to avoid having to use changeimgvis and changeimgcolors?
Reply With Quote
  #9  
Old 01-22-2008, 04:13 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
It's just a matter of preference.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 01-22-2008, 04:44 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
showimg() = GS1 >
As far as I'm concerned considering the way you can use findimg(), I consider showimg() to just be a remnant of GS1 existing for compatibility.
__________________
Reply With Quote
  #11  
Old 01-22-2008, 04:47 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
showimg() = GS1 >
As far as I'm concerned considering the way you can use findimg(), I consider showimg() to just be a remnant of GS1 existing for compatibility.
Hmm ... I've always used the functions like changeimgcolor, etc.

Will probably start using findimg().
__________________
Reply With Quote
  #12  
Old 01-22-2008, 04:59 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
I consider showimg() to just be a remnant of GS1 existing for compatibility.
This drawline...it has it's own function to allow people to quickly draw a line using 1 line of code. Technically you could just add the provided code at every instance and it would have the same effect, yes? People will still choose the function as it's easier. showimg() seems quite similar to this.
Reply With Quote
  #13  
Old 01-22-2008, 05:47 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I use showimg because it's shorter. If I'm going to be showing an image and change a lot about it though, I'll usually use findimg.
Reply With Quote
  #14  
Old 01-22-2008, 05:53 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
Quote:
Originally Posted by Rapidwolve24 View Post
I think he did it to avoid having to use changeimgvis and changeimgcolors?
Quote:
Originally Posted by coreys View Post
It's just a matter of preference.


And, I find using findimg() easier to read and debug
__________________
Reply With Quote
  #15  
Old 01-22-2008, 07:28 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Graal Script Code:
    polygon = {
      
xy1[0]-(thickness/2), xy2[1]-(thickness/2), xy2[0]-(thickness/2), xy1[1]-(thickness/2),
      
xy2[0]+(thickness/2), xy1[1]+(thickness/2), xy1[0]+(thickness/2), xy2[1]+(thickness/2)
    }; 
Wouldn't that look better?
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:35 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.