    indexing
    	description: "Color modeled as red, green, blue intensitieseach with range [0,1]."
    	legal: "See notice at end of class."
    	keywords: "color, pixel, rgb, 8, 16, 24"
    	status: "See notice at end of class."
    	date: "$Date: 2006-03-16 17:10:42 -0800 (Thu, 16 Mar 2006) $"
    	revision: "$Revision: 57525 $"

    class interface
    	EV_COLOR

    create
    	default_create
    			-- Standard creation procedure.
    			-- (from EV_ANY)
    		require -- from  ANY
    			True
    		ensure then -- from EV_ANY
    			is_coupled: implementation /= Void
    			is_initialized: is_initialized
    			default_create_called_set: default_create_called
    			is_in_default_state: is_in_default_state

    	make_with_8_bit_rgb (an_8_bit_red, an_8_bit_green, an_8_bit_blue: INTEGER_32)
    			-- Create with `a_red', `a_green', `a_blue', and default name.
    		require
    			red_within_range: an_8_bit_red >= 0 and an_8_bit_red <= max_8_bit
    			green_within_range: an_8_bit_green >= 0 and an_8_bit_green <= max_8_bit
    			blue_within_range: an_8_bit_blue >= 0 and an_8_bit_blue <= max_8_bit
    		ensure
    			red_assigned: red_8_bit = an_8_bit_red
    			green_assigned: green_8_bit = an_8_bit_green
    			blue_assigned: blue_8_bit = an_8_bit_blue

    	make_with_rgb (a_red, a_green, a_blue: REAL_32)
    			-- Create with `a_red', `a_green', `a_blue', and default name.
    		require
    			a_red_within_range: a_red >= 0 and then a_red <= 1
    			a_green_within_range: a_green >= 0 and then a_green <= 1
    			a_blue_within_range: a_blue >= 0 and then a_blue <= 1
    		ensure
    			red_assigned: (red - a_red).abs <= delta
    			green_assigned: (green - a_green).abs <= delta
    			blue_assigned: (blue - a_blue).abs <= delta

    feature -- Access

    	blue: REAL_32
    			-- Intensity of blue component. Range: [0,1]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.blue

    	data: ANY
    			-- Arbitrary user data may be stored here.
    			-- (from EV_ANY)

    	generating_type: STRING_8
    			-- Name of current object's generating type
    			-- (type of which it is a direct instance)
    			-- (from ANY)

    	generator: STRING_8
    			-- Name of current object's generating class
    			-- (base class of the type of which it is a direct instance)
    			-- (from ANY)

    	green: REAL_32
    			-- Intensity of green component. Range: [0,1]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.green

    	hue: REAL_32
    			-- Hue of the color
    		require
    			not_destroyed: not is_destroyed

    	lightness: REAL_32
    			-- Lightness of the color
    		require
    			not_destroyed: not is_destroyed

    	red: REAL_32
    			-- Intensity of red component. Range: [0,1]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.red

    	saturation: REAL_32
    			-- Saturation of the color
    		require
    			not_destroyed: not is_destroyed

    feature -- Comparison

    	copy (other: like Current)
    			-- Update `Current' by setting attributes from `other'.
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_equal: is_equal (other)

    	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void
    			-- or attached to isomorphic object structures?
    			-- (from ANY)
    		ensure -- from ANY
    			shallow_implies_deep: standard_equal (some, other) implies Result
    			both_or_none_void: (some = Void) implies (Result = (other = Void))
    			same_type: (Result and (some /= Void)) implies some.same_type (other)
    			symmetric: Result implies deep_equal (other, some)

    	frozen equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached
    			-- to objects considered equal?
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

    	is_equal (other: like Current): BOOLEAN
    			-- Does `Current' look the same color as `other'?
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			symmetric: Result implies other.is_equal (Current)
    			consistent: standard_is_equal (other) implies Result

    	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached to
    			-- field-by-field identical objects of the same type?
    			-- Always uses default object comparison criterion.
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

    	frozen standard_is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object of the same type
    			-- as current object, and field-by-field identical to it?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			same_type: Result implies same_type (other)
    			symmetric: Result implies other.standard_is_equal (Current)

    feature -- Status report

    	conforms_to (other: ANY): BOOLEAN
    			-- Does type of current object conform to type
    			-- of `other' (as per Eiffel: The Language, chapter 13)?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void

    	is_hashable: BOOLEAN
    			-- May current object be hashed?
    			-- (True if it is not its type's default.)
    			-- (from HASHABLE)
    		ensure -- from HASHABLE
    			ok_if_not_default: Result implies (Current /= default)

    	same_type (other: ANY): BOOLEAN
    			-- Is type of current object identical to type of `other'?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			definition: Result = (conforms_to (other) and other.conforms_to (Current))

    feature -- Element change

    	set_blue (a_blue: REAL_32)
    			-- Assign `a_blue' to blue.
    		require
    			not_destroyed: not is_destroyed
    			blue_within_range: a_blue >= 0 and then a_blue <= 1
    		ensure
    			blue_assigned: (blue - a_blue).abs <= delta

    	set_data (some_data: like data)
    			-- Assign `some_data' to data.
    			-- (from EV_ANY)
    		require -- from EV_ANY
    			not_destroyed: not is_destroyed
    		ensure -- from EV_ANY
    			data_assigned: data = some_data

    	set_green (a_green: REAL_32)
    			-- Assign `a_green' to green.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_green >= 0 and then a_green <= 1
    		ensure
    			green_assigned: (green - a_green).abs <= delta

    	set_red (a_red: REAL_32)
    			-- Assign `a_red' to red.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_red >= 0 and then a_red <= 1
    		ensure
    			red_assigned: (red - a_red).abs <= delta

    	set_rgb (a_red, a_green, a_blue: REAL_32)
    			-- Assign `a_red', `a_green' and `a_blue'
    			-- to red, green and blue respectively.
    		require
    			not_destroyed: not is_destroyed
    			red_within_range: a_red >= 0 and then a_red <= 1
    			green_within_range: a_green >= 0 and then a_green <= 1
    			blue_within_range: a_blue >= 0 and then a_blue <= 1
    		ensure
    			red_assigned: (red - a_red).abs <= delta
    			green_assigned: (green - a_green).abs <= delta
    			blue_assigned: (blue - a_blue).abs <= delta

    feature -- Conversion

    	blue_16_bit: INTEGER_32
    			-- Intensity of blue component as an 16 bit unsigned integer.
    			-- Range [0,65535]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.blue_16_bit

    	blue_8_bit: INTEGER_32
    			-- Intensity of blue component as an 8 bit unsigned integer.
    			-- Range [0,255]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.blue_8_bit

    	green_16_bit: INTEGER_32
    			-- Intensity of green component as an 16 bit unsigned integer.
    			-- Range [0,65535]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.green_16_bit

    	green_8_bit: INTEGER_32
    			-- Intensity of green component as an 8 bit unsigned integer.
    			-- Range [0,255]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.green_8_bit

    	red_16_bit: INTEGER_32
    			-- Intensity of red component as an 16 bit unsigned integer.
    			-- Range [0,65535]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.red_16_bit

    	red_8_bit: INTEGER_32
    			-- Intensity of red component as an 8 bit unsigned integer.
    			-- Range [0,255]
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.red_8_bit

    	rgb_24_bit: INTEGER_32
    			-- red, green and blue intensities packed into 24 bits
    			-- with 8 bits per colour and blue in the least significant 8 bits.
    		require
    			not_destroyed: not is_destroyed
    		ensure
    			bridge_ok: Result = implementation.rgb_24_bit

    	set_blue_with_16_bit (a_16_bit_blue: INTEGER_32)
    			-- Set blue from `a_16_bit_blue' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_16_bit_blue >= 0 and then a_16_bit_blue <= max_16_bit
    		ensure
    			blue_assigned: blue_16_bit = a_16_bit_blue

    	set_blue_with_8_bit (an_8_bit_blue: INTEGER_32)
    			-- Set blue from `an_8_bit_blue' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: an_8_bit_blue >= 0 and then an_8_bit_blue <= max_8_bit
    		ensure
    			blue_assigned: blue_8_bit = an_8_bit_blue

    	set_green_with_16_bit (a_16_bit_green: INTEGER_32)
    			-- Set green from `a_16_bit_green' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_16_bit_green >= 0 and then a_16_bit_green <= max_16_bit
    		ensure
    			green_assigned: green_16_bit = a_16_bit_green

    	set_green_with_8_bit (an_8_bit_green: INTEGER_32)
    			-- Set green from `an_8_bit_green' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: an_8_bit_green >= 0 and then an_8_bit_green <= max_8_bit
    		ensure
    			green_assigned: green_8_bit = an_8_bit_green

    	set_red_with_16_bit (a_16_bit_red: INTEGER_32)
    			-- Set red from `a_8_bit_red' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_16_bit_red >= 0 and then a_16_bit_red <= max_16_bit
    		ensure
    			red_assigned: red_16_bit = a_16_bit_red

    	set_red_with_8_bit (an_8_bit_red: INTEGER_32)
    			-- Set red from `an_8_bit_red' intinsity.
    		require
    			not_destroyed: not is_destroyed
    			within_range: an_8_bit_red >= 0 and then an_8_bit_red <= max_8_bit
    		ensure
    			red_assigned: red_8_bit = an_8_bit_red

    	set_rgb_with_16_bit (a_16_bit_red, a_16_bit_green, a_16_bit_blue: INTEGER_32)
    			-- Set intensities  from `a_16_bit_red', `a_16_bit_green', and
    			-- `a_16_bit_blue' intensity. (16 bits per channel.)
    		require
    			not_destroyed: not is_destroyed
    			red_within_range: a_16_bit_red >= 0 and a_16_bit_red <= max_16_bit
    			green_within_range: a_16_bit_green >= 0 and a_16_bit_green <= max_16_bit
    			blue_within_range: a_16_bit_blue >= 0 and a_16_bit_blue <= max_16_bit
    		ensure
    			red_assigned: red_16_bit = a_16_bit_red
    			green_assigned: green_16_bit = a_16_bit_green
    			blue_assigned: blue_16_bit = a_16_bit_blue

    	set_rgb_with_24_bit (a_24_bit_rgb: INTEGER_32)
    			-- Set intensities from `a_24_bit_rgb' value
    			-- with blue in the least significant 8 bits.
    		require
    			not_destroyed: not is_destroyed
    			within_range: a_24_bit_rgb >= 0 and a_24_bit_rgb <= max_24_bit
    		ensure
    			rgb_assigned: rgb_24_bit = a_24_bit_rgb

    	set_rgb_with_8_bit (an_8_bit_red, an_8_bit_green, an_8_bit_blue: INTEGER_32)
    			-- Set intensities  from `an_8_bit_red', `an_8_bit_green', and
    			-- `an_8_bit_blue' intensity. (8 bits per channel.)
    		require
    			not_destroyed: not is_destroyed
    			red_within_range: an_8_bit_red >= 0 and an_8_bit_red <= max_8_bit
    			green_within_range: an_8_bit_green >= 0 and an_8_bit_green <= max_8_bit
    			blue_within_range: an_8_bit_blue >= 0 and an_8_bit_blue <= max_8_bit
    		ensure
    			red_assigned: red_8_bit = an_8_bit_red
    			green_assigned: green_8_bit = an_8_bit_green
    			blue_assigned: blue_8_bit = an_8_bit_blue

    feature -- Duplication

    	frozen deep_copy (other: like Current)
    			-- Effect equivalent to that of:
    			--		copy (`other' . deep_twin)
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, other)

    	frozen deep_twin: like Current
    			-- New object structure recursively duplicated from Current.
    			-- (from ANY)
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, Result)

    	frozen standard_copy (other: like Current)
    			-- Copy every field of `other' onto corresponding field
    			-- of current object.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_standard_equal: standard_is_equal (other)

    	frozen standard_twin: like Current
    			-- New object field-by-field identical to `other'.
    			-- Always uses default copying semantics.
    			-- (from ANY)
    		ensure -- from ANY
    			standard_twin_not_void: Result /= Void
    			equal: standard_equal (Result, Current)

    	frozen twin: like Current
    			-- New object equal to `Current'
    			-- twin calls copy; to change copying/twining semantics, redefine copy.
    			-- (from ANY)
    		ensure -- from ANY
    			twin_not_void: Result /= Void
    			is_equal: Result.is_equal (Current)

    feature -- Basic operations

    	frozen default: like Current
    			-- Default value of object's type
    			-- (from ANY)

    	frozen default_pointer: POINTER
    			-- Default value of type `POINTER'
    			-- (Avoid the need to write `p'.default for
    			-- some `p' of type `POINTER'.)
    			-- (from ANY)

    	default_rescue
    			-- Process exception for routines with no Rescue clause.
    			-- (Default: do nothing.)
    			-- (from ANY)

    	frozen do_nothing
    			-- Execute a null action.
    			-- (from ANY)

    feature -- Command

    	destroy
    			-- Destroy underlying native toolkit object.
    			-- Render `Current' unusable.
    			-- (from EV_ANY)
    		ensure -- from EV_ANY
    			is_destroyed: is_destroyed

    feature -- Constants

    	max_16_bit: INTEGER_32 is 65535
    			-- Maximum value for 16 bit unsigned integers.

    	max_24_bit: INTEGER_32 is 16777215
    			-- Maximum value for 24 bit unsigned integers.

    	max_8_bit: INTEGER_32 is 255
    			-- Maximum value for 8 bit unsigned integers.

    feature -- Hashable

    	hash_code: INTEGER_32
    			-- Hash code value
    		ensure -- from HASHABLE
    			good_hash_value: Result >= 0

    feature -- Output

    	io: STD_FILES
    			-- Handle to standard file setup
    			-- (from ANY)

    	out: STRING_8
    			-- Textual representation.

    	print (some: ANY)
    			-- Write terse external representation of `some'
    			-- on standard output.
    			-- (from ANY)

    	frozen tagged_out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of out.
    			-- (from ANY)

    feature -- Platform

    	operating_environment: OPERATING_ENVIRONMENT
    			-- Objects available from the operating system
    			-- (from ANY)

    feature -- Status Report

    	is_destroyed: BOOLEAN
    			-- Is `Current' no longer usable?
    			-- (from EV_ANY)
    		ensure -- from EV_ANY
    			bridge_ok: Result = implementation.is_destroyed

    invariant
    	red_within_range: red >= 0 and red <= 1
    	green_within_range: green >= 0 and green <= 1
    	blue_within_range: blue >= 0 and blue <= 1
    	red_8_bit_within_range: red_8_bit >= 0 and red_8_bit <= max_8_bit
    	green_8_bit_within_range: green_8_bit >= 0 and green_8_bit <= max_8_bit
    	blue_8_bit_within_range: blue_8_bit >= 0 and blue_8_bit <= max_8_bit
    	red_16_bit_within_range: red_16_bit >= 0 and red_16_bit <= max_16_bit
    	green_16_bit_within_range: green_16_bit >= 0 and green_16_bit <= max_16_bit
    	blue_16_bit_within_range: blue_16_bit >= 0 and blue_16_bit <= max_16_bit
    	rgb_24_bit_within_range: rgb_24_bit >= 0 and rgb_24_bit <= max_24_bit
    	red_16_bit_conversion: ((red * max_16_bit) - red_16_bit).abs <= delta * max_16_bit
    	red_8_bit_conversion: ((red * max_8_bit) - red_8_bit).abs <= delta * max_8_bit
    	green_16_bit_conversion: ((green * max_16_bit) - green_16_bit).abs <= delta * max_16_bit
    	green_8_bit_conversion: ((green * max_8_bit) - green_8_bit).abs < delta * max_8_bit
    	blue_16_bit_conversion: ((blue * max_16_bit) - blue_16_bit).abs < delta * max_16_bit
    	blue_8_bit_conversion: ((blue * max_8_bit) - blue_8_bit).abs < delta * max_8_bit

    		-- from EV_ANY
    	is_initialized: is_initialized
    	is_coupled: implementation /= Void and then implementation.interface = Current
    	default_create_called: default_create_called

    		-- from ANY
    	reflexive_equality: standard_is_equal (Current)
    	reflexive_conformance: conforms_to (Current)

    indexing
    	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
    	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
    	source: "[
    		Eiffel Software
    		356 Storke Road, Goleta, CA 93117 USA
    		Telephone 805-685-1006, Fax 805-685-6869
    		Website http://www.eiffel.com
    		Customer support http://support.eiffel.com
    	]"

    end -- class EV_COLOR