ClearWin+ ARGB colours and anti-aliasing
----------------------------------------

New options [smooth4] and [smooth8] have been added to %gr in order to provide a simple and direct way to add anti-aliasing
smoothing to existing code. smooth4 uses an 8x4 box filter whilst smooth8 uses an 8x8 box. When using these options the 
following details may not be needed.

New ClearWin+ functions SET_OPACITY@ and SET_SMOOTHING_MODE@ have been added in order to provide access to the Microsoft GDI+ library.
SET_OPACITY@ enables programmers to set the alpha value for colours whilst SET_SMOOTHING_MODE@ provides smoothing effects such as 
anti-aliasing. With these new functions, standard ClearWin+ drawing routines like draw_line_between@ and draw_characters@ (see list
below) can be used without change. 

INTEGER FUNCTION SET_OPACITY@(Opacity)
INTEGER opacity

A value for Opacity in the range 0-255 inclusive, sets this as the default value for the current drawing surface and activates the GDI+
library. A value of 256 (the initial default) indicates that the GDI+ library is not to be used. This function returns the previous 
opacity value.

INTEGER FUNCTION SET_SMOOTHING_MODE@(Mode)
INTEGER Mode

This function returns the previous mode and sets the new mode for the current drawing surface in the range 0-5 inclusive with the 
following outline:

    SmoothingModeDefault      = 0 (no smoothing)
    SmoothingModeHighSpeed    = 1 (no smoothing)
    SmoothingModeHighQuality  = 2 (8x4 box filter)
    SmoothingModeNone         = 3 (no smoothing)
    SmoothingModeAntiAlias8x4 = 4 (8x4 box filter)
    SmoothingModeAntiAlias8x8 = 5 (8x8 box filter)

Note that, if the current opacity is 256 then calling SET_SMOOTHING_MODE@ will set the opacity to 255 to activate the GDI+ library.

%gr[smooth4] sets the opacity to 255 and the smoothing mode to 4.
%gr[smooth8] sets the opacity to 255 and the smoothing mode to 5.

INTEGER FUNCTION USE_GDIPLUS@(state)
INTEGER state

A non-zero value for 'state' enables the GDI+ by setting the default opacity to 255 when drawing surfaces are created.
This function returns the previous state.

FUNCTION nARGB@(a,r,g,b)
INTEGER a,r,g,b
a is the opacity and r,g,b are the colour intensities. All values are assumed to be in the range 0-255 inclusive.
This function returns the RGB@ value and has the side effect of storing the opacity for the next call to a drawing routine.
This temporary value is reset to the default opacity after its first use and this value over-rides the default opacity for 
the current drawing surface. When nARGB@ is called in an argument of a graphics routine then the stored opacity will 
relate to the current call.

The following existing routines have been extended to use the opacity and smoothing parameters:

DRAW_LINE_BETWEEN@
DRAW_RECTANGLE@
DRAW_FILLED_RECTANGLE@
DRAW_ELLIPSE@
DRAW_FILLED_ELLIPSE@
DRAW_POYLINE@
DRAW_FILLED_POLYGON@
DRAW_CHARACTERS@     (but not rotated text)

The following routines have been added and take DOUBLE PRECISION values for co-ordinate points:

DRAW_LINE_BETWEEND@
DRAW_RECTANGLED@
DRAW_FILLED_RECTANGLED@
DRAW_ELLIPSED@
DRAW_FILLED_ELLIPSED@
DRAW_POYLINED@
DRAW_FILLED_POLYGOND@
DRAW_CHARACTERSD@    (but not rotated text)

Graphics Printing
-----------------
OPEN_PRINTER@ and CLOSE_PRINTER@ will use the GDI+ library provided the smoothing and/or opacity is set.
Call USE_GDIPLUS@ before opening the pringer or set the opacity and/or the smoothing after opening.

Metafiles
---------
In ClearWin+ a metafile is always associated with an existing drawing surface with which it shares the same
smoothing mode and default opacity.

a) %gr[metafile_resize] can be used together with [smooth4] or [smooth8].
   A new option [keep_aspect_ratio] has been added in this context.
   
