Discussion:
Small and Subtle colour change in animated object
(too old to reply)
Richard Ashbery
2019-03-23 12:06:28 UTC
Permalink
MODE 1920,1080,8 : OFF
x = 0
REPEAT
CIRCLE FILL x,1100,100
x+=10
Z=INKEY(10)
UNTIL x=3800

This simple code draws a filled circle across screen. Has anyone got a
routine I could add to make each new circle go through a gradual
colour change? Only very small and subtle changes of colour are
required to cover the whole of the RGB spectrum. Routine would need to
handle thousands of colours because each prime colour has 256 possible
levels.

Richard
druck
2019-03-24 21:40:00 UTC
Permalink
Post by Richard Ashbery
MODE 1920,1080,8 : OFF
x = 0
REPEAT
CIRCLE FILL x,1100,100
x+=10
Z=INKEY(10)
UNTIL x=3800
This simple code draws a filled circle across screen. Has anyone got a
routine I could add to make each new circle go through a gradual
colour change? Only very small and subtle changes of colour are
required to cover the whole of the RGB spectrum. Routine would need to
handle thousands of colours because each prime colour has 256 possible
levels.
Try this, it not my best code, but I'm really rusty in BBC BASIC.
As you want thousands of colours I've decreaed the increment to 2, to give
1920 steps as opposed to 380 above.

ON ERROR PRINT REPORT$;" at line ";ERL:END
MODE 1920,1080,32 : OFF
x% = 0
REPEAT
c = (x%/3800)*7
i% = (c*256)MOD256
d% = 255-i%
c% = c
CASE c% OF
WHEN 0
r% = i%
g% = 0
b% = 0
WHEN 1
r% = 255
g% = i%
b% = 0
WHEN 2
r% = d%
g% = 255
b% = 0
WHEN 3
r% = 0
g% = 255
b% = i%
WHEN 4
r% = 0
g% = d%
b% = 255
WHEN 5
r% = i%
g% = 0
b% = 255
WHEN 6
r% = 255
g% = i%
b% = 255
ENDCASE
GCOL r%,g%,b%
CIRCLE FILL x%,1100,100
x%+=2
Z%=INKEY(10)
UNTIL x%>=3800


---druck
--
The ARM Club Free Software - http://www.armclub.org.uk/free/
32 bit Conversions Page - http://www.armclub.org.uk/32bit/
Richard Ashbery
2019-03-25 13:48:35 UTC
Permalink
[snip]
Post by druck
Post by Richard Ashbery
Routine would need to
handle thousands of colours because each prime colour has 256 possible
levels.
Try this, it not my best code, but I'm really rusty in BBC BASIC.
As you want thousands of colours I've decreaed the increment to 2, to give
1920 steps as opposed to 380 above.
ON ERROR PRINT REPORT$;" at line ";ERL:END
MODE 1920,1080,32 : OFF
x% = 0
REPEAT
c = (x%/3800)*7
i% = (c*256)MOD256
d% = 255-i%
c% = c
CASE c% OF
WHEN 0
r% = i%
g% = 0
b% = 0
WHEN 1
r% = 255
g% = i%
b% = 0
WHEN 2
r% = d%
g% = 255
b% = 0
WHEN 3
r% = 0
g% = 255
b% = i%
WHEN 4
r% = 0
g% = d%
b% = 255
WHEN 5
r% = i%
g% = 0
b% = 255
WHEN 6
r% = 255
g% = i%
b% = 255
ENDCASE
GCOL r%,g%,b%
CIRCLE FILL x%,1100,100
x%+=2
Z%=INKEY(10)
UNTIL x%>=3800
Many thanks Druck. I wish I could write a program as quickly as that!
Works a treat - just the job. I see you use MODE 1920,1080,32 which
makes a significant difference to the colour graduation smoothness.

Presumably you've expanded the WHEN statements to make it clearer for
me but by combining each r,g,b parameter group into each WHEN line
almost halves the number of lines making routine quite compact.

I can link your routine with a rather unusual but very effective
multi-pattern pseudo 'lissajous' program written in BB4W.

Thanks again

Richard
druck
2019-03-25 20:26:23 UTC
Permalink
Post by Richard Ashbery
Many thanks Druck. I wish I could write a program as quickly as that!
Works a treat - just the job. I see you use MODE 1920,1080,32 which
makes a significant difference to the colour graduation smoothness.
No worries. I was able to do it remotely via VNC to my ARMx6 minim.
Post by Richard Ashbery
Presumably you've expanded the WHEN statements to make it clearer for
me but by combining each r,g,b parameter group into each WHEN line
almost halves the number of lines making routine quite compact.
Yes, it was a simple cut & paste job, and can be expressed far more simply.
Post by Richard Ashbery
I can link your routine with a rather unusual but very effective
multi-pattern pseudo 'lissajous' program written in BB4W.
Put it on some web space somewhere so we can all see it.

---druck
Richard Ashbery
2019-03-26 11:31:52 UTC
Permalink
In article <q7bdhi$q7i$***@dont-email.me>, druck <***@druck.org.uk>
wrote:

[snip]
Post by druck
Post by Richard Ashbery
I can link your routine with a rather unusual but very effective
multi-pattern pseudo 'lissajous' program written in BB4W.
Put it on some web space somewhere so we can all see it.
Unfortunately I'm without webspace at the moment. I've been too busy
with other projects to sort out a new provider. I'll try and do that
as soon as I've arranged webspace and got the program working
properly.

Regards

Richard

Loading...