I recently purchased a new 84+CE, and have been playing with color in BASIC. I thought up of a simple plotter that uses the color as a sort of Z to plot "3d" functions in 2d, like a gradient. I have working code using 9 colors, even "dithering" in-between. Here is the code:
Code:
It works pretty well, but is awfully slow. I have a few ideas to make it faster, but need some fresh eyes. Am I missing anything glaring that would make this much faster?
Code:
Input "Z=",Str1
Str1→|u //sets the z function to u for easy evaluation
//May want to use Y1 or some other function
Input "ZMIN=",I
Input "ZMAX=",J //sets upper and lower boundaries for the colors
{2,7,0,8,4,9,5,1,3}→L1 //9 colors in order minus 10: bk, navy, bl, lt bl, g, y, o, r, m
ClrDraw
For(A,0,54 //55 "points" vertical
For(B,0,87 //88 "points" horizontal
Xmin+(3B+1)deltaX→X //calculate x and y values given A and B
Ymax-(3A+1)deltaY→Y //might should do this in the for loop declarations
|u→C //calculate Z with given x,y
(min(9,max(1,1+iPart((C-I)/(J-I)*9-.25+fPart((A+B)/2→C //calculate the level between 1-9
//min and max bound the calcuation,
//(C-I)/(J-I) gives a value from 0 to 1 if C falls within I and J
//multiply by nine and add the -.25+fpart(A+B)/2 for checkerboard dithering
10+L1(C→C //index 1-9 of the color list, add to 10, gives color code.
Pt-On(X,Y,C //color that point!
End
It works pretty well, but is awfully slow. I have a few ideas to make it faster, but need some fresh eyes. Am I missing anything glaring that would make this much faster?