Silverfrost Forums

Welcome to our forums

Clearwin colors

5 Mar 2019 12:38 #23319

I lifted below test program out of a large code to get a handle on clearwin which was not behaving well when I compiled my code 64 bit (it basically showed a black rectangle obscuring the black text)

When I compile below test code win 32 it shows a black rectangle if I use the the original draw_filled_rectangle statements and a green rectangle if I use the tweaked version (guessed the tweaked number).

I have 2 questions

1- Why is the original part of the code (thats works within the larger program) not working, and

2- Could someone perhaps point me to the section of the Clearwin manual that explains the coloring for draw rectangle

Thanks,

PROGRAM main

use clrwin

implicit none

INTEGER winio@, ans

ans=winio@('%ww[no_maxminbox]&') ans=winio@('%bg[grey]&') ans=winio@('%sp&',0L,0L) ans=winio@('%gr[rgb_colours]&',800,570)

call set_rgb_colours_default@(0)

call set_line_width@(2)

! Original draw filled rectangle statements ! call draw_filled_rectangle@(196,146,605,286,7) ! call draw_filled_rectangle@(191,151,600,291,15)

! Tweaked draw filled rectangle statements call draw_filled_rectangle@(196,146,605,286,1671168) call draw_filled_rectangle@(191,151,600,291,1671168)

call draw_rectangle@(191,151,600,291,4) call draw_rectangle@(194,154,597,288,1) call size_in_pixels@(21,12) call bold_font@(1) call draw_characters@('** Initialisation **',275,235,4) call set_line_width@(1)

ans=winio@(' ') ! added this to draw the thing

END PROGRAM main

5 Mar 2019 12:50 #23320

I would start by replacing your 'tweeked' numbers with a call to:

RGB@(RED,GREEN,BLUE)

Where RED, GREEN, and BLUE are integers in the range 0 to 255.

eg RGB@(255,0,0) generates RED.

5 Mar 2019 2:34 #23321

Joost,

For a very long time, CW+ had the original 16 colour VGA setup as its default. Some versions ago, Paul realised that the world had moved on, and changed the default to the RGB mode where you can set all colours to have R, G and B components in the range 0..255 inclusive.

The routine SET_RGB_COLOURS_DEFAULT@ with a parameter 0 is used to select the VGA 16 colour mode, and with parameter 1 to select RGB colour mode. Then, you use a different method for VGA or RGB colour modes. The VGA mode is utter rubbish, and modern software should use RGB mode. You get the colour number with the routine RGB@.

Eddie

6 Mar 2019 12:37 #23322

My legacy code works firn under 32 bit with the VGA 16 color schema, but does not work with 64 bit.

I tried to use SET_RGB_COLOURS_DEFAULT@ with a parameter 0 but that did not get the proper result either.

So it is probably better to goto the RGB color pallete.

As I have quite a few colors hardwired in the code.

It would be very useful to have a conversion from the clearwin VGA 16 to RGB.

I tried the corresponding RGB codes for the Microsoft Windows default 16-color palette from https://en.wikipedia.org/wiki/List_of_software_palettes but that did not work out.

Could anyone please point me to the correct conversion table.

6 Mar 2019 10:27 #23323

Hi Joost,

Black is RGB@(0,0,0) and white is RGB@(255,255,255). Silver and grey have the three colours in the same anounts (less for grey, more for silver). Lime is (0,255,0), red (255,0,0) and blue (0,0,255).

Look here, not quite halfway down the page:

https://www.rapidtables.com/web/color/RGB_Color.html

Regards, Eddie

7 Mar 2019 8:52 #23330

Because the code contains:

call set_rgb_colours_default@(0) 

Zero means 'False' and 1 means 'True'

Eddie

Please login to reply.