07-12-2003, 05:56 AM
Does anyone know how I would draw a line without the LINE command. I know it must use the SIN and COS command, but I could be wrong. Hopefully it's not the difficult, because it certainly sounds easy enough...
Drawing a line...
|
07-12-2003, 05:56 AM
Does anyone know how I would draw a line without the LINE command. I know it must use the SIN and COS command, but I could be wrong. Hopefully it's not the difficult, because it certainly sounds easy enough...
07-12-2003, 07:01 AM
Define a slope (call it SLOPE) and y-intercept (call it INTERCEPT), pick a value for an attribute (call it ATTR), and for X between X1 and X2:
FOR X = X1 TO X2 Y = SLOPE * X + INTERCEPT PSET (X,Y), ATTR NEXT X
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.) I liked spam better when it was something that came in a can. Windows should be defenestrated.
07-12-2003, 07:03 AM
I've got a tutorial that explains a very fast method using simple addition and subtraction - should I email it to you?
07-12-2003, 08:00 AM
Bresenham, eh?
Code: SUB DrawLine (x1, y1, x2, y2, colr)
07-12-2003, 01:18 PM
Glenn: Could you show me how I would do that in a sub please? With the varibles and stuff?
Plasma: *brain shorts out* *lungs melt away* *alarms flash on and off* *dies*
07-12-2003, 01:58 PM
I'll assume you ultimately want to work with screen coordinates. (I really wish I'd have read that before drinking the undiluted amaretto. Oh, boy. Here goes nothing.)
SUB DRAWLINE(X1 AS INTEGER, X2 AS INTEGER, SLOPE AS SINGLE, INTERCEPT AS SINGLE, ATTR AS INTEGER) DIM X AS INTEGER, Y AS INTEGER FOR X = X1 TO X2 Y = SLOPE * X + INTERCEPT PSET (X,Y), ATTR NEXT X END SUB *Hick* up. (Do not construe this as a recommendation of something better or more useful than Bresenham's algorithm. It's just an implementation of the standard definition of a line. There is sometimes a difference between mathematics and what works "best" when a computer is involved.) Good night. (If that actually works and you come to the conclusion that the amaretto obviously wasn't affecting anything, well, I feel obligated to point out that I had to come back and fix the SUB statement.) *Plop*
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.) I liked spam better when it was something that came in a can. Windows should be defenestrated.
07-14-2003, 10:49 AM
Glenn: I bet Mega wanted you to explain how to get...
1. Slope 2. the y-intercept. ;*) As in the Linear Equation: y=mx+b and its different flavors. Mega: you could look it up on an algebra book. ;*)
07-14-2003, 11:16 AM
depends on what he's doing and what information he has. Math textbooks, for example, have a habit of simply specifying a slope and intercept in a homework problem to draw the line.
If you know that the points (x1,y1) and (x2,y2) lie on a (non-vertical) line, SLOPE = (Y2 - Y1) / (X2 - X1) and Y-INTERCEPT = Y1 - SLOPE * X1 = Y2 - SLOPE * X2 If, alternatively, you know that the line makes an angle THETA with the x-axis and passes through the point (X1,Y1), SLOPE = TAN(THETA) and Y-INTERCEPT = Y1 - SLOPE * X1, as before.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.) I liked spam better when it was something that came in a can. Windows should be defenestrated.
07-14-2003, 11:23 AM
Mega, you reading this?
;*)
07-14-2003, 11:45 AM
Yeah I'm readin' it... I get it, but I'm wondering how can I draw a line the supports X1, Y1 to X2,Y2...
Edit: *See's is* Alright, thanks guys.,. |
« Next Oldest | Next Newest »
|