From: Patrick Mochel (mochelp@ironarm.com)
Date: Fri 14 Jul 2000 - 07:30:21 IDT
Thanks for the example, but it wasn't quite _exactly_ what I was looking
for. I've attached a file with what I was trying to do (well, for the
most part). I haven't quite got a smooth transition to and from
green: it uses 6 bits while red and blue use 5, so I increment and
decrement green by 1.5, since its max value is 0x2f, (~1.5 * 0x1f)...but
is' not smooth...
On Tue, 11 Jul 2000, Sergio Masci wrote:
> > This is another generic graphics programming question, but hopefully
> > someone will know the answer.
> >
> > How do I iteratate through the colors? It seems like it should be simple,
> > but it's not behaving as expected. I'm writing a little something that
> > draws a color wheel on the screen at 800x600x64K. Just for kicks, suppose
> > that it's just drawing vertical lines, so the code looks like this:
> >
> > ...
> > color = 0;
> > for (xnow = 0; xnow < xmax; xnow++)
> > gl_line(xnow,0,xnow,ymax,color++);
> > ...
> >
> > I come up with about 13 identical sections of color fading.
> > the same happens if I do
> >
> > vga_setcolor(color++);
> > vga_drawline(xnow,0,xnow,ymax);
> >
> >
> > Is there a way that I can do what I am trying simply?
> >
> > Regards,
> >
> > -patrick
>
>
> I don't use the gl libraries or the vga_setcolor or vga_drawline
> functions so I cannot give a concrete answer BUT it looks to me as
> though the colour is a direct copy of the hardware pixel used in the
> 800x600x64K mode. In this mode the colours are packed into a 16 bit word
> something like 6:5:5 or 6:6:4 I cannot remember exactly.
>
> Try experimenting with the following:
>
> float fx, fy, fz;
> int x, y
> red, green, blue, pixel;
>
> for (x=0; x<800; x++)
> {
> for (y=0; y<600; y++)
> {
> fx = (float)x / 799;
> fy = (float)y / 599;
> fz = sqrt(x * x + y * y) / sqrt(799*799 + 599*599);
>
> red = 0x2f * fx;
> blue = 0x1f * fy;
> green = 0x1f * fz;
>
> pixel = (red << 10) | (green << 5) | blue;
>
> vga_setcolor(pixel);
> vga_drawline(x,y,x,y);
> }
> }
>
> You should end up with a box, one corner of which should be black,
> diagnally opposit will be white, one other corner should be blue and the
> last should be red (no pure green since this component is generated from
> blue and red and so does not exist in this square without them).
>
> Regards
> Sergio
>
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST