Color of a screen pixel: Difference between revisions
Content added Content deleted
Line 679:
=={{header|FutureBasic}}==
Tracks color information of the pixel under the current mouse x/y coordinates.
<syntaxhighlight lang="futurebasic">
_window = 1
begin enum 1
_view
_colorWell
_imageView
end enum
void local fn BuildWindow
window _window, @"ColorUnderMouse", (0,0,500,400), NSWindowStyleMaskTitled + NSWindowStyleMaskClosable▼
view subclass _view, (0,0,500,300)▼
▲window _window, @"ColorUnderMouse", (0,0,500,400), NSWindowStyleMaskTitled + NSWindowStyleMaskClosable
colorwell _colorWell, YES, fn ColorWhite, ( 410, 310, 70, 70 ), NO, _window▼
▲view subclass _view, (0,0,500,300)
▲colorwell _colorWell, YES, fn ColorWhite, ( 410, 310, 70, 70 ), NO, _window
end fn
void local fn DrawRect
CFArrayRef array = @[fn ColorRed, fn ColorOrange, fn ColorYellow, fn ColorGreen, fn ColorBlue, fn ColorWithRGB(0,0.29,0.51,1), fn ColorWithRGB(0.58,0.0,0.83,1)]▼
GradientRef grad = fn GradientWithColors( array )▼
▲CFArrayRef array = @[fn ColorRed, fn ColorOrange, fn ColorYellow, fn ColorGreen, fn ColorBlue, fn ColorWithRGB(0,0.29,0.51,1), fn ColorWithRGB(0.58,0.0,0.83,1)]
GradientDrawInRect( grad, fn ViewFrame(_view), 0 )▼
▲GradientRef grad = fn GradientWithColors( array )
▲GradientDrawInRect( grad, fn ViewFrame(_view), 0 )
end fn
void local fn DoMouse( tag as NSInteger )
CGPoint pt = fn EventLocationInView( tag )
ColorWellSetColor( _colorWell, color )▼
▲ColorWellSetColor( _colorWell, color )
cls : printf @"%.0fx, %.0fy, %@", pt.x, pt.y, color▼
▲cls : printf @"%.0fx, %.0fy, %@", pt.x, pt.y, color
end fn
void local fn DoDialog( ev as long, tag as long )
select ( tag )▼
case _view▼
▲select ( tag )
select ( ev )▼
▲case _view
case _viewDrawRect : fn DrawRect▼
▲select ( ev )
▲case _viewDrawRect : fn DrawRect
end select▼
▲case _viewMouseDragged : fn DoMouse( tag )
end select
▲end select
select ( ev )▼
case _windowWillClose : end▼
▲select ( ev )
end select▼
▲case _windowWillClose : end
▲end select
end fn
|