赞 | 0 |
VIP | 13 |
好人卡 | 65 |
积分 | 1 |
经验 | 58644 |
最后登录 | 2017-10-23 |
在线时间 | 1281 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 1281 小时
- 注册时间
- 2006-8-27
- 帖子
- 590
|
本帖最后由 wbsy8241 于 2011-3-26 21:16 编辑
- class Bitmap
- #--------------------------------------------------------------------------
- # ● 文字阴影
- # draw_text(x, y, width, height, str[, align[, shadow[, shadow_color]]])
- # draw_text(rect, str[, align[, shadow[, shadow_color]]])
- #
- # shadow: 指定为 1 时加阴影
- # shadow_color: 自指定阴影颜色
- # 使用阴影需要先指定对齐
- # 红色阴影范例:bitmap.draw_text(0, 0, 64, 32, "红色", 0, 1, Color.new(255,0,0))
- # 默认阴影范例:bitmap.draw_text(0, 0, 64, 32, "默认", 0, 1)
- #--------------------------------------------------------------------------
- alias new_draw_text draw_text if $f12 == nil
- def draw_text(p1, p2, p3=0, p4=0, p5=0, p6=0, p7=0, p8=0)
- case p1
- when Numeric
- x = p1
- y = p2
- width = p3
- height = p4
- text = p5.to_s
- align = p6
- shadow = p7
- shadow_color = p8
- when Rect
- x = p1.x
- y = p1.y
- width = p1.width
- height = p1.height
- text = p2.to_s
- align = p3
- shadow = p4
- shadow_color = p5
- end
- if shadow == 1
- color_temp = self.font.color.clone
- case shadow_color
- when Numeric
- color = Color.new(0, 0, 0, color_temp.alpha)
- when Color
- color = shadow_color
- end
- self.font.color = color
- new_draw_text(x+1, y+1, width, height, text, align)
- self.font.color = color_temp
- end
- new_draw_text(x, y, width, height, text, align)
- end
- end
- $f12 = true
复制代码 |
|