赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 8 |
经验 | 132 |
最后登录 | 2014-9-6 |
在线时间 | 1270 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 777
- 在线时间
- 1270 小时
- 注册时间
- 2011-2-14
- 帖子
- 5589
|
- #=============================================================================
- # ■ Bitmap重定义
- #=============================================================================
-
- class Sprite
- alias ud update
- def update
- self.bitmap = self.bitmap.exc
- ud
- end
- end
- class Bitmap
- def blur(strength = 1, opacity = 5)
- blur_in(strength, opacity)
- extend(strength,strength,strength,strength)
- end
- def exc
- return self if not @excb
- self.dispose
- return @excb
- end
- def blur_in(strength = 1, opacity = 10)
- (-strength).upto(strength) do |x|
- (-strength).upto(strength) do |y|
- next if x.zero? and y.zero?
- src_rect = Rect.new(0, 0, width - x, height - y)
- blt(x, y, self, src_rect, opacity)
- end
- end
- end
- def extend(lx,ly,rx,ry)
- new_bitmap = Bitmap.new(width+lx+rx,height+ly+ry)
- new_bitmap.blt(lx,ly,self,Rect.new(0, 0, width, height))
- @excb = new_bitmap
- end
- end
- s = Sprite.new
- s.bitmap = Bitmap.new(32,32)
- s.bitmap.fill_rect(0,0,32,32,Color.new(255,0,0))
- s.x = 320
- s.y = 240
- s.ox = s.bitmap.width / 2
- s.oy = s.bitmap.height / 2
- loop{Graphics.update;s.update;s.bitmap.blur;s.ox = s.bitmap.width / 2;
- s.oy = s.bitmap.height / 2
- }
复制代码 边blur边扩充边缘
不过这个东西还不够卫生不能多用 |
|