b) METAFILE_TO_CLIPBOARD@ and PLAY_CLIPBOARD_METAFILE@ have been extended.

c) OPEN_METAFILE@ after OPEN_PRINTER@ (for use with DO_COPIES@) has been extended
   but note that modern printers will provide multiple copies without using a metafile.

Mixing calls to GDI and GDI+
----------------------------
    
nARGB@ can be used to active the GDI+ library for the next drawing routine only, thus allowing GDI+ calls to be mixed with 
non-GDI+ calls as illustrated in the following sample. Mixing calls in this way is not premitted when using %gr[metafile_resize].

A Sample Program in Fortran
---------------------------
winapp 
program main
include <windows.ins>
c_external nARGB@              '__nargb'(VAL,VAL,VAL,VAL):integer
c_external SET_SMOOTHING_MODE@ '__set_smoothing_mode'(VAL):integer

  iw = winio@("%gr&",450,200)
  call set_line_width@(8)
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_SQUARE)
  call draw_line_between@(5,4,5,108,  nARGB@(255,0,0,255))
  call draw_line_between@(25,4,25,108,  RGB@(255,0,0))
  call draw_line_between@(5,10,25,10, nARGB@(255,0,255,0))
  call draw_line_between@(5,30,25,30, nARGB@(192,0,255,0))
  call draw_line_between@(5,50,25,50,   RGB@(255,0,255))
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_FLAT)
  call set_line_width@(16)
  iw = set_smoothing_mode@(5)        !SmoothingModeAntiAlias8x8
  call draw_line_between@(50,4,150,104,         RGB@(255,0,0))
  call draw_line_between@(150,4,50,104,       nARGB@(192,0,0,255))
  call draw_ellipse@(225,60,50,50,            nARGB@(255,0,255,0))
  call draw_filled_ellipse@(225,60,50,50,     nARGB@(192,255,0,0))
  call draw_rectangle@(320,10,420,110,        nARGB@(255,255,0,0))
  call draw_filled_rectangle@(320,10,420,110, nARGB@(192,0,255,0))
  call select_font@("Arial")
  call size_in_pixels@(24,0)
  call italic_font@(1)
  call bold_font@(1)
  call draw_characters@("AntiAlias Smoothing", 65, 150, RGB@(255,0,0,255)) 
  iw = winio@(" ")
end


A Sample Program in C (SCC or third compiler)
--------------------------------------------
#include <windows.h>
#include <stdio.h>
#include "clrwin32.h"

#define FULL 255
#define HALF 192

int main()
{
  winio("%gr&",450,200);
  set_line_width(8);
  set_line_style(PS_GEOMETRIC|PS_ENDCAP_SQUARE);
  draw_line_between(5,4,5,108,  nARGB(FULL,0,0,255));
  draw_line_between(25,4,25,108,  RGB(255,0,0));
  draw_line_between(5,10,25,10, nARGB(FULL,0,255,0));
  draw_line_between(5,30,25,30, nARGB(HALF,0,255,0));
  draw_line_between(5,50,25,50,   RGB(255,0,255)); 
  set_line_style(PS_GEOMETRIC|PS_ENDCAP_FLAT);
  set_line_width(16);
  set_smoothing_mode(5);   //SmoothingModeAntiAlias8x8
  draw_line_between(50,4,150,104,         RGB(255,0,0));
  draw_line_between(150,4,50,104,       nARGB(HALF,0,0,255));
  draw_ellipse(225,60,50,50,            nARGB(FULL,0,255,0));
  draw_filled_ellipse(225,60,50,50,     nARGB(HALF,255,0,0));
  draw_rectangle(320,10,420,110,        nARGB(FULL,255,0,0));
  draw_filled_rectangle(320,10,420,110, nARGB(HALF,0,255,0));
  select_font("Arial"); size_in_pixels(24, 0); italic_font(1); bold_font(1);
  draw_characters("AntiAlias Smoothing", 65, 150, RGB(FULL,0,0,255)); 
  winio(" ");
  return 0;
}


