Home Index classes Index static functions Index enumerations Index structure types

{Canvas|_to_draw}


CLASS {Canvas|_to_draw} , UNTESTED, BITWISE :


{Canvas} to draw on bitmap or {Paintbox} control.


IMPORT : {Bitmap} , {Control} , {AL4_form} , {AL4_drawing} .

{Bitmap} Bitmap_|to_draw_on_ , READ , INIT

Target {Bitmap} object or NONE (alternatively, the Control_ field should be set - for a canvas to draw on a {Paintbox} control).


{Control} Control_|to_paint_ , READ , INIT

Target {Control} object or NONE (alternatively, the Bitmap_ field should be set - for a canvas to draw on a {Bitmap} object).


INT Handle|_canvas_object , READ

The native descriptor to connect the AL-IV {Canvas} object to a native canvas object.


INT Printer_handle , READ

The same as above, but in case of drawing on a printer canvas.



------------------------------------------------------------------ 'colors'

INT Foreground|_color

The ink color used to draw foreground objects. It is sufficient to assigning it to any color before drawing using one of painting methods. Use PUSH statement to assign the Foreground value temporary and then return a previous value.


INT Background|_color

The same as above but for the background (fill) color.


BOOL Alpha|_channel_used_for_32_bpp_bitmaps

Set to TRUE to use alpha-channel on 32 bit bitmaps (of class {Bitmap}). If FALSE, then the high byte is ignored while drawing on a canvas.


  

ENUMERATION {rgba_order} :

        'R_G_B|_A|_mainly_in_windows' ,

        'B_G_R|_A|_usual_for_linux' .



FUN RGBA_order ==> {rgba_order}



---------------------------------------------------------- 'clip rectangle'

{Geometry}.{rect} Clip|_rect|angle||Clipping|_rect|angle

Set this rectangle to restrict drawing in its area only. If height or width of the Clip_rect is 0, it is just ignored while drawing.



FUN RGB|_to_color (
     
INT R|ed_0_to_255 ,
     
INT G|reen_0_to_255 ,
     
INT B|lue_0_to_255 ) ==> INT


The function converting 3 components R, B and B (0 to 255) to a color value representing by an integer value.


FUN Replace_alpha|_in_color (
     
INT C|olor_value ,
     
REAL A|lpha_value_0_to_1 ) ==> INT , IF A IS CONST , THEN A IN [0 TO 1] :


The function replacing the Alpha value of a color (and returning a color value with the new alpha channel vlaue).

CONSTANT INT :

          BLACK|_COLOR = 0xFF_00_00_00

          WHITE|_COLOR = 0xFF_FF_FF_FF

          MAROON|_COLOR = 0xFF_00_00_80

          GREEN|_COLOR = 0xFF_00_80_00

          OLIVE|_COLOR = 0xFF_00_80_80

          NAVY|_COLOR = 0xFF_80_00_00

          MAGENTA|_COLOR = 0xFF_80_00_80

          PURPLE|_SAME_AS_MAGENTA = 0xFF_80_00_80

          TEAL|_COLOR = 0xFF_80_80_00

          GRAY|_COLOR = 0xFF_80_80_80

          GREY|_SAME_AS_GRAY = 0xFF_80_80_80

          DK_GRAY|_COLOR = 0xFF_40_40_40

          DK_GREY|_COLOR = 0xFF_40_40_40

          SILVER|_COLOR = 0xFF_C0_C0_C0

          RED|_COLOR = 0xFF_00_00_FF

          LIME|_COLOR = 0xFF_00_FF_00

          YELLOW|_COLOR = 0xFF_00_FF_FF

          BLUE|_COLOR = 0xFF_FF_00_00

          FUCHSIA|_COLOR = 0xFF_FF_00_FF

          AQUA|_COLOR = 0xFF_FF_FF_00

          CYAN|_COLOR = 0xFF_FF_FF_00

          BROWN|_COLOR = 0xFF_50_50_A0

          DK_BROWN|_COLOR = 0xFF_30_30_60

          ORANGE|_COLOR = 0xFF_33_99_FF

          SKY_BLUE = 0xFF_F0_CA_A6

          LT_PINK|_COLOR = 0xFF_BF_B3_FF

          PINK|_COLOR = 0xFF_CB_C0_FF

          KHAKI|_COLOR = 0xFF_6B_86_78 .


A set of often used colors.


----------------------------------------------------------- 'system colors'

 

ENUMERATION {system_color} :

        'ACTIVE_CAPTION' ,

        'ACTIVE_GRADIENT' ,

        'ACTIVE_BORDER' ,

        'ACTIVE_TEXT' ,

        'BUTTON|_FACE' ,

        'BUTTON_TEXT' ,

        'BUTTON_HIGHLIGHT' ,

        'BUTTON_SHADOW' ,

        'DESKTOP|_BACKGROUND' ,

        'GRAY_TEXT' ,

        'HELP|_BACKGROUND' ,

        'HELP_TEXT' ,

        'INACTIVE_CAPTION' ,

        'INACTIVE_GRADIENT' ,

        'INACTIVE_BORDER' ,

        'INACTIVE_TEXT' ,

        'MENU|_BACKGROUND' ,

        'MENU_TEXT' ,

        'MENU_HIGHLIGHT' ,

        'SCROLLBAR' ,

        'WINDOW|_COLOR' ,

        'WINDOW_TEXT' ,

        'WINDOW_FRAME' ,

        'HIGHLIGHT' ,

        'HIGHLIGHT_TEXT' .


Available system colors. Can be used as a parameter for the function System_color returning current value of the specified system color.


FUN System_color ( {system_color} System|_name_color ) ==> INT


The function returning current value of the system color specified.


FUNCTION Mix|_colors ( INT C1|_color , INT C2|_color ) ==> INT


Mixing two colors to get an (almost) averange color or two.


FUNCTION Mix_percents (
     
INT C1|_color ,
     
INT C2|_color ,
     
INT Percents|_0_TO_100 ) ==> INT



--------------------------------------------------------------------- 'pen'

REAL Pen_width

The pen width. In differ to other measured sizes, the pen width is not specified in points but pixels are used. Also, as it was traditionally so, value 0 means "default" pen width which usually is 1 pixel.


{pen_style} Pen_style

The pen current style. To change at, as for most canvas attributes, just assign new value to it. Or, use PUSH to do so temporary.



ENUMERATION {pen_style} :

        'SOLID_PEN' ,

        'CLEAR_PEN' .


Available pen styles.


------------------------------------------------------------------- 'brush'

{brush_style} Brush|_style

The brush current style (used to fill a shape drawing). To change at, as for most canvas attributes, just assign new value to it. Or, use PUSH to do so temporary.



ENUMERATION {brush_style} :

        'SOLID_BRUSH' ,

        'CLEAR_BRUSH' ,

        'HORIZONTAL' ,

        'VERTICAL' ,

        'DIAGONAL' ,

        'BDIAGONAL' ,

        'CROSS|_BRUSH' ,

        'DIAGONAL_CROSS' .


Available brush styles. On some platforms, styles other then 'SOLID_BRUSH' and 'CLEAR_BRUSH' can be ignored (treated as 'SOLID_BRUSH').


-------------------------------------------------------------------- 'font'

{Font} Font|_tool , READ

Current font (to paint a text).



METHOD Set_font ( {Font} F|ont_set )


Setup font used to draw a text. Also, it is possible just to change fields of the Font property (filed) of the {Canvas} object: Face, Size, Bold, Italic, Underline.


METHOD Measure|_string (
     
STR S|tring_to_measure ) ==> {Geometry}.{rect}


Measuring size of a text which can be drawing with the current Font on the canvas. In returning rectangle, the Location pount is always Pt(0,0), Width and Height are done in current Units. To get maximum possible height of the current font, it is possible to pass a string "_/|". Or, just use the Font.Size (specified in poiunts) which in most of cases should be of exact such value. The width of leading and trailing spaces is always 0.


------------------------------------------------------------------- 'units'

{units} Units|_measure_graphics

Current measure units. By default, points are used, but it is possiblt to set other available units. This is not certain for a Pen_width which is always done in pixels.



ENUMERATION {units|_measure_graphics} :

        'POINTS|_UNITS' ,

        'PIXELS|_UNITS' ,

        'INCHES|_UNITS' ,

        'CENTIMETERS|_UNITS' .


Available measure units.


FUN Units_convert (
     
{units} Dest|ination ,
     
{units} Source|_units ,
     
REAL Value|_convert ) ==> REAL


Converting units from one to another.


FUN Points_to_pixels ( REAL P|oints_value ) ==> INT


Converting units from points to pixels (with rounding to integers).


FUN Pixels_to_points ( REAL P|ixels_value ) ==> REAL


Converting units from pixels to points.


---------------------------------------------------- 'construct / destruct'

   

FUNCTION New_canvas (
     
{Bitmap} B|itmap_to_paint_in ) ==> {Canvas} , NEW



FUNCTION New_paint_canvas|_may_not_be_supported_on_certain_platforms (
     
{Control} C|ontrol_paint ) ==> {Canvas} , NEW



FUNCTION New_print_canvas ( INT H|andle_printer ) ==> {Canvas} , NEW



------------------------------------------------------- 'drawing functions'

        

METHOD Erase|_entire_canvas



METHOD Rect|angle_draw ( {rect} R|ectangle )



METHOD Line|_draw (
     
{Geometry}.{point} P1|_from_point ,
     
{point} P2|_to_point )



METHOD Ellipse|_draw ( {rect} R|ectangle_ellipse )



STRUCTURE {arc|_information}

      {rect} R|ect|angle

      {point} A|ngles|_degrees_sector

      BOOL Sided|_shape .



METHOD Arc|_or_pie (
     
{rect} R|ectangle ,
     
{point} A|ngles_sector_2_angles_in_degrees ,
     
BOOL Sided|_shape )



METHOD Poly|line_polygon (
     
{point} P|oints_array [*] ,
     
BOOL Closed|_shape )



METHOD Text|_draw ( {point} Point|_top_left , STR Text|_to_draw )



---------------------------------------------------- 'coordinate transform'

      

METHOD Reset_transform|ations



METHOD Offset|_transform (
     
REAL Dx|_delta_points ,
     
REAL Dy|_delta_points )



METHOD Offset_pt || Offset_point_positive ( {point} P|oint_to_offset )



METHOD Offset_neg|ative_point ( {point} P|oint_to_offset )



METHOD Rotate|_transform ( REAL Angle|_in_degrees )



METHOD Scale|_transform ( REAL X_scale|_value , REAL Y_scale|_value )



--------------------------------------------------------- 'quality control'

 

ENUMERATION {quality|_drawing_lines_shapes} :

        'HIGH|_QUALITY' ,

        'MEDIUM|_QUALITY' ,

        'LOW|_QUALITY' .


{quality} Quality|_drawing



---------------------------------------- 'End of paint operations sequence'

 

METHOD End_paint



--------------------------------------------- 'operations between canvases'

 

METHOD Copy_rect|angle (
     
{rect} Dest|ination ,
     
{Canvas} From|_source_canvas ,
     
{rect} Source|_rectangle )


END