Skip to content

set_colorSetColorSetColorset_colorT_set_color🔗

Short description🔗

set_colorSetColorSetColorset_colorT_set_color — Set output color.

Signature🔗

set_color( window WindowHandle, string Color )void SetColor( const HTuple& WindowHandle, const HTuple& Color )static void HOperatorSet.SetColor( HTuple windowHandle, HTuple color )def set_color( window_handle: HHandle, color: MaybeSequence[str] ) -> None

Herror T_set_color( const Htuple WindowHandle, const Htuple Color )

void HWindow::SetColor( const HTuple& Color ) const

void HWindow::SetColor( const HString& Color ) const

void HWindow::SetColor( const char* Color ) const

void HWindow::SetColor( const wchar_t* Color ) const (Windows only)

void HWindow.SetColor( HTuple color )

void HWindow.SetColor( string color )

Description🔗

set_colorSetColor defines the colors for region output in the window. The available colors can be queried with the operator query_colorQueryColor. In addition, the Colorcolorcolor may be specified as hexadecimal RGB triplet or RGBA quadruplet in the form '#rrggbb'"#rrggbb" and '#rrggbbaa'"#rrggbbaa". ‘rr’, ‘gg’, ‘bb’, and ‘aa’ are hexadecimal numbers between ‘00’ and ‘ff’, respectively. ‘aa’ denotes the alpha value of a color and can be used to display transparent regions.

The parameter Colorcolorcolor can contain a single color or a tuple with up to 256 colors. If only a single color is passed, all output is in this color. If a tuple of colors is passed, the output color of regions is modulo to the number of colors. In the example below, the first circle is displayed red, the second in transparent green and the third in red again. HALCON always begins output with the first color passed. Note, that the number of output colors depends on the number of objects that are displayed in one operator call. If only single objects are displayed, they always appear in the first color, even if they consist of more than one connected component.

The defined colors are used until set_colorSetColor, set_rgbSetRgb, set_rgbaSetRgba, set_hsiSetHsi or set_graySetGray is called again.

Colors are defined separately for each window. They can only be changed for the valid window.

Colorcolorcolor is used in operators with region output like disp_regionDispRegion, disp_lineDispLine, disp_rectangle1DispRectangle1, or disp_arrowDispArrow.

Examples of possible color strings

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

WindowHandlewindowHandlewindow_handle (input_control) window → (handle)HTuple (HHandle)HWindow, HTuple (IntPtr)HHandleHtuple (handle)

Window handle.

Colorcolorcolor (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Output color names.

Default: 'white'"white"
Suggested values: 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'dim gray', 'gray', 'light gray', 'medium slate blue', 'coral', 'slate blue', 'spring green', 'orange red', 'orange', 'dark olive green', 'pink', 'cadet blue', '#003075', '#e53019', '#ffb529', '#f28d26bb'"black", "white", "red", "green", "blue", "cyan", "magenta", "yellow", "dim gray", "gray", "light gray", "medium slate blue", "coral", "slate blue", "spring green", "orange red", "orange", "dark olive green", "pink", "cadet blue", "#003075", "#e53019", "#ffb529", "#f28d26bb"

Example🔗

(HDevelop)

set_color(WindowHandle, ['red', '#00ff00a0'])
disp_circle(WindowHandle, [100,200,300], [200,300,100], [100,100,100])

Result🔗

set_colorSetColor returns 2 (H_MSG_TRUE) if the window is valid and the passed colors are displayable on the screen. Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

query_colorQueryColor

Possible successors

disp_regionDispRegion

Alternatives

set_rgbSetRgb, set_hsiSetHsi

See also

get_rgbGetRgb, disp_regionDispRegion, set_paintSetPaint

Module🔗

Foundation