| Posted: 05:37am 10 Jun 2020 |
|
|
|
Here is a variation of the colour wheel example given in lesson 3 above. In this example, the wheel rotates 6 degrees at each step, giving smoother motion. This is accomplished by making the pie chart with 60 segments instead of the 6 in the original example. Each segment has its own colour number, however, groups of 10 different colours have the same actual colour values. This way, 10 adjacent segments of the pie chart have the same colour and appear to be a single piece. Animation happens the same as before, except now only a single 6 degree segment of each region changes to the next colour at each step.
This example also shows some interesting Moire artefacts that appear when many slightly different angled lines meet at a point.
Press CTRL-C to end the program after you have been hypnotized. Type the command "map reset" to fix colours back to normal, or you may seem some strange colours when editing or using the file manager.
' Set up an array to hold the colour mappings we are going to use Dim integer cmap(60)
'Clear the screen CLS
'Set up 6 colours in the array for i = 1 to 10 cmap( 0+i)=RGB(red) cmap(10+i)=RGB(green) cmap(20+i)=RGB(blue) cmap(30+i)=RGB(yellow) cmap(40+i)=RGB(magenta) cmap(50+i)=RGB(cyan) next i
' Do an initial update of the CLUT to set up our colours mapclut
'Display an outer circle in white Circle MM.HRes/2,MM.VRes/2,MM.VRes/2-1,0,,RGB(white),RGB(white)
' Now draw a simple colour pie chart using our new colours with the ARC command for i = 0 to 59 Arc MM.HRes/2,MM.VRes/2,0,MM.VRes/2-10,i*6,(i+1)*6,map(i+1) next i
' Start a never ending loop Do
'each time round the loop move the colours in our array one place to the left ' Use array element 0 to store the first element that is going to be at the end for i = 1 to 60 cmap(i-1)=cmap(i) next i cmap(60)=cmap(0)
' update the colour map mapclut
' pause so we can see the change Pause 25 Loop
'This subroutine updates the colour map for the colours we are using ' set map positions 1 to 60 to the new colours ' then apply the change Sub mapclut local i for i = 1 to 60 map(i)=cmap(i) next i map set End Sub
|