# coding: utf-8
# ===========================================================================
# ★★ WF-RGSS Scripts ★★
# Bitmap-EX ビットマップスクリプト
# バージョン : rev-10.1(2012-10-15)
# 作者 : A Crying Minister (WHITE-FLUTE)
# サポート先URI:
http://www.whiteflute.org/wfrgss/
# ---------------------------------------------------------------------------
# 機能:
# ・ビットマップに対して様々なエフェクトをかけることが出来るようになります。
# ・手軽に高速なゲージを導入することができます。
# ・ビットマップをpngファイルに書き出すことができます。
# ・アニメーションGIFをサポートします。暗号化アーカイブからでも読み込めます。
# ・ライン、円、ポリゴン描画などを行うことが出来ます。
# ・線の先端にスタイルを設定したり、線の種別を選択できます。
# ---------------------------------------------------------------------------
# 設置場所 :共通スクリプト より下、Mainより上
# 必要スクリプト:
# ・共通スクリプト、共通実行スクリプト
# 必要DLL: wfbitmap.dll
# 注意事項:
# ▽メソッドによっては時間の掛かる処理があります。
# 著作権表示:
#* libpng version 1.5.4 - July 7, 2011
#* Copyright (c) 1998-2011 Glenn Randers-Pehrson
#* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
#* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
#
# The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond
#==============================================================================
module WFRGSS_BitmapEX
#----------------------------------------------------------------------------
# 高速テキスト描画に置き換えるか
USE_DRAW_TEXT = false
end
#==============================================================================
# RGSS組み込みクラス Font
#------------------------------------------------------------------------------
class Font
#--------------------------------------------------------------------------
# ● クラス変数
#--------------------------------------------------------------------------
@@gradient_start_color = Color.new(255,255,255)
@@gradient_end_color = Color.new(200,200,200)
@@frame_color = Color.new(0,0,0)
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias __initialize__ initialize unless $@
def initialize(*args)
case args.size
when 2
__initialize__(args.at(0),args.at(1))
when 1
__initialize__(args.at(0))
when 0
__initialize__
else
raise(ArgumentError,"wrong number of arguments(#{args.size} for 2)",
caller(1))
end
@gradient_start_color = @@gradient_start_color.dup
@gradient_end_color = @@gradient_end_color.dup
@frame_color = @@frame_color.dup
end
#--------------------------------------------------------------------------
# ● フォント存在判定
#--------------------------------------------------------------------------
def exist_font
if self.name.is_a?(Array)
for font in self.name
return font if Font.exist?(font)
end
return ""
else
return self.name
end
end
def self.default_gradient_start_color
@@gradient_start_color
end
def self.default_gradient_start_color=(color)
@@gradient_start_color = color if color.is_a?(Color)
end
def self.default_gradient_end_color
@@gradient_end_color
end
def self.default_gradient_end_color=(color)
@@gradient_end_color = color if color.is_a?(Color)
end
def self.default_frame_color
@@frame_color
end
def self.default_frame_color=(color)
@@frame_color = color if color.is_a?(Color)
end
def gradient_start_color
@gradient_start_color
end
def gradient_start_color=(color)
@gradient_start_color = color if color.is_a?(Color)
end
def gradient_end_color
@gradient_end_color
end
def gradient_end_color=(color)
@gradient_end_color = color if color.is_a?(Color)
end
def frame_color
@frame_color
end
def frame_color=(color)
@frame_color = color if color.is_a?(Color)
end
end
#==============================================================================
# RGSS組み込みクラス Bitmap
#------------------------------------------------------------------------------
class Bitmap
#--------------------------------------------------------------------------
# ● クラス変数
#--------------------------------------------------------------------------
begin
@@mosaic = Win32API.new('wfbitmap','mosaic',%w(l l l l l),'l').freeze
@@reversing = Win32API.new('wfbitmap','Reversing',%w(l l l),'l').freeze
@@diffusion = Win32API.new('wfbitmap','Diffusion',%w(l l l l),'l').freeze
@@blur = Win32API.new('wfbitmap','blur',%w(l l l l),'l').freeze
@@darkrndimg = Win32API.new('wfbitmap','DarkRndImg',%w(l l l),'l').freeze
@@lightrndimg = Win32API.new('wfbitmap','lightRndImg',%w(l l l),'l').freeze
@@radialblur = Win32API.new('wfbitmap','radialBlur',%w(l l l l),'l').freeze
@@rotationblur = Win32API.new('wfbitmap','rotationBlur',%w(l l l l),'l').freeze
@@whirlblur = Win32API.new('wfbitmap','WhirlBlur',%w(l l l l l),'l').freeze
@@postaraiz = Win32API.new('wfbitmap','Postaraiz',%w(l l l),'l').freeze
@@guage = Win32API.new('wfbitmap','drawGuage',%w(l l l p p p l l l l l l),'l').freeze
@@png = Win32API.new('wfbitmap','pngWrite',%w(l p i i),'l').freeze
@@blend = Win32API.new('wfbitmap','blend_blt',
%w(l l l l l l i i l l l l l l),'l').freeze
@@fontdraw = Win32API.new('wfbitmap','drawText',%w(p p l p p),'i').freeze
@@gfontdraw = Win32API.new('wfbitmap','drawGradientText',%w(p p l p p p p),'i').freeze
@@fontsize = Win32API.new('wfbitmap','getTextSize',%w(p p l p p),'i').freeze
@@dispose = Win32API.new('wfbitmap','dispose','v','v').freeze
@@line = Win32API.new('wfbitmap','drawLine',%w(l l l p p i),'v').freeze
@@ellipse = Win32API.new('wfbitmap','drawEllipse',%w(l l l i i i i p p i i),'v').freeze
@@polygon = Win32API.new('wfbitmap','drawPolygon',%w(l l l p i p p i i i),'i').freeze
@@curve = Win32API.new('wfbitmap','drawCurve',%w(l l l p i p p i i),'i').freeze
@@closedcurve = Win32API.new('wfbitmap','drawClosedCurve',%w(l l l p i p p i i i i),'i').freeze
@@pie = Win32API.new('wfbitmap','drawPie',%w(l l l i i i i p p i i i i),'v').freeze
@@antialias = Win32API.new('wfbitmap','setAntiAliasMode','l','v').freeze
@@tellipse = Win32API.new('wfbitmap','textureEllipse',%w(p p l l l l),'v').freeze
@@tpolygon = Win32API.new('wfbitmap','texturePolygon',%w(p p p l i),'i').freeze
@@tclosedcurve = Win32API.new('wfbitmap','textureClosedCurve',%w(p p p l i i),'i').freeze
@@tpie = Win32API.new('wfbitmap','texturePie',%w(p p i i i i i i),'v').freeze
@@dashmode = Win32API.new('wfbitmap','setPenDashStyleMode','i','v').freeze
@@gray = Win32API.new('wfbitmap','grayScale',%w(l l l),'v').freeze
@@raster = Win32API.new('wfbitmap','rasterScroll',%w(l l l i i),'v').freeze
@@startcap = Win32API.new('wfbitmap','setLineStartCapMode','i','v').freeze
@@endcap = Win32API.new('wfbitmap','setLineEndCapMode','i','v').freeze
@@join = Win32API.new('wfbitmap','setLineJoinMode','i','v').freeze
@@arc = Win32API.new('wfbitmap','drawArc',%w(l l l i i i i p p i i i),'v').freeze
@@bezier = Win32API.new('wfbitmap','drawBeziers',%w(l l l p l p p i),'i').freeze
@@threedtrans = Win32API.new('wfbitmap','ThreeDTransform',%w(l i i p),'l').freeze
rescue Exception
raise if debug?
raise(LoadError,"cannot read modules.(wfbitmap.dll)")
end
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
DASH_STYLE_SOLID = 0
DASH_STYLE_DASH = 1
DASH_STYLE_DOT = 2
DASH_STYLE_DASHDOT = 3
DASH_STYLE_DASHDOTDOT = 4
LINE_CAP_FLAT = 0
LINE_CAP_SQUARE = 1
LINE_CAP_ROUND = 2
LINE_CAP_TRIANGLE = 3
LINE_CAP_NOANCHOR = 4
LINE_CAP_SQUAREANCHOR = 5
LINE_CAP_ROUNDANCHOR = 6
LINE_CAP_DIAMONDANCHOR = 7
LINE_CAP_ARROWAMNCHOR = 8
LINE_CAP_ANCHORMASK = 9
LINE_JOIN_MITER = 0
LINE_JOIN_BEVEL = 1
LINE_JOIN_ROUND = 2
LINE_JOIN_MITERCLIPPED = 3
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def self.dispose
@@dispose.call()
end
#--------------------------------------------------------------------------
# ● アンチエイリアスモード
#--------------------------------------------------------------------------
def self.antialias_mode=( mode )
@@antialias.call(mode ? 1 : 0 )
end
#--------------------------------------------------------------------------
# ● 線の種類
#--------------------------------------------------------------------------
def self.dash_style=(style)
@@dashmode.call( style )
end
#--------------------------------------------------------------------------
# ● 開始点のスタイル
#--------------------------------------------------------------------------
def self.line_start_cap=(mode)
@@startcap.call( mode )
end
#--------------------------------------------------------------------------
# ● 終了点のスタイル
#--------------------------------------------------------------------------
def self.line_end_cap=(mode)
@@endcap.call( mode )
end
#--------------------------------------------------------------------------
# ● 線分の接続形
#--------------------------------------------------------------------------
def self.line_join=(mode)
@@join.call( mode )
end
#--------------------------------------------------------------------------
# ● モザイク
#--------------------------------------------------------------------------
def mosaic( msx = 2, msy = 2)
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@mosaic.call( b.object_id , msx , msy , b.width , b.height )
b
end
#--------------------------------------------------------------------------
# ● モザイク
#--------------------------------------------------------------------------
def mosaic!( msx = 2, msy = 2)
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@mosaic.call( object_id , msx , msy , self.width , self.height )
self
end
#--------------------------------------------------------------------------
# ● 色反転
#--------------------------------------------------------------------------
def reversing
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@reversing.call( b.object_id , b.width , b.height )
b
end
#--------------------------------------------------------------------------
# ● 色反転
#--------------------------------------------------------------------------
def reversing!
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@reversing.call( object_id , self.width , self.height )
self
end
#--------------------------------------------------------------------------
# ● 拡散
#--------------------------------------------------------------------------
def diffusion( noise = 2 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@diffusion.call( b.object_id , noise , b.width , b.height )
b
end
#--------------------------------------------------------------------------
# ● 拡散
#--------------------------------------------------------------------------
def diffusion!( noise = 2 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@diffusion.call( object_id , noise , self.width , self.height )
self
end
unless rpgvx?
#--------------------------------------------------------------------------
# ● ぼかし(※時間がかかります。) ※ XPのみ VXでは標準のものを使う
#--------------------------------------------------------------------------
def blur( sm = 5 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@blur.call(b.object_id , sm , b.width , b.height )
b
end
else
#--------------------------------------------------------------------------
# ● ぼかし(※時間がかかります。) ※ VXのみ
#--------------------------------------------------------------------------
def blur2( sm = 5 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@blur.call(b.object_id , sm , b.width , b.height )
b
end
end
#--------------------------------------------------------------------------
# ● ぼかし(※時間がかかります。)
#--------------------------------------------------------------------------
def blur!( sm = 5 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@blur.call(object_id , sm , self.width , self.height )
self
end
#--------------------------------------------------------------------------
# ● ランダム色(暗色)
#--------------------------------------------------------------------------
def darkrndimg
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@darkrndimg.call( b.object_id , b.width , b.height)
b
end
#--------------------------------------------------------------------------
# ● ランダム色(暗色)
#--------------------------------------------------------------------------
def darkrndimg!
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@darkrndimg.call( object_id , self.width , self.height)
self
end
#--------------------------------------------------------------------------
# ● ランダム色(明色)
#--------------------------------------------------------------------------
def lightrndimg
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@lightrndimg.call( b.object_id , b.width , b.height)
b
end
#--------------------------------------------------------------------------
# ● ランダム色(明色)
#--------------------------------------------------------------------------
def lightrndimg!
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@lightrndimg.call( object_id , self.width , self.height)
self
end
#--------------------------------------------------------------------------
# ● 放射状ブラー(※時間がかかります。)
#--------------------------------------------------------------------------
def radialblur( ef = 10 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@radialblur.call( b.object_id , b.width , b.height , ef )
b
end
#--------------------------------------------------------------------------
# ● 放射状ブラー(※時間がかかります。)
#--------------------------------------------------------------------------
def radialblur!( ef = 10 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@radialblur.call( object_id , self.width , self.height , ef )
self
end
#--------------------------------------------------------------------------
# ● 回転ブラー(※時間がかかります。)
#--------------------------------------------------------------------------
def rotationblur( ef = 10 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@rotationblur.call( b.object_id , b.width , b.height , ef )
b
end
#--------------------------------------------------------------------------
# ● 回転ブラー(※時間がかかります。)
#--------------------------------------------------------------------------
def rotationblur!( ef = 10 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@rotationblur.call( object_id , self.width , self.height , ef )
self
end
#--------------------------------------------------------------------------
# ● 渦巻き(※時間がかかります。)
#--------------------------------------------------------------------------
def whirlblur( ef = 10 , r = 1 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
_fixnum_range_check( r , -12 , 12 )
b = self.dup
@@whirlblur.call( b.object_id , b.width , b.height , ef , r )
b
end
#--------------------------------------------------------------------------
# ● 渦巻き(※時間がかかります。)
#--------------------------------------------------------------------------
def whirlblur!( ef = 10 , r = 1 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
_fixnum_range_check( r , -12 , 12 )
@@whirlblur.call( object_id , self.width , self.height , ef , r )
self
end
#--------------------------------------------------------------------------
# ● ポスタライズ
#--------------------------------------------------------------------------
def postaraiz
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@postaraiz.call( b.object_id , b.width , b.height )
b
end
#--------------------------------------------------------------------------
# ● ポスタライズ
#--------------------------------------------------------------------------
def postaraiz!
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@postaraiz.call( object_id , self.width , self.height )
self
end
#--------------------------------------------------------------------------
# ● グレイスケール
#--------------------------------------------------------------------------
def gray_scale
raise(RGSSError,"disposed bitmap.") if self.disposed?
b = self.dup
@@gray.call( b.object_id , b.width , b.height )
b
end
#--------------------------------------------------------------------------
# ● グレイスケール
#--------------------------------------------------------------------------
def gray_scale!
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@gray.call(self.object_id , self.width , self.height )
self
end
#--------------------------------------------------------------------------
# ● ラスタースクロール
#--------------------------------------------------------------------------
def raster_scroll( amp , length )
raise(RGSSError,"disposed bitmap.") if self.disposed?
raise(RGSSError,"Invalid amp data.") if (self.width >> 1) <= amp
b = self.dup
@@raster.call(b.object_id , b.width , b.height ,amp , length )
b
end
#--------------------------------------------------------------------------
# ● ラスタースクロール
#--------------------------------------------------------------------------
def raster_scroll!( amp , length )
raise(RGSSError,"disposed bitmap.") if self.disposed?
raise(RGSSError,"Invalid amp data.") if (self.width >> 1) <= amp
@@raster.call(self.object_id , self.width , self.height ,amp , length )
self
end
#--------------------------------------------------------------------------
# ● 横ゲージ描画
#--------------------------------------------------------------------------
def horizontal_gauge( x, y, width, height, color1, color2, basecolor,life )
raise(RGSSError,"disposed bitmap.") if self.disposed?
c1 = color_convert( color1 )
c2 = color_convert( color2 )
bc = color_convert( basecolor )
@@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
x , y + height, width , height , life , 0 )
self
end
#--------------------------------------------------------------------------
# ● 縦ゲージ描画
#--------------------------------------------------------------------------
def vertical_gauge( x, y, width, height, color1 , color2 , basecolor , life )
raise(RGSSError,"disposed bitmap.") if self.disposed?
c1 = color_convert( color1 )
c2 = color_convert( color2 )
bc = color_convert( basecolor )
@@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
x , y + height, width , height , life , 1 )
self
end
#--------------------------------------------------------------------------
# ● 横ゲージ描画2 ▽△
#--------------------------------------------------------------------------
def horizontal_gauge2( x, y, width, height, color1, color2, basecolor,life )
raise(RGSSError,"disposed bitmap.") if self.disposed?
c1 = color_convert( color1 )
c2 = color_convert( color2 )
bc = color_convert( basecolor )
@@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
x + height, y + height, width , height , life , 2 )
self
end
#--------------------------------------------------------------------------
# ● 横ゲージ描画3 △▽
#--------------------------------------------------------------------------
def horizontal_gauge3( x, y, width, height, color1, color2, basecolor,life )
raise(RGSSError,"disposed bitmap.") if self.disposed?
c1 = color_convert( color1 )
c2 = color_convert( color2 )
bc = color_convert( basecolor )
@@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
x, y + height, width , height , life , 3 )
self
end
#--------------------------------------------------------------------------
# ● PNG書き出し
#--------------------------------------------------------------------------
def write_png( filename )
raise(RGSSError,"disposed bitmap.") if self.disposed?
@@png.call( object_id , filename , self.width , self.height )
end
#--------------------------------------------------------------------------
# ● ブレンディング
#--------------------------------------------------------------------------
def blend_blt( x, y , src, rect, blend_type = 0 , opacity = 255 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
_fixnum_range_check( blend_type , 0 , 10 )
@@blend.call( self.object_id , src.object_id , x , y , rect.x , rect.y ,
blend_type , opacity , src.width , src.height ,
self.width , self.height , rect.width , rect.height)
self
end
#--------------------------------------------------------------------------
# ● 3Dトランスフォーム
#--------------------------------------------------------------------------
def three_d_transform(rotx,roty,rotz,w =1.0,h = 1.0,x = 0.0,y = 0.0,d = 1.0)
raise(RGSSError,"disposed bitmap.") if self.disposed?
rot = [rad2d(rotx),rad2d(roty),rad2d(rotz),w,h,x,y,d].pack("ffffffff")
@@threedtrans.call(self.object_id, self.width, self.height, rot)
self
end
#--------------------------------------------------------------------------
# ● ライン描画
#--------------------------------------------------------------------------
def simple_draw_line(start_x , start_y , end_x , end_y , color , width = 1)
draw_line( start_x , start_y , end_x , end_y , color , color , width)
end
#--------------------------------------------------------------------------
# ● ライン描画
#--------------------------------------------------------------------------
def draw_line( start_x, start_y, end_x, end_y,
start_color, end_color, width = 1)
raise(RGSSError,"disposed bitmap.") if self.disposed?
pstart = [ start_x , start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ end_x , end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@line.call(self.object_id ,self.width,self.height,pstart,pend,w)
self
end
#--------------------------------------------------------------------------
# ● 円描画
#--------------------------------------------------------------------------
def simple_draw_ellipse(start_x,start_y,end_x,end_y,color,fill,width = 1)
draw_ellipse( start_x , start_y , end_x , end_y , 0, 0, 1 , 1 ,
color , color , fill , width)
end
#--------------------------------------------------------------------------
# ● 円描画
#--------------------------------------------------------------------------
def draw_ellipse( start_x , start_y , end_x , end_y ,
gra_start_x , gra_start_y, gra_end_x , gra_end_y ,
start_color , end_color , fill , width = 1)
raise(RGSSError,"disposed bitmap.") if self.disposed?
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@ellipse.call(self.object_id,self.width,self.height,
start_x,start_y,end_x,end_y,pstart,pend,fill ? 1 : 0, w)
self
end
#--------------------------------------------------------------------------
# ● ポリゴン描画
#--------------------------------------------------------------------------
def simple_draw_polygon(polygon,count,color,fill,mode = true,width = 1)
draw_polygon( polygon, count, 0, 0, 1, 1, color, color,fill, mode,width)
end
#--------------------------------------------------------------------------
# ● ポリゴン描画
#--------------------------------------------------------------------------
def draw_polygon( polygon , count , gra_start_x , gra_start_y, gra_end_x ,
gra_end_y , start_color , end_color ,
fill , mode = true, width = 1)
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless polygon.size > 5 and polygon.size & 0x1 == 0 and
(polygon.size >> 1) == count
raise(RGSSError,"Invalid polygon data.")
end
poly = polygon.pack("s*")
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@polygon.call( self.object_id , self.width , self.height , poly , count ,
pstart , pend , fill ? 1 : 0 , mode ? 1 : 0 , w)
self
end
#--------------------------------------------------------------------------
# ● カーブ描画
#--------------------------------------------------------------------------
def simple_draw_curve( curve , count , color , width = 1 , tension = 50 )
draw_curve( curve , count , 0, 0, 1, 1, color, color,width,tension)
end
#--------------------------------------------------------------------------
# ● カーブ描画
#--------------------------------------------------------------------------
def draw_curve( curve , count , gra_start_x , gra_start_y, gra_end_x ,
gra_end_y , start_color ,end_color,width = 1 ,tension = 50)
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless curve.size > 5 and curve.size & 0x1 == 0 and
(curve.size >> 1) == count
raise(RGSSError,"Invalid curve data.")
end
poly = curve.pack("s*")
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@curve.call( self.object_id , self.width , self.height , poly , count ,
pstart , pend , w , tension)
self
end
#--------------------------------------------------------------------------
# ● 閉カーブ描画
#--------------------------------------------------------------------------
def simple_draw_closed_curve( curve, count, color, fill, mode = true,
width = 1, tension = 50)
draw_closed_curve(curve,count,0,0,1,1,color,color,fill,mode,width,tension)
end
#--------------------------------------------------------------------------
# ● 閉カーブ描画
#--------------------------------------------------------------------------
def draw_closed_curve( curve , count , gra_start_x , gra_start_y, gra_end_x ,
gra_end_y , start_color ,end_color,
fill , mode = true , width = 1 ,tension = 50)
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless curve.size > 5 and curve.size & 0x1 == 0 and
(curve.size >> 1) == count
raise(RGSSError,"Invalid curve data.")
end
poly = curve.pack("s*")
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@closedcurve.call( self.object_id, self.width, self.height, poly, count,
pstart , pend , fill ? 1 : 0 , mode ? 1 : 0 , w , tension)
self
end
#--------------------------------------------------------------------------
# ● パイ描画
#--------------------------------------------------------------------------
def simple_draw_pie(start_x, start_y, end_x, end_y,
color,start_angle,sweep_angle,fill,width = 1)
draw_pie( start_x, start_y, end_x, end_y, 0, 0, 1, 1,
color,color,start_angle,sweep_angle,fill,width)
end
#--------------------------------------------------------------------------
# ● パイ描画
#--------------------------------------------------------------------------
def draw_pie( start_x, start_y, end_x, end_y,
gra_start_x, gra_start_y, gra_end_x , gra_end_y ,
start_color,end_color,start_angle,sweep_angle,fill,width = 1)
raise(RGSSError,"disposed bitmap.") if self.disposed?
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@pie.call(self.object_id,self.width,self.height,start_x,start_y,
end_x,end_y, pstart, pend, start_angle, sweep_angle,
fill ? 1 : 0 , w )
self
end
#--------------------------------------------------------------------------
# ● 円弧描画
#--------------------------------------------------------------------------
def simple_draw_arc( start_x, start_y, end_x, end_y,
color,start_angle,sweep_angle,width = 1)
draw_arc( start_x, start_y, end_x, end_y, 0, 0, 1, 1,
color, color,start_angle,sweep_angle,width)
end
#--------------------------------------------------------------------------
# ● 円弧描画
#--------------------------------------------------------------------------
def draw_arc( start_x, start_y, end_x, end_y,
gra_start_x, gra_start_y, gra_end_x , gra_end_y ,
start_color,end_color,start_angle,sweep_angle,width = 1)
raise(RGSSError,"disposed bitmap.") if self.disposed?
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@arc.call(self.object_id,self.width,self.height,start_x,start_y,
end_x,end_y, pstart, pend, start_angle, sweep_angle, w )
self
end
#--------------------------------------------------------------------------
# ● べジエ曲線描画
#--------------------------------------------------------------------------
def simple_draw_beziers( curve , count , color , width = 1 )
draw_beziers( curve , count , 0, 0, 1, 1, color ,color, width)
end
#--------------------------------------------------------------------------
# ● ベジエ曲線描画
#--------------------------------------------------------------------------
def draw_beziers( curve , count , gra_start_x , gra_start_y, gra_end_x ,
gra_end_y , start_color ,end_color, width = 1 )
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless curve.size > 7 and curve.size & 0x1 == 0 and
(curve.size >> 1) == count
raise(RGSSError,"Invalid bezier data.")
end
poly = curve.pack("s*")
pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
w = Integer( width * 100.0 )
@@bezier.call( self.object_id, self.width, self.height, poly, count,
pstart , pend , w )
self
end
#--------------------------------------------------------------------------
# ● テクスチャ円形
#--------------------------------------------------------------------------
def texture_ellipse( bitmap , start_x , start_y , end_x , end_y )
psrc = [self.object_id,self.width,self.height].pack("III")
pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
@@tellipse.call(psrc,pdest,start_x , start_y , end_x , end_y )
self
end
#--------------------------------------------------------------------------
# ● テクスチャポリゴン
#--------------------------------------------------------------------------
def texture_polygon( bitmap , polygon , count , mode)
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless polygon.size > 5 and polygon.size & 0x1 == 0 and
(polygon.size >> 1) == count
raise(RGSSError,"Invalid polygon data.")
end
poly = polygon.pack("s*")
psrc = [self.object_id,self.width,self.height].pack("III")
pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
@@tpolygon.call( psrc , pdest , poly , count , mode ? 1 : 0 )
self
end
#--------------------------------------------------------------------------
# ● テクスチャ閉カーブ
#--------------------------------------------------------------------------
def texture_closed_curve( bitmap , curve , count, mode , tension = 50)
raise(RGSSError,"disposed bitmap.") if self.disposed?
unless curve.size > 5 and curve.size & 0x1 == 0 and
(curve.size >> 1) == count
raise(RGSSError,"Invalid curve data.")
end
poly = curve.pack("s*")
psrc = [self.object_id,self.width,self.height].pack("III")
pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
@@tclosedcurve.call( psrc , pdest , poly, count, mode ? 1 : 0 , tension)
self
end
#--------------------------------------------------------------------------
# ● テクスチャパイ
#--------------------------------------------------------------------------
def texture_pie(bitmap,start_x,start_y,end_x,end_y,start_angle,sweep_angle)
raise(RGSSError,"disposed bitmap.") if self.disposed?
psrc = [self.object_id,self.width,self.height].pack("III")
pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
@@tpie.call(psrc,pdest,start_x,start_y,end_x,end_y,start_angle,sweep_angle)
self
end
#--------------------------------------------------------------------------
# ● 文字描画
#--------------------------------------------------------------------------
def draw_gradient_text(*args)
raise(RGSSError,"disposed bitmap.") if self.disposed?
x, y, width, height, text, align, mode = get_text_args_s(args)
w2 = text_size(text).width
ry = height - self.font.size
rect = [x, y + ry / 2, width , self.font.size ,
self.width , self.height, w2].pack("s*")
data = [Integer( self.font.frame_color.red ),
Integer( self.font.frame_color.green ),
Integer( self.font.frame_color.blue ),
Integer( self.font.frame_color.alpha ),self.font.size,
mode & 0x1,(self.font.italic ? 2 : 0) | (self.font.bold ? 1 : 0),
((mode & 0x2) >> 1),align ].pack("C*")
start_color = self.font.gradient_start_color
end_color = self.font.gradient_end_color
pstart = [ x , y - 2, start_color.blue , start_color.green ,
start_color.red , start_color.alpha ].pack("iiCCCC")
pend = [ x , y + self.font.size + 2, end_color.blue , end_color.green ,
end_color.red , end_color.alpha ].pack("iiCCCC")
@@gfontdraw.call(text.dup,self.font.exist_font.dup,
self.object_id,rect,data, pstart, pend) == 1
end
#--------------------------------------------------------------------------
# ● 文字描画
#--------------------------------------------------------------------------
def draw_text_s(*args)
raise(RGSSError,"disposed bitmap.") if self.disposed?
x, y, width, height, text, align, mode = get_text_args_s(args)
w2 = text_size(text).width
ry = height - self.font.size
rect = [x, y + ry / 2, width , self.font.size ,
self.width , self.height, w2].pack("s*")
data = [Integer( self.font.color.red ),
Integer( self.font.color.green ),
Integer( self.font.color.blue ),
Integer( self.font.color.alpha ),self.font.size,
mode & 0x1,(self.font.italic ? 2 : 0) | (self.font.bold ? 1 : 0),
((mode & 0x2) >> 1),align ].pack("C*")
@@fontdraw.call(text.dup,self.font.exist_font.dup,
self.object_id,rect,data) == 1
end
private
#--------------------------------------------------------------------------
# ◆(内部専用)◆ 描画引数
#--------------------------------------------------------------------------
def get_text_args_s(args)
if args.at(0).is_a?(Rect)
if args.size.between?(2, 5)
rect = args.at(0)
x, y = rect.x, rect.y
width, height = rect.width, rect.height
text = args.at(1).to_s
align = (args.at(2).equal?(nil) ? 0 : args.at(2))
mode = (args.at(3).equal?(nil) ? 1 : args.at(3))
else
as = args.size < 2 ? 2 : 5
raise(ArgumentError,
"wrong number of arguments(#{args.size} of #{as})")
end
elsif args.size.between?(5, 8)
x, y, width, height = args
text = args.at(4).to_s
align = (args.at(5).equal?(nil) ? 0 : args.at(5))
mode = (args.at(6) ? args.at(6) : 1 )
else
as = args.size < 5 ? 5 : 8
raise(ArgumentError,
"wrong number of arguments(#{args.size} of #{as})")
end
return [x, y, width, height, text, align, mode]
end
#--------------------------------------------------------------------------
# ◆(内部専用)◆ カラーコンバート ( bgra の順になっていることに注意する)
#--------------------------------------------------------------------------
def color_convert(color)
str = [color.blue.to_i , color.green.to_i ,
color.red.to_i , color.alpha.to_i ].pack("C*")
str
end
def rad2d( rad )
(rad * Math:

I) / 180.0
end
unless method_defined?

original_draw_text)
alias original_draw_text draw_text
if WFRGSS_BitmapEX::USE_DRAW_TEXT
alias draw_text draw_text_s
end
end
end
#==============================================================================
# GIFFile クラス
#------------------------------------------------------------------------------
class GIFFile
#--------------------------------------------------------------------------
# ● クラス変数
#--------------------------------------------------------------------------
begin
@@loader = Win32API.new('wfbitmap','gifLoader',%w(p i p p p p),'l').freeze
@@load = Win32API.new('wfbitmap','gifLoadImage',%w(l i),'l').freeze
@@count = Win32API.new('wfbitmap','gifImageCount','v','l').freeze
@@close = Win32API.new('wfbitmap','GifClose','v','v').freeze
rescue Exception
raise if debug?
raise(LoadError,"cannot read modules.(wfbitmap.dll)")
end
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
RGSSA_FILE = rpgvx? ? (rpgvxace? ? "Game.rgss3a" : "Game.rgss2a") :
"Game.rgssad"
RGSSA_VERSION = rpgvx? ? (rpgvxace? ? 3 : 2) : 1
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :bitmap
attr_reader :count
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize( giffile )
w = "\x00" * 2
h = "\x00" * 2
@loaded = false
begin
infile = giffile.gsub(/\//){ "\\" }
i = @@loader.call(RGSSA_FILE,RGSSA_VERSION,
infile,String.utf82ansi(infile), w , h )
raise(Errno::ENOENT,infile) if i < 0
@loaded = true
@count = @@count.call()
width = w.unpack("S").first
height = h.unpack("S").first
@bitmap = Array.new( @count ){ Bitmap.new( width , height ) }
i = 0
for bitmap in @bitmap
@@load.call( bitmap.object_id , i )
i += 1
end
ensure
@@close.call() if @loaded
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
for bitmap in @bitmap
bitmap.dispose
end
end
end
#==============================================================================
# GifSprite クラス
#------------------------------------------------------------------------------
class GifSprite < Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize( giffile , wait = 1 , viewport = nil)
super(viewport)
@gif = GIFFile.new( giffile )
@wait = wait
self.bitmap = @gif.bitmap.at(0)
@_count = 0
@_index = 0
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
@gif.dispose
super
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
@_count += 1
if @_count >= @wait
@_index += 1
@_index %= @gif.count
self.bitmap = @gif.bitmap.at(@_index)
@_count = 0
end
end
end