TextureDrawLine

Author: Eric Haines (Eric5h5)

Description
Draws single-pixel-wide, non-anti-aliased lines inside a texture. This isn't for drawing lines on the screen (unless the texture fills the entire screen, of course). Line drawing code adapted from some example code in another web page somewhere on teh intarnets.



Usage
Have this script somewhere in your project. Call the function by the name of the script ("TextureDraw" in this case) plus ".Line". The arguments are:

function Line (texture : Texture2D, x1 : int, y1 : int, x2 : int, y2 : int, color : Color)

"texture" is the texture you want to draw the line in, "x1" and "y1" are the x and y coordinates of the starting point of the line, "x2" and "y2" are the x and y coordinates of the ending point of the line, "color" is the color of the line. Lines drawn in the texture won't show up until Apply is called; for speed reasons, this should be done last if more than one line is being drawn at once. A code example, which draws some random lines in a texture and results in something similar to the image above:

What happens to points drawn outside the texture boundaries depends on whether the texture is set to clamp or repeat: clamp means the line won't draw past the edge, and repeat makes the line start over from the other side (this behavior is inherent to SetPixel).