[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
obsolete[LuaStudio] Bitmap2
! Bitmap class methodsFor: #samples !
drawSprite: sprite
" Draw sprite "
| red green blue size graphics colours |
red := 16rFF0000.
green := 16r00FF00.
blue := 16r0000FF.
size := 100.
colours := Array with: red with: blue with: green.
graphics := sprite graphics.
graphics beginGradientFill: GradientType linear
colors: colours alphas: #(1 0.5 1)
ratios: #(0 200 255) matrix: nil
spreadMethod: nil
interpolationMethod: nil
focalPointRatio: 0.
graphics drawRect: 0 y: 0
width:100 height: 100.
graphics beginFill: 16r808080 alpha: 1.
graphics drawRect: 80 y: 80 width: 100 height: 100.
! !
! Bitmap class methodsFor: #samples !
colorTransformExample
" Color transform example "
| stage target data bmp bmp2 target box s
data2 |
stage := Display stage.
target := Display sprite new.
self drawSprite: target.
stage addChild: target.
data := BitmapData
bytes: (Lib project getBytes: '/assets/Image.jpg')
rawAlpha: nil.
bmp := (Bitmap
bitmapData: data
pixelSnapping: PixelSnapping auto
smoothing: false)
alpha: 0.5; x: 50; y: 50;
yourself.
target addChild: bmp.
target alpha: 0.5.
box := Display sprite new.
box alpha: 0.2.
self drawSprite: box.
box x: 160; y: 160.
stage addChild: box.
data := BitmapData inWidth: 100 inHeight: 100
inTransparent: true fillColor: 16r00
inGPUMode: nil.
s := Shape new.
s graphics
beginFill: 16r00FF00 alpha: 1;
drawCircle: 0 y: 0 radius: 100.
data draw: s matrix: nil colorTransform: nil blendMode: nil
clipRect: nil smoothing: false.
data2 := BitmapData inWidth: 100 inHeight: 100
inTransparent: true fillColor: 16r00
inGPUMode: nil.
data2 draw: (Bitmap
bitmapData: data
pixelSnapping: PixelSnapping auto
smoothing: false
)
matrix: nil
colorTransform: (ColorTransform
redMultiplier: 0 greenMultiplier: 0
blueMultiplier: 0 alphaMultiplier: -1
redOffset: 0 greenOffset: 0
blueOffset: 0 alphaOffset: 255
)
blendMode: nil clipRect: nil smoothing: false.
bmp2 := (Bitmap
bitmapData: data2
pixelSnapping: PixelSnapping auto
smoothing: false)
x: 200;
yourself.
stage addChild: bmp2.
target addEventListener: MouseEvent click
with: [:e | | t rOffset bOffset a |
t := stage transform.
rOffset := t colorTransform redOffset + 25.
bOffset := t colorTransform redOffset + 25.
a := stage alpha.
t colorTransform: (ColorTransform
redMultiplier: 1 greenMultiplier: 1
blueMultiplier: 1 alphaMultiplier: a * 0.9
redOffset: rOffset greenOffset: 0
blueOffset: bOffset alphaOffset: 0)
]! !
Bitmap colorTransformExample