Color wheel: Difference between revisions
Content deleted Content added
m Uploaded Rust output file |
No edit summary |
||
Line 378:
Screenunlock
Loop Until Inkey = Chr(27)</syntaxhighlight>
=={{header|FutureBasic}}==
FB has native functions to construct color wheels.
<syntaxhighlight lang="futurebasic">
_window = 1
begin enum output 1
_colorwheelImageView
end enum
void local fn BuildWindow
'~'1
CGRect r = fn CGRectMake( 0, 0, 400, 400 )
window _window, @"ColorWheel", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable
r = fn CGRectMake( 20, 20, 360, 360 )
imageview _colorwheelImageView, YES, , r, NSImageScaleProportionallyUpOrDown, NSImageAlignCenter, NSImageFrameNone, _window
end fn
local fn CIImageToImageRef( ciImage as CIImageRef ) as ImageRef
'~'1
CIImageRepRef rep = fn CIImageRepWithCIImage( ciImage )
CGSize size = fn ImageRepSize( rep )
ImageRef image = fn ImageWithSize( size )
ImageAddRepresentation( image, rep )
end fn = image
local fn ColorWheelImage( colorSpace as CGColorSpaceRef, dither as CFNumberRef, radius as CFNumberRef, softness as CFNumberRef, lightness as CFNumberRef ) as CIImageRef
'~'1
CIFilterRef filter = fn CIFilterWithName( @"CIHueSaturationValueGradient" )
ObjectSetValueForkey( filter, colorSpace, @"inputColorSpace" )
ObjectSetValueForkey( filter, dither, @"inputDither" )
ObjectSetValueForkey( filter, radius, @"inputRadius" )
ObjectSetValueForkey( filter, softness, @"inputSoftness" )
ObjectSetValueForkey( filter, lightness, @"inputValue" )
CIImageRef outputCIImage = fn CIFilterOutputImage( filter )
end fn = outputCIImage
local fn BuildColorWheel
'~'1
CIImageRef colorWheelCIImage = fn ColorWheelImage( fn CGColorSpaceCreateDeviceRGB, @0, @160, @0, @1 )
ImageRef colorWheelImage = fn CIImageToImageRef( colorWheelCIImage )
ImageViewSetImage( _colorwheelImageView, colorWheelImage )
end fn
fn BuildWindow
fn BuildColorWheel
HandleEvents
</syntaxhighlight>
{{output}}
Final image [https://noahgilmore.com/static/d7ab3b40faa43c643473dd4c1c269b9e/e9755/cifilter-colorwheel-3.png here.]
|