[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
obsolete[LuaStudio] Bitmap
! Bitmap class methodsFor: #samples !
example
" Cache as bitmap, example "
| circle stage gfx colours alphas mtx focal shape bmp bitmap
combined matrix ratios f strip |
circle := Display sprite new.
stage := Display stage.
gfx := circle graphics.
colours := #(16rFF0000 16r000000).
alphas := #(1 1).
ratios := #(0 255).
mtx := Matrix a: 1 b: 0 c: 0 d: 1 tx: 0 ty: 0.
focal := -0.9.
mtx createGradientBox: 100 height: 100
rotation: 0 tx: 0 ty: 0.
gfx beginGradientFill: GradientType radial
colors: colours alphas: alphas ratios: ratios
matrix: mtx spreadMethod: SpreadMethod repeat
interpolationMethod: InterpolationMethod linearRgb
focalPointRatio: focal.
gfx drawRect: 0 y: 0 width: 100 height: 100.
stage addChild: circle.
circle cacheAsBitmap: true; x: 200; y: 200.
f := DropShadowFilter distance: 4 angle: 45
color: 0 alpha: 1 blurX: 4 blurY: 4
strength: 1 quality: 1
inner: false knockout: false
hideObject: false.
circle filters: (Array with: f).
shape := Shape new.
gfx := shape graphics.
gfx lineStyle: 3 color: 16r0000FF alpha: 1
pixelHinting: false scaleMode: nil
caps: nil joints: nil miterLimit: 3.
gfx moveTo: 5 y: 5.
gfx lineTo: 25 y: 25.
bmp := BitmapData inWidth: 32 inHeight: 32
inTransparent: true fillColor: 0
inGPUMode: nil.
bmp draw: shape matrix: nil colorTransform: nil
blendMode: nil clipRect: nil smoothing: false.
bitmap := (Bitmap
bitmapData: bmp
pixelSnapping: nil
smoothing: false)
x: 50; y: 50; yourself.
stage addChild: bitmap.
combined := BitmapData inWidth: 200 inHeight: 200
inTransparent: true fillColor: 0
inGPUMode: nil.
matrix := Matrix a: 1 b: 0 c: 0 d: 1 tx: 0 ty: 0.
0 to: 4 do: [:x |
0 to: 4 do: [:y |
matrix tx: x * 20; ty: y * 20.
combined draw: bmp matrix: matrix
colorTransform: nil
blendMode: nil clipRect: nil
smoothing: false.
]
].
bitmap := (Bitmap
bitmapData: combined
pixelSnapping: nil
smoothing: false)
x: 150; y: 50; yourself.
stage addChild: bitmap.
strip := (self createStrip: InterpolationMethod linearRgb)
x: 20; y: 300; yourself.
stage addChild: strip.
strip := (self createStrip: InterpolationMethod rgb)
x: 20; y: 400; yourself.
stage addChild: strip.
stage addEventListener: Event enterFrame
with: [:e | circle rotation: circle rotation + 1 ]! !
! Bitmap class methodsFor: #samples !
createStrip: inMethod
" Create strip "
| shape gfx mtx colours alphas ratios |
shape := Display sprite new.
gfx := shape graphics.
mtx := Matrix a: 1 b: 0 c: 0 d: 1 tx: 0 ty: 0.
mtx createGradientBox: 250 height: 50 rotation: 0 tx: 0 ty: 0.
colours := #(16rFF0000 16r00FF00 16r0000FF).
alphas := #(1 1 1).
ratios := #(0 128 255).
gfx beginGradientFill: GradientType linear
colors: colours alphas: alphas ratios: ratios
matrix: mtx spreadMethod: SpreadMethod repeat
interpolationMethod: inMethod
focalPointRatio: -0.9.
gfx drawRect: 0 y: 0 width: 250 height: 50.
shape addEventListener: MouseEvent click
with: [:e | self print: #click ].
^shape! !
Bitmap example