You are not logged in.
Pages: 1
Hmm, I have never used primitives, and I never had the idea... I will look into it
This script draws a gradient rectangle, with the specified colour to 0 alpha... Take a look:
/*
** Usage:
** draw_rectangle_toalpha(x1,y1,x2,y2,colour,xscale,yscale)
**
** Arguments:
** x1,y1 first corner of the rectangle
** x2,y2 second corner of the rectangle
** colour the colour of the visible side (optional)
** xscale direction of the gradient
** yscale direction of the gradient
**
** Returns:
** nothing
**
** Notes:
** Draws a rectangle of a cirtain colour, which
** will have a gradient and turn to invisible.
**
** GMLscripts.com
*/
{
//initialize some variables to use
var x1,y1,x2,x2,width,height,alpha,alphastep;
x1=argument0
y1=argument1
x2=argument2
y2=argument3
width=(x2-x1)
height=(y2-y1)
alpha=1
alphastep=(1/width)
draw_set_color(argument4)
//move along and draw the line, decreasing alpha each time
if argument5=1 && argument6=1{
for ( i = x1; i < x2; i += 1 ){
draw_set_alpha(alpha)
draw_line(i,y1,i,y2)
alpha-=alphastep
}
}
if argument5=-1 && argument6=1{
for ( i = x2; i > x1; i -= 1 ){
draw_set_alpha(alpha)
draw_line(i,y1,i,y2)
alpha-=alphastep
}
}
if argument5=1 && argument6=-1{
for ( i = y1; i < y2; i += 1 ){
draw_set_alpha(alpha)
draw_line(x1,i,x2,i)
alpha-=alphastep
}
}
if argument5=-1 && argument6=-1{
for ( i = y2; i > y1; i -= 1 ){
draw_set_alpha(alpha)
draw_line(x1,i,x2,i)
alpha-=alphastep
}
}
}
Pages: 1