Jump to content


Photo

Draw Line Width


  • Please log in to reply
2 replies to this topic

#1 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 16 February 2008 - 01:45 AM

I now that GM7 has a functions to draw a line with a desired width, but GM6 and under doesn't, so I designed this very simple script that works just like "draw_line", yet you can chose the width of the line using a simple approach with the lengthdir functions. Here's the code:
/* draw_line_width(x1,y1,x2,y2,width)
** Draws a centered line with a desired width
** Argument(s):
**      argument0 = x1
**      argument1 = y1
**      argument2 = x2
**      argument3 = y2
**      argument4 = width
** Returns: Nothing
*/
var i;
for (i=0;i<argument4/2;i+=0.5)
{
draw_line(argument0+lengthdir_x(i,point_direction(argument0,argument1,argument2,argument3)-90),argument1+lengthdir_y(i,point_direction(argument0,argument1,argument2,argument3)-90),argument2+lengthdir_x(i,point_direction(argument2,argument3,argument0,argument1)+90),argument3+lengthdir_y(i,point_direction(argument2,argument3,argument0,argument1)+90));
draw_line(argument0+lengthdir_x(i*(-1),point_direction(argument0,argument1,argument2,argument3)-90),argument1+lengthdir_y(i*(-1),point_direction(argument0,argument1,argument2,argument3)-90),argument2+lengthdir_x(i*(-1),point_direction(argument2,argument3,argument0,argument1)+90),argument3+lengthdir_y(i*(-1),point_direction(argument2,argument3,argument0,argument1)+90));
}
It's actually quite simple, but can prove useful for GM6 users :)

NOTE: This script works for unregistered users too :P

Edited by Rixeno, 16 February 2008 - 02:40 AM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-

#2 xot

xot

    GMC Dismember

  • GMC Elder
  • 4785 posts
  • Version:GM:Studio

Posted 16 February 2008 - 02:35 AM

Hmmm, interesting way to do this. Not exactly fast or efficient, but it works for unregistered users, so it's got that going for it.
  • 0
GMLscripts.com, rise from your grave!

If any of my posts contain broken images or links, I can probably supply them for you. PM with a link to the post.

#3 Rixeno

Rixeno

    The One 'n' Only

  • New Member
  • 513 posts

Posted 16 February 2008 - 02:39 AM

Thanks xot, that actually means a lot coming from someone like you (in the case of experience). Of course, it's true that it isn't fast because of all the lines, and yet it's ALSO true that it would work for unregistered users. I think I'll mention that.

Edited by Rixeno, 16 February 2008 - 02:40 AM.

  • 0
Do you need an example? You can PM me a request and I'll try my best.
Creations:
- Extra String Functions - Sprite Chroma Key - String at Position - Word Censor - Draw_Line_Width (Unreg GM6-) - Shadowed Text - Draw N-Gon - PIXEL PERFECT COLLISION ENGINE-