Colour circle

You can create images yourself.  In this example an image with different colours is generated and the result is mapped to a circle using a vector-field.

See also

#!/usr/bin/env ruby
require 'hornetseye'
include Hornetseye
raise "Syntax: colours.rb <output file>" if ARGV.size != 1
class MultiArray
  class << self
    def ramp( w, h )
      idx = int( w, h ).indgen!
      retval = MultiArray.int 2, w, h
      retval.roll[ 0 ] = idx % w
      retval.roll[ 1 ] = idx / w
      retval
    end
  end
end
img = MultiArray.ubytergb( 361, 128 ).fill!
r = MultiArray.ramp *img.shape
x, y = r.roll[ 0 ], r.roll[ 1 ]
img.r = ( ( ( x - 180 ).abs -  60 ).clip( 0..60 ) * y ).normalise
img.g = ( ( 120 - ( x - 120 ).abs ).clip( 0..60 ) * y ).normalise
img.b = ( ( 120 - ( x - 240 ).abs ).clip( 0..60 ) * y ).normalise
r = MultiArray.ramp 256, 256
x, y = r.roll[ 0 ], r.roll[ 1 ]
warp = MultiArray.int 2, 256, 256
warp.roll[ 0 ] = Math.atan2( y - 128.0, x - 128.0 ) * 180.0 / Math::PI + 180.0
warp.roll[ 1 ] = Math.hypot( x - 128.0, y - 128.0 )
result = img.warp_clipped warp
result[   0... 20,   0... 20 ] = RGB 0xFF, 0x00, 0x00
result[ 235...255,   0... 20 ] = RGB 0x00, 0xFF, 0x00
result[   0... 20, 235...256 ] = RGB 0x00, 0x00, 0xFF
result[ 235...256, 235...256 ] = RGB 0xFF, 0xFF, 0xFF
result.save_ubytergb ARGV[0]
Close