Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Draw-a-sphere/FutureBasic/draw-a-sphere.basic
Normal file
38
Task/Draw-a-sphere/FutureBasic/draw-a-sphere.basic
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
_window = 1
|
||||
begin enum output 1
|
||||
_sphereImageView
|
||||
end enum
|
||||
|
||||
void local fn BuildWindow
|
||||
CGRect r = fn CGRectMake( 0, 0, 400, 400 )
|
||||
window _window, @"Rosetta Code Sphere", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable
|
||||
|
||||
r = fn CGRectMake( 20, 20, 360, 360 )
|
||||
imageview _sphereImageView, YES, , r, NSImageScaleAxesIndependently, NSImageAlignCenter, NSImageFrameNone, _window
|
||||
end fn
|
||||
|
||||
local fn SphereImageWithCIFilter( imageDimension as NSUInteger, sphereColor as ColorRef, backgroundColor as ColorRef, radiusBlur as float, radiusSphere as float ) as ImageRef
|
||||
CIVectorRef civ = fn CIVectorWithXY( imageDimension/2, imageDimension/2 )
|
||||
CIFilterRef filter = fn CIFilterWithName( @"CIRadialGradient" )
|
||||
CIFilterSetDefaults( filter )
|
||||
ObjectSetValueForKey( filter, civ, @"inputCenter" )
|
||||
ObjectSetValueForKey( filter, fn NumberWithFloat( radiusBlur ), @"inputRadius0" )
|
||||
ObjectSetValueForKey( filter, fn NumberWithFloat( radiusSphere ), @"inputRadius1" )
|
||||
ObjectSetValueForKey( filter, fn CIColorWithCGColor( fn ColorCGColor( sphereColor ) ), @"inputColor0" )
|
||||
ObjectSetValueForKey( filter, fn CIColorWithCGColor( fn ColorCGColor( backgroundColor ) ), @"inputColor1" )
|
||||
|
||||
ImageRef resultImage = fn ImageWithSize( fn CGSizeMake( imageDimension, imageDimension ) )
|
||||
ImageLockFocus( resultImage )
|
||||
CIImageDrawAtPoint( fn CIFilterOutputImage( filter ), CGPointZero, fn CGRectMake( 0, 0, imageDimension, imageDimension ), NSCompositeDestinationAtop, 1.0 )
|
||||
ImageUnlockFocus( resultImage )
|
||||
end fn = resultImage
|
||||
|
||||
local fn BuildSphere
|
||||
ImageRef sphereImage = fn SphereImageWithCIFilter( 340, fn ColorWithRGB( 0.988, 0.335, 0.176, 1.0 ), fn ColorBlack, 0.0, 125.0 )
|
||||
ImageViewSetImage( _sphereImageView, sphereImage )
|
||||
end fn
|
||||
|
||||
fn BuildWindow
|
||||
fn BuildSphere
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue