Color mixer example

Simple example to show some color manipulation functions.

Compilation

Easiest way to get this example running is to go to examples directory in package root, and run:

$ ./build.sh color_mix

build.sh script compiles Ano script to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.

Preview

; ------------------------------------------------------------------------------
; color_mix.ano
;
; To compile:
;
; $ ./build/ano ./examples/color_mix/color_mix.ano > \
;     engine/dsl_ano.h
; ------------------------------------------------------------------------------
;
@ANO_SCRIPT_NAME		color_mix
@ANO_SCRIPT_VERSION		0.0.1
@ANO_SCRIPT_DESCRIPTION	Simple example to mix two colors together
;
@ANO_FLAGS_USE_PROTOS		[ ]
@ANO_FLAGS_VAR_NAME_SUBS	[ ]
@ANO_FLAGS_VAR_WARN_UNUSED	[ ]
;
; Copyright © 2016-2026, Jani Salonen <salojan@goto10.co>
; All rights reserved.
;
; Simple example to show some color manipulation functions.
;

main [exit: 0] {
	; Mix two colors together using factor of 0.5.
	;
	mov	_col1 ("blue")
	mov	_col2 (# 0xaa, 0x00, 0x00, 0xff)

	color_mix (_col1, _col2, 0.5)

	print "1. Mixing " . _col1 . " and " . _col2 . " together produces" \
		" RGBA color of " . rc . ".\n"

	; Get complement color and its brightness.
	;
	color_complement ("orange")

	print "2. Complement color of orange is " . rc . "…\n"

	color_brightness (rc)

	print "   …which brightness is " . rc . " in scale of 0-255.\n";
}
; ------------------------------------------------------------------------------
; color_mix.w2c
;
; To compile:
;
; $ ./build/widget ./examples/color_mix/color_mix.w2c > \
;     engine/widget_defs.h
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; color_mix.m2c
;
; To compile:
;
; $ ./build/menu ./examples/color_mix/color_mix.m2c > \
;     engine/menu_defs.h
; ------------------------------------------------------------------------------

Copyright © 2026, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.