program vec2screen (INPUT, OUTPUT); const x_data_min = 0; y_data_min = 0; x_data_max = 512; y_data_max = 512; xmax = 256; ymax = 256; xmin = 0; ymin = 0; var INPUT_file: TEXT; x1, y1, x2, y2: INTEGER; color: INTEGER; x_scale, y_scale: REAL; procedure line (var xs, ys, xf, yf: INTEGER); begin moveto(xs, ys); lineto(xf, yf); end; {line} procedure draw_line_scaled (x1, y1, x2, y2: REAL); var xs, ys, xf, yf: INTEGER; {scaled and translated values} begin {scale the values of the endpoints of the line so that they will} { fit into the screen. Use the limits of the virtual window, which} { is typically defined by the data to be presented} xs := ROUND((x1 + ABS(x_data_min)) * x_scale); ys := ROUND((y1 + ABS(y_data_min)) * y_scale); xf := ROUND((x2 + ABS(x_data_min)) * x_scale); yf := ROUND((y2 + ABS(y_data_min)) * y_scale); yf := ymax - yf; ys := ymax - ys; line(xs, ys, xf, yf); end; {draw_line_scaled} begin {main} x_scale := (xmax - xmin) / (x_data_max - x_data_min); y_scale := (ymax - ymin) / (y_data_max - y_data_min); RESET(input_file, 'aerimg'); while not (EOF(INPUT_FILE)) do begin READLN(input_file, x1, y1, x2, y2, color); draw_line_scaled(x1, y1, x2, y2); end; CLOSE(input_file); READLN; end. {main}