Colour space and greyscale

For finished programs
Post Reply
User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Colour space and greyscale

Post by Dutchman » Tue Sep 10, 2019 5:35 pm

Color selection is easy with HSV2RGB|3 ;)
Greyscale requires encoding gamma for visual linear scale.
Mac gamma equals 2.2, so encoding gamma = 1/2.2 = 0.45.

Code: Select all

'Colour space with grey scale
'by "Dutchman" Ton Nillesen
'august 2019
sw sh = SCRSIZE|2
midx midy = sw/2 sh/2
Radius=INT(0.8*MIN(midx,midy))
Ratio=360/2/PI ' ratio between degrees and radians
dphi=0.9/Radius
'--- set grey radius
grey=INT(Radius/3)
'---- Graphics
DRAW CLEAR 0,0,0
phi=0
DO
  dx=COS(phi) : dy=SIN(phi)
'--- greyscale, saturation=0
  DRAW COLOR 0,0,0
  DRAW POINT midx midy ' start at center
  FOR i=0 to grey
    DRAW COLOR HSV2RGB|3 (x, 0, (i/grey)^0.45) ' with encoding gamma
    DRAW TO midx+i*dx midy+i*dy
  NEXT
'---- saturating color
  rest=Radius-grey
  FOR i=0 TO rest
    DRAW COLOR HSV2RGB|3 (phi*ratio, i/rest, 1)
    DRAW TO midx+(grey+i)*dx midy+(grey+i)*dy
  NEXT
  phi+=dphi
REDO IF phi<2*PI
END
Colour space and greyscale.png
Colour space and greyscale.png (100.01 KiB) Viewed 207 times
It is still a long way to go

User avatar
kibernetik
Site Admin
Posts: 131
Joined: Tue Aug 06, 2019 3:03 pm

Re: Colour space and greyscale

Post by kibernetik » Tue Sep 10, 2019 5:50 pm

What do you think, do we need such built-in constants as 2PI and PI2, where 2PI = 2*PI and PI2 = PI/2 ?

User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Re: Colour space and greyscale

Post by Dutchman » Tue Sep 10, 2019 8:10 pm

Not for me, I have a lot of other wishes.
However, I trust the app's steady growth into maturity. :D
It is still a long way to go

Post Reply