Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- # ===========================================================================
- # ★★ WF-RGSS Scripts ★★
- # Bitmap-EX ビットマップスクリプト
- # バージョン : rev-13.1(2013-3-29)
- # 作者 : WF-RGSS担当 (WHITE-FLUTE)
- # サポート先URI: http://www.whiteflute.org/wfrgss/
- # ---------------------------------------------------------------------------
- # 機能:
- # ・ビットマップに対して様々なエフェクトをかけることが出来るようになります。
- # ・手軽に高速なゲージを導入することができます。
- # ・ビットマップをpngファイルに書き出すことができます。
- # ・アニメーションGIFをサポートします。暗号化アーカイブからでも読み込めます。
- # ・ライン、円、ポリゴン描画などを行うことが出来ます。
- # ・線の先端にスタイルを設定したり、線の種別を選択できます。
- # ---------------------------------------------------------------------------
- # 設置場所 :共通スクリプト より下、Mainより上
- # 必要スクリプト:
- # ・共通スクリプト、共通実行スクリプト
- # 必要DLL: wfbitmap.dll
- # 注意事項:
- # ▽メソッドによっては時間の掛かる処理があります。
- # ▽一部のメソッドは、頂点シェーダおよびピクセルシェーダが2.0に
- # 対応している必要があります。
- # 著作権表示:
- #* 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
- #
- # stretch_blend_blt バイリニア補完法のアルゴリズムは
- # 本棚様(http://ameblo.jp/tales-bado/)の素材を参考にしました。
- # http://www.tekepon.net/fsm/modules/imgbb/viewtopic.php?topic_id=3228&forum=12
- #==============================================================================
- 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
- # ---------------------------------------------------------------------------
- # ◆ Lighting
- # ---------------------------------------------------------------------------
- class Lighting
- #--------------------------------------------------------------------------
- # ◆ 定数
- #--------------------------------------------------------------------------
- D3DLIGHT_POINT = 1
- D3DLIGHT_SPOT = 2
- D3DLIGHT_DIRECTIONAL = 3
- #--------------------------------------------------------------------------
- # ◆ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :type # 光源のタイプ
- attr_accessor :diffuse # ディフューズ色
- attr_accessor :specular # スペキュラー色
- attr_accessor :ambient # アンビエント色
- attr_accessor :range # 範囲
- attr_accessor :falloff #
- attr_reader :attenation0 #
- attr_reader :attenation1 #
- attr_reader :attenation2 #
- attr_reader :theta #
- attr_reader :phi #
- #--------------------------------------------------------------------------
- # ◆ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- @type = D3DLIGHT_POINT
- @diffuse = Color.new(0,0,0,0)
- @specular = Color.new(0,0,0,0)
- @ambient = Color.new(0,0,0,0)
- @position = Array.new(3){ 0.0 }
- @direction = Array.new(3){ 1.0 }
- @range = 1.0
- @falloff = 1.0
- @attenation0 = 0.0
- @attenation1 = 0.0
- @attenation2 = 0.0
- @theta = 0.0
- @phi = 0.0
- end
- #--------------------------------------------------------------------------
- # ◆ タイプ設定
- #--------------------------------------------------------------------------
- def type=(type)
- @type = type.to_i
- attenation_reset if @type != D3DLIGHT_DIRECTIONAL
- end
- #--------------------------------------------------------------------------
- # ◆ 光源の位置設定
- #--------------------------------------------------------------------------
- def position_update( x , y , z )
- @position[0] = x
- @position[1] = y
- @position[2] = z
- end
- #--------------------------------------------------------------------------
- # ◆ 光源の向き設定
- #--------------------------------------------------------------------------
- def direction_update( x , y , z )
- @direction[0] = x if x != 0.0
- @direction[1] = y if y != 0.0
- @direction[2] = z if z != 0.0
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def attenation0=(a)
- return if @type != D3DLIGHT_DIRECTIONAL
- @attenation0 = a if a >= 0.0
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def attenation1=(a)
- return if @type != D3DLIGHT_DIRECTIONAL
- @attenation1 = a if a >= 0.0
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def attenation2=(a)
- return if @type != D3DLIGHT_DIRECTIONAL
- @attenation2 = a if a >= 0.0
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def theta=(a)
- return if a < 0.0
- return if a > @phi
- @theta = a
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def phi=(a)
- return if a < 0.0
- return if a > Math::PI
- @phi = a
- @theta = @phi if @theta > @phi
- end
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def to_s
- [@type, @diffuse.red / 255.0, @diffuse.green / 255.0,
- @diffuse.blue / 255.0, @diffuse.alpha / 255.0,
- @specular.red / 255.0, @specular.green / 255.0,
- @specular.blue / 255.0, @specular.alpha / 255.0,
- @ambient.red / 255.0, @ambient.green / 255.0,
- @ambient.blue / 255.0, @ambient.alpha / 255.0,
- @position.at(0), @position.at(1), @position.at(2),
- @direction.at(0), @direction.at(1), @direction.at(2),
- @range, @falloff, @attenation0, @attenation1, @attenation2, @theta,
- @phi ].pack("Lf*")
- end
- private
- #--------------------------------------------------------------------------
- # ◆
- #--------------------------------------------------------------------------
- def attenation_reset
- @attenation0 = 0.0
- @attenation1 = 0.0
- @attenation2 = 0.0
- end
- end
- # ---------------------------------------------------------------------------
- # ◆ ThreeDSetting
- # ---------------------------------------------------------------------------
- class ThreeDSetting
- #--------------------------------------------------------------------------
- # ◆ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :use_light # ライト使用フラグ
- attr_reader :use_texture # テクスチャ使用フラグ
- attr_accessor :bitmap # テクスチャビットマップ
- attr_accessor :extrusion # 厚み(フォントで使用)
- attr_accessor :power # スペキュラー強度
- attr_accessor :diffuse # ディフューズ色
- attr_accessor :specular # スペキュラー色
- attr_accessor :ambient # アンビエント色
- attr_accessor :emissive # 発光色
- attr_reader :light # ライティング
- #--------------------------------------------------------------------------
- # ◆ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- @use_light = true
- @use_texture = false
- @bitmap = nil
- @extrusion = 1.0
- @power = 1.0
- @diffuse = Color.new(0,0,0,0)
- @ambient = Color.new(0,0,0,0)
- @specular = Color.new(0,0,0,0)
- @emissive = Color.new(0,0,0,0)
- @light = Lighting.new
- end
- #--------------------------------------------------------------------------
- # ◆ライト使用
- #--------------------------------------------------------------------------
- def use_light=(a)
- @use_light = a ? true : false
- end
- #--------------------------------------------------------------------------
- # ◆ テクスチャ使用
- #--------------------------------------------------------------------------
- def use_texture=(a)
- @use_texutre = a ? true : false
- end
- #--------------------------------------------------------------------------
- # ◆ データ書き出し
- #--------------------------------------------------------------------------
- def to_s
- [@use_light ? 1 : 0 , @use_texutre ? 1 : 0 , @bitmap.object_id ,
- @bitmap.width , @bitmap.height , @extrusion , @power ,
- @diffuse.red / 255.0, @diffuse.green / 255.0,
- @diffuse.blue / 255.0, @diffuse.alpha / 255.0,
- @ambient.red / 255.0, @ambient.green / 255.0,
- @ambient.blue / 255.0, @ambient.alpha / 255.0,
- @specular.red / 255.0, @specular.green / 255.0,
- @specular.blue / 255.0, @specular.alpha / 255.0,
- @emissive.red / 255.0, @emissive.green / 255.0,
- @emissive.blue / 255.0, @emissive.alpha / 255.0 ].pack("SSLLLf*") +
- @light.to_s
- end
- end
- # ---------------------------------------------------------------------------
- # ◆ LOGFont
- # ---------------------------------------------------------------------------
- class LOGFont
- #--------------------------------------------------------------------------
- # ◆ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :escapement #
- attr_accessor :orientation #
- attr_accessor :weight # フォントの太さ(100-900)
- attr_reader :italic # 斜体
- attr_reader :underline # 下線
- attr_reader :strikeout # 打ち消し線
- #--------------------------------------------------------------------------
- # ◆ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initalize
- @facename = ""
- @height = 0
- @width = 0
- @escapement = 0
- @orientation = 0
- @weight = 400
- @italic = false
- @underline = false
- @strikeout = false
- end
- #--------------------------------------------------------------------------
- # ◆ 斜体
- #--------------------------------------------------------------------------
- def italic=(italic)
- @italic = italic ? true : false
- end
- #--------------------------------------------------------------------------
- # ◆ 下線
- #--------------------------------------------------------------------------
- def underline=(underline)
- @underline = underline ? true : false
- end
- #--------------------------------------------------------------------------
- # ◆ 打ち消し線
- #--------------------------------------------------------------------------
- def strikeout=(strikeout)
- @strikeout = strikeout ? true : false
- end
- #--------------------------------------------------------------------------
- # ◆ フォント書体決定
- #--------------------------------------------------------------------------
- def facename=(facename)
- face = String.utf82uni(facename)
- #if rpgvxace?
- @facename = face if face.bytesize < 64
- #~ else
- #~ @facename = face if face.size < 64
- #~ end
- end
- #--------------------------------------------------------------------------
- # ◆ データ書き出し
- #--------------------------------------------------------------------------
- def to_s
- [0 , 0, @escapement, @orientation , @weight,
- @italic ? 1 : 0, @underline ? 1 : 0,@strikeout ? 1 : 0 ,
- 0 , 0 , 0 , 5 , 2].pack("LLLLLC*") + @facename
- end
- end
- # ---------------------------------------------------------------------------
- # ◆ Light_Type
- # ---------------------------------------------------------------------------
- class Light_Type
- #--------------------------------------------------------------------------
- # ◆ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :x # x
- attr_accessor :y # y
- attr_accessor :z # z
- attr_accessor :mil # ハイライト 1-400
- attr_accessor :env # 環境光 1-100
- #--------------------------------------------------------------------------
- # ◆ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- @x = 1.0
- @y = 1.0
- @z = 1.0
- @mil = 1.0
- @env = 1.0
- end
- #--------------------------------------------------------------------------
- # ◆ データ書き出し
- #--------------------------------------------------------------------------
- def to_s
- [@mil,@env,@x,@y,@z].pack("d*")
- end
- end
- # ---------------------------------------------------------------------------
- # ◆ 組み込みクラス String
- # ---------------------------------------------------------------------------
- class String
- #--------------------------------------------------------------------------
- # ◆ UTF-8 → UNICODE 変換
- #--------------------------------------------------------------------------
- #~ unless rpgvxace?
- #~ def self.utf82uni( str )
- #~ to_widechar( str , CP_UTF8 )
- #~ end
- #~ else
- def self.utf82uni( str )
- to_widechar(str,CP_UTF8).force_encoding("ASCII-8BIT")
- end
- #~ 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
- @@pencil = Win32API.new('wfbitmap','pencilEffect',%w(l i i i i i),'l').freeze
- @@sharp = Win32API.new('wfbitmap','sharpFilter', %w(l i i),'l').freeze
- @@gamma = Win32API.new('wfbitmap','Gamma',%w(l i 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
- @@threedfont = Win32API.new('wfbitmap','ThreeDDrawText',%w(l i i p p p p i),'l').freeze
- @@thrredsphere = Win32API.new('wfbitmap','ThreeDSphere',%w(l i i p p i),'l').freeze
- @@blend_stretch = Win32API.new('wfbitmap','stretch_blend_blt',%w(p p i i i),'l').freeze
- @@blend_rotate = Win32API.new('wfbitmap','rotate_blend_blt',%w(p p i i i i i),'l').freeze
- @@blend_transform = Win32API.new('wfbitmap','transform_blend_blt',%w(p p p p i i i),'l').freeze
- @@blend_circle = Win32API.new('wfbitmap','circle_blend_blt',%w(p p i i i),'l').freeze
- @@blend_sphere = Win32API.new('wfbitmap','sphere_blend_blt',%w(p p p i i i),'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 antialias_mode=( mode )
- @@antialias.call(mode ? 1 : 0 )
- end
- #--------------------------------------------------------------------------
- # ● 線の種類
- #--------------------------------------------------------------------------
- def dash_style=(style)
- @@dashmode.call( style )
- end
- #--------------------------------------------------------------------------
- # ● 開始点のスタイル
- #--------------------------------------------------------------------------
- def line_start_cap=(mode)
- @@startcap.call( mode )
- end
- #--------------------------------------------------------------------------
- # ● 終了点のスタイル
- #--------------------------------------------------------------------------
- def line_end_cap=(mode)
- @@endcap.call( mode )
- end
- #--------------------------------------------------------------------------
- # ● 線分の接続形
- #--------------------------------------------------------------------------
- def 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 gamma( gamma = 1.0 )
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- b = self.dup
- @@gamma.call( b.object_id , b.width , b.height , (gamma * 100).to_i )
- b
- end
- #--------------------------------------------------------------------------
- # ● ガンマ補正
- #--------------------------------------------------------------------------
- def gamma!( gamma = 1.0 )
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- @@gamma.call( object_id , width , height , (gamma * 100).to_i )
- self
- end
- #--------------------------------------------------------------------------
- # ● 先鋭化
- #--------------------------------------------------------------------------
- def sharp
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- b = self.dup
- unless @@sharp.call( b.object_id , b.width , b.height ).zero?
- GC.start
- unless @@sharp.call( b.object_id , b.width , b.height ).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b
- end
- #--------------------------------------------------------------------------
- # ● 先鋭化
- #--------------------------------------------------------------------------
- def sharp!
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- unless @@sharp.call( self.object_id , self.width , self.height ).zero?
- GC.start
- unless @@sharp.call( self.object_id ,self.width , self.height ).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- self
- end
- #--------------------------------------------------------------------------
- # ● 鉛筆画調
- #--------------------------------------------------------------------------
- def pencil( act = 3 , st = 10 , sm = 3 )
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( act , 0 , 6 )
- b = self.dup
- unless @@pencil.call(b.object_id,b.width,b.height,act,st,sm).zero?
- GC.start
- unless @@pencil.call(b.object_id,b.width,b.height,act,st,sm).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b
- end
- #--------------------------------------------------------------------------
- # ● 鉛筆画調
- #--------------------------------------------------------------------------
- def pencil!( act = 3 , st = 10 , sm = 3 )
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( act , 0 , 6 )
- unless @@pencil.call(object_id,self.width,self.height,act,st,sm).zero?
- GC.start
- unless @@pencil.call(object_id,self.width,self.height,act,st,sm).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- 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 , 11 )
- @@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
- #--------------------------------------------------------------------------
- # ● ブレンディング
- #--------------------------------------------------------------------------
- def stretch_blend_blt(dest_rect,bitmap,src_rect,blend_type = 0,
- mode = 1,opacity = 255)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( blend_type , 0 , 11 )
- src = make_bitmap_datas( src_rect , bitmap )
- dest = make_bitmap_datas( dest_rect , self )
- unless @@blend_stretch.call( src, dest, blend_type, opacity, mode ).zero?
- GC.start
- unless @@blend_stretch.call( src, dest, blend_type, opacity, mode ).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- self
- end
- #--------------------------------------------------------------------------
- # ● ブレンディング
- #--------------------------------------------------------------------------
- def rotate_blend_blt(x,y,bitmap,src_rect,deg, zoom, blend_type = 0,mode = 1,
- opacity = 255)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( blend_type , 0 , 11 )
- b = Bitmap.new(src_rect.width, src_rect.height)
- b.blt( 0,0,bitmap,src_rect)
- src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
- dest = make_bitmap_datas( Rect.new(x,y,0,0) , self )
- ideg = (deg * 100).to_i
- izoom = (zoom * 1000).to_i
- m = mode
- unless @@blend_rotate.call(src,dest,ideg,izoom,blend_type,opacity,m).zero?
- GC.start
- unless @@blend_rotate.call(src,dest,ideg,izoom,blend_type,opacity,m).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b.dispose
- self
- end
- #--------------------------------------------------------------------------
- # ● ブレンディング
- #--------------------------------------------------------------------------
- def transform_blend_blt(x,y,bitmap,src_rect,dest_pos,blend_type = 0,mode = 1,
- opacity = 255)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( blend_type , 0 , 11 )
- b = Bitmap.new(src_rect.width, src_rect.height)
- b.blt( 0,0,bitmap,src_rect)
- src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
- dest = make_bitmap_datas( Rect.new(x,y,0,0) , self )
- raise(RGSSError,"Invalid dest data.") if dest_pos.size != 8
- destpos_x = [dest_pos.at(0).to_i,dest_pos.at(2).to_i,
- dest_pos.at(4).to_i,dest_pos.at(6).to_i].pack("i*")
- destpos_y = [dest_pos.at(1).to_i,dest_pos.at(3).to_i,
- dest_pos.at(5).to_i,dest_pos.at(7).to_i] .pack("i*")
- unless @@blend_transform.call( src, dest , destpos_x, destpos_y,
- blend_type,opacity,mode ).zero?
- GC.start
- unless @@blend_transform.call( src, dest , destpos_x, destpos_y,
- blend_type,opacity,mode ).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b.dispose
- self
- end
- #--------------------------------------------------------------------------
- # ● ブレンディング
- #--------------------------------------------------------------------------
- def circle_blend_blt(dest_rect,bitmap,src_rect,blend_type = 0,
- mode = 1,opacity = 255)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( blend_type , 0 , 11 )
- b = Bitmap.new(src_rect.width, src_rect.height)
- b.blt( 0,0,bitmap,src_rect)
- src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
- dest = make_bitmap_datas( dest_rect , self )
- unless @@blend_circle.call( src, dest, blend_type, opacity, mode ).zero?
- GC.start
- unless @@blend_circle.call( src, dest, blend_type, opacity, mode ).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b.dispose
- self
- end
- #--------------------------------------------------------------------------
- # ● ブレンディング
- #--------------------------------------------------------------------------
- def sphere_blend_blt(dest_rect,bitmap,src_rect,light_type,blend_type = 0,
- mode = 1,opacity = 255)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- _fixnum_range_check( blend_type , 0 , 11 )
- b = Bitmap.new(src_rect.width, src_rect.height)
- b.blt( 0,0,bitmap,src_rect)
- src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
- dest = make_bitmap_datas( dest_rect , self )
- _type_check_( light_type , Light_Type )
- light = light_type.to_s
- unless @@blend_sphere.call(src,dest,light,blend_type,opacity,mode).zero?
- GC.start
- unless @@blend_sphere.call(src,dest,light,blend_type,opacity,mode).zero?
- raise(NoMemoryError,"failed to allocate memory.")
- end
- end
- b.dispose
- 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
- #--------------------------------------------------------------------------
- # ● 3Dフォント
- #--------------------------------------------------------------------------
- def three_d_draw_font( text , lf , data , overwrite ,
- 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")
- utext = String.utf82uni(text)
- _type_check_( lf , LOGFont )
- _type_check_( data , ThreeDSetting )
- plf = lf.to_s
- pdata = data.to_s
- @@threedfont.call(self.object_id , self.width , self.height , rot,
- utext , plf, pdata , overwrite ? 1 : 0 )
- self
- end
- #--------------------------------------------------------------------------
- # ● 3D球体
- #--------------------------------------------------------------------------
- def three_d_sphere( data , overwrite , r ,w = 1.0,h=1.0,x = 0.0,y = 0.0)
- raise(RGSSError,"disposed bitmap.") if self.disposed?
- rot = [rad2d(0.0),rad2d(0.0),rad2d(0.0),w,h,x,y,r].pack("ffffffff")
- _type_check_( data , ThreeDSetting )
- pdata = data.to_s
- @@thrredsphere.call(self.object_id , self.width , self.height , rot,
- pdata , overwrite ? 1 : 0 )
- 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 make_bitmap_datas( rect , bitmap )
- [bitmap.object_id , 0 , 0 , bitmap.width.to_i , bitmap.height.to_i ,
- rect.x.to_i , rect.y.to_i , rect.width.to_i , rect.height.to_i].pack("L*")
- end
- #--------------------------------------------------------------------------
- # ◆(内部専用)◆ 描画引数
- #--------------------------------------------------------------------------
- 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::PI) / 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 = "Game.rgss3a"#rpgvx? ? (rpgvxace? ? "Game.rgss3a" : "Game.rgss2a") :
- # "Game.rgssad"
- RGSSA_VERSION = 3#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
Advertisement
Add Comment
Please, Sign In to add comment