[SOLVED] Line drawing Algorithm


Looking for a good line drawing algorithm.

I want to be able to per pixel colour a line so i can animate colour along the length of the line which GML does seem to cover

i have looked on line and seen a few options but wanted to get advice on what was best for quick, efficient game use

options i have looked at are:

any help would be appreciated
You can pass a vertex with two points as a pr_linelist, then you can use any texture you want for your line without rewriting the algorithm.
///@param x1
///@param y1
///@param x2
///@param y2
///@param color

var xmin = min(argument0,argument2);
var xmax = max(argument0,argument2);
var ymin = min(argument1,argument3);
var ymax = max(argument1,argument3);
var x1 = argument0;
var x2 = argument2;
var y1 = argument1;
var y2 = argument3;
var color = argument4;

var xdist = xmax-xmin;
var ydist = ymax-ymin;

if(xdist == 0 && ydist == 0){

if(xdist <= ydist){
    for(var yy = ymin; yy <= ymax; yy++){
        var xx = round(x2+(x2-x1)*(yy-ymax)/ydist);
        if(y1 > y2) xx = round(x1+(x1-x2)*(yy-ymax)/ydist);


    for(var xx = xmin; xx <= xmax; xx++){
        var yy = round(y2+(y2-y1)*(xx-xmax)/xdist);
        if(x1 > x2) yy = round(y1+(y1-y2)*(xx-xmax)/xdist);

Also, you can use this simple script I wrote some time ago. You can modify it to add different colors to each point