Generic Function | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## paint-operation

Arguments: graphical-stream

Returns the current paint operation of the specified stream, which should be a `graphical-stream`. The value may be changed at any time by calling (setf paint-operation) or with-paint-operation. The initial paint operation of any graphical-stream is `po-replace`.

A paint operation determines how the colors of new content that is being drawn are combined with the current colors of the stream's pixels to determine the final colors that will appear.

A paint operation value should be the value of one of the following constants: `po-replace`, `po-paint`, `po-xor`, `po-invert`, `po-fill`, `po-erase`, and `po-and`.

On the Windows platform, an alternate paint operation will not be used for line drawing when `*antialiasing*` is true, and will not be used for area filling when `*color-gradient-filling*` is true. The reason is those variables cause Common Graphics to use the newer GDI+ library of Windows graphics functions, while paint operations are provided only by the older GDI library that Common Graphics uses otherwise.

Here is an example that uses some of the possible values:

    (in-package :cg-user)

    (let* ((frame (make-window :paint-operations
                    :class 'bitmap-window
                    :exterior (make-box-relative 100 200 300 300)))
           (pane (frame-child frame)))

      ;; Starting out with a black background is handy for
      ;; some paint operations.
      (with-background-color (pane black)
        (clear-page pane))

      ;; Draw a basic red block using the default po-replace operation.
      (with-foreground-color (pane red)
        (fill-box pane (make-box 40 40 200 200)))

      ;; Use po-paint to merge part of a dark-green block
      ;; with part of the red block.
      (with-paint-operation (pane po-paint)
        (with-foreground-color
            (pane (make-rgb :red 60 :green 130 :blue 40))
          (fill-box pane (make-box 100 100 240 240))))

      ;; Use po-erase to draw an upper line that erases redness.
      (with-line-width (pane 7)
        (with-foreground-color (pane red)
          (with-paint-operation (pane po-erase)
            (draw-line pane (make-position 0 0)
                       (make-position 300 300)))

          ;; And finally use po-and to draw a lower line that
          ;; erases all color EXCEPT redness.
          (with-paint-operation (pane po-and)
            (draw-line pane (make-position 0 0)
                       (make-position 300 400))))))

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version