dsiver144

Bitmap EX

Jun 2nd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.76 KB | None | 0 0
  1. # coding: utf-8
  2. # ===========================================================================
  3. # ★★ WF-RGSS Scripts ★★
  4. # Bitmap-EX ビットマップスクリプト
  5. # バージョン : rev-13.1(2013-3-29)
  6. # 作者 : WF-RGSS担当 (WHITE-FLUTE)
  7. # サポート先URI: http://www.whiteflute.org/wfrgss/
  8. # ---------------------------------------------------------------------------
  9. # 機能:
  10. # ・ビットマップに対して様々なエフェクトをかけることが出来るようになります。
  11. # ・手軽に高速なゲージを導入することができます。
  12. # ・ビットマップをpngファイルに書き出すことができます。
  13. # ・アニメーションGIFをサポートします。暗号化アーカイブからでも読み込めます。
  14. # ・ライン、円、ポリゴン描画などを行うことが出来ます。
  15. # ・線の先端にスタイルを設定したり、線の種別を選択できます。
  16. # ---------------------------------------------------------------------------
  17. # 設置場所 :共通スクリプト より下、Mainより上
  18. # 必要スクリプト:
  19. # ・共通スクリプト、共通実行スクリプト
  20. # 必要DLL: wfbitmap.dll
  21. # 注意事項:
  22. # ▽メソッドによっては時間の掛かる処理があります。
  23. # ▽一部のメソッドは、頂点シェーダおよびピクセルシェーダが2.0に
  24. # 対応している必要があります。
  25. # 著作権表示:
  26. #* libpng version 1.5.4 - July 7, 2011
  27. #* Copyright (c) 1998-2011 Glenn Randers-Pehrson
  28. #* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  29. #* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  30. #
  31. # The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond
  32. #
  33. # stretch_blend_blt バイリニア補完法のアルゴリズムは
  34. # 本棚様(http://ameblo.jp/tales-bado/)の素材を参考にしました。
  35. # http://www.tekepon.net/fsm/modules/imgbb/viewtopic.php?topic_id=3228&forum=12
  36. #==============================================================================
  37. module WFRGSS_BitmapEX
  38. #----------------------------------------------------------------------------
  39. # 高速テキスト描画に置き換えるか
  40.  
  41. USE_DRAW_TEXT = false
  42.  
  43. end
  44.  
  45. #==============================================================================
  46. # RGSS組み込みクラス Font
  47. #------------------------------------------------------------------------------
  48. class Font
  49. #--------------------------------------------------------------------------
  50. # ● クラス変数
  51. #--------------------------------------------------------------------------
  52. @@gradient_start_color = Color.new(255,255,255)
  53. @@gradient_end_color = Color.new(200,200,200)
  54. @@frame_color = Color.new(0,0,0)
  55. #--------------------------------------------------------------------------
  56. # ● オブジェクト初期化
  57. #--------------------------------------------------------------------------
  58. alias __initialize__ initialize unless $@
  59. def initialize(*args)
  60. case args.size
  61. when 2
  62. __initialize__(args.at(0),args.at(1))
  63. when 1
  64. __initialize__(args.at(0))
  65. when 0
  66. __initialize__
  67. else
  68. raise(ArgumentError,"wrong number of arguments(#{args.size} for 2)",
  69. caller(1))
  70. end
  71. @gradient_start_color = @@gradient_start_color.dup
  72. @gradient_end_color = @@gradient_end_color.dup
  73. @frame_color = @@frame_color.dup
  74. end
  75. #--------------------------------------------------------------------------
  76. # ● フォント存在判定
  77. #--------------------------------------------------------------------------
  78. def exist_font
  79. if self.name.is_a?(Array)
  80. for font in self.name
  81. return font if Font.exist?(font)
  82. end
  83. return ""
  84. else
  85. return self.name
  86. end
  87. end
  88.  
  89. def self.default_gradient_start_color
  90. @@gradient_start_color
  91. end
  92.  
  93. def self.default_gradient_start_color=(color)
  94. @@gradient_start_color = color if color.is_a?(Color)
  95. end
  96.  
  97. def self.default_gradient_end_color
  98. @@gradient_end_color
  99. end
  100.  
  101. def self.default_gradient_end_color=(color)
  102. @@gradient_end_color = color if color.is_a?(Color)
  103. end
  104.  
  105. def self.default_frame_color
  106. @@frame_color
  107. end
  108.  
  109. def self.default_frame_color=(color)
  110. @@frame_color = color if color.is_a?(Color)
  111. end
  112.  
  113. def gradient_start_color
  114. @gradient_start_color
  115. end
  116.  
  117. def gradient_start_color=(color)
  118. @gradient_start_color = color if color.is_a?(Color)
  119. end
  120.  
  121. def gradient_end_color
  122. @gradient_end_color
  123. end
  124.  
  125. def gradient_end_color=(color)
  126. @gradient_end_color = color if color.is_a?(Color)
  127. end
  128.  
  129. def frame_color
  130. @frame_color
  131. end
  132.  
  133. def frame_color=(color)
  134. @frame_color = color if color.is_a?(Color)
  135. end
  136. end
  137.  
  138. # ---------------------------------------------------------------------------
  139. # ◆ Lighting
  140. # ---------------------------------------------------------------------------
  141. class Lighting
  142. #--------------------------------------------------------------------------
  143. # ◆ 定数
  144. #--------------------------------------------------------------------------
  145. D3DLIGHT_POINT = 1
  146. D3DLIGHT_SPOT = 2
  147. D3DLIGHT_DIRECTIONAL = 3
  148. #--------------------------------------------------------------------------
  149. # ◆ 公開インスタンス変数
  150. #--------------------------------------------------------------------------
  151. attr_reader :type # 光源のタイプ
  152. attr_accessor :diffuse # ディフューズ色
  153. attr_accessor :specular # スペキュラー色
  154. attr_accessor :ambient # アンビエント色
  155. attr_accessor :range # 範囲
  156. attr_accessor :falloff #
  157. attr_reader :attenation0 #
  158. attr_reader :attenation1 #
  159. attr_reader :attenation2 #
  160. attr_reader :theta #
  161. attr_reader :phi #
  162. #--------------------------------------------------------------------------
  163. # ◆ オブジェクト初期化
  164. #--------------------------------------------------------------------------
  165. def initialize
  166. @type = D3DLIGHT_POINT
  167. @diffuse = Color.new(0,0,0,0)
  168. @specular = Color.new(0,0,0,0)
  169. @ambient = Color.new(0,0,0,0)
  170. @position = Array.new(3){ 0.0 }
  171. @direction = Array.new(3){ 1.0 }
  172. @range = 1.0
  173. @falloff = 1.0
  174. @attenation0 = 0.0
  175. @attenation1 = 0.0
  176. @attenation2 = 0.0
  177. @theta = 0.0
  178. @phi = 0.0
  179. end
  180. #--------------------------------------------------------------------------
  181. # ◆ タイプ設定
  182. #--------------------------------------------------------------------------
  183. def type=(type)
  184. @type = type.to_i
  185. attenation_reset if @type != D3DLIGHT_DIRECTIONAL
  186. end
  187. #--------------------------------------------------------------------------
  188. # ◆ 光源の位置設定
  189. #--------------------------------------------------------------------------
  190. def position_update( x , y , z )
  191. @position[0] = x
  192. @position[1] = y
  193. @position[2] = z
  194. end
  195. #--------------------------------------------------------------------------
  196. # ◆ 光源の向き設定
  197. #--------------------------------------------------------------------------
  198. def direction_update( x , y , z )
  199. @direction[0] = x if x != 0.0
  200. @direction[1] = y if y != 0.0
  201. @direction[2] = z if z != 0.0
  202. end
  203. #--------------------------------------------------------------------------
  204. # ◆
  205. #--------------------------------------------------------------------------
  206. def attenation0=(a)
  207. return if @type != D3DLIGHT_DIRECTIONAL
  208. @attenation0 = a if a >= 0.0
  209. end
  210. #--------------------------------------------------------------------------
  211. # ◆
  212. #--------------------------------------------------------------------------
  213. def attenation1=(a)
  214. return if @type != D3DLIGHT_DIRECTIONAL
  215. @attenation1 = a if a >= 0.0
  216. end
  217. #--------------------------------------------------------------------------
  218. # ◆
  219. #--------------------------------------------------------------------------
  220. def attenation2=(a)
  221. return if @type != D3DLIGHT_DIRECTIONAL
  222. @attenation2 = a if a >= 0.0
  223. end
  224. #--------------------------------------------------------------------------
  225. # ◆
  226. #--------------------------------------------------------------------------
  227. def theta=(a)
  228. return if a < 0.0
  229. return if a > @phi
  230. @theta = a
  231. end
  232. #--------------------------------------------------------------------------
  233. # ◆
  234. #--------------------------------------------------------------------------
  235. def phi=(a)
  236. return if a < 0.0
  237. return if a > Math::PI
  238. @phi = a
  239. @theta = @phi if @theta > @phi
  240. end
  241. #--------------------------------------------------------------------------
  242. # ◆
  243. #--------------------------------------------------------------------------
  244. def to_s
  245. [@type, @diffuse.red / 255.0, @diffuse.green / 255.0,
  246. @diffuse.blue / 255.0, @diffuse.alpha / 255.0,
  247. @specular.red / 255.0, @specular.green / 255.0,
  248. @specular.blue / 255.0, @specular.alpha / 255.0,
  249. @ambient.red / 255.0, @ambient.green / 255.0,
  250. @ambient.blue / 255.0, @ambient.alpha / 255.0,
  251. @position.at(0), @position.at(1), @position.at(2),
  252. @direction.at(0), @direction.at(1), @direction.at(2),
  253. @range, @falloff, @attenation0, @attenation1, @attenation2, @theta,
  254. @phi ].pack("Lf*")
  255. end
  256. private
  257. #--------------------------------------------------------------------------
  258. # ◆
  259. #--------------------------------------------------------------------------
  260. def attenation_reset
  261. @attenation0 = 0.0
  262. @attenation1 = 0.0
  263. @attenation2 = 0.0
  264. end
  265. end
  266. # ---------------------------------------------------------------------------
  267. # ◆ ThreeDSetting
  268. # ---------------------------------------------------------------------------
  269. class ThreeDSetting
  270. #--------------------------------------------------------------------------
  271. # ◆ 公開インスタンス変数
  272. #--------------------------------------------------------------------------
  273. attr_reader :use_light # ライト使用フラグ
  274. attr_reader :use_texture # テクスチャ使用フラグ
  275. attr_accessor :bitmap # テクスチャビットマップ
  276. attr_accessor :extrusion # 厚み(フォントで使用)
  277. attr_accessor :power # スペキュラー強度
  278. attr_accessor :diffuse # ディフューズ色
  279. attr_accessor :specular # スペキュラー色
  280. attr_accessor :ambient # アンビエント色
  281. attr_accessor :emissive # 発光色
  282. attr_reader :light # ライティング
  283. #--------------------------------------------------------------------------
  284. # ◆ オブジェクト初期化
  285. #--------------------------------------------------------------------------
  286. def initialize
  287. @use_light = true
  288. @use_texture = false
  289. @bitmap = nil
  290. @extrusion = 1.0
  291. @power = 1.0
  292. @diffuse = Color.new(0,0,0,0)
  293. @ambient = Color.new(0,0,0,0)
  294. @specular = Color.new(0,0,0,0)
  295. @emissive = Color.new(0,0,0,0)
  296. @light = Lighting.new
  297. end
  298. #--------------------------------------------------------------------------
  299. # ◆ライト使用
  300. #--------------------------------------------------------------------------
  301. def use_light=(a)
  302. @use_light = a ? true : false
  303. end
  304. #--------------------------------------------------------------------------
  305. # ◆ テクスチャ使用
  306. #--------------------------------------------------------------------------
  307. def use_texture=(a)
  308. @use_texutre = a ? true : false
  309. end
  310. #--------------------------------------------------------------------------
  311. # ◆ データ書き出し
  312. #--------------------------------------------------------------------------
  313. def to_s
  314. [@use_light ? 1 : 0 , @use_texutre ? 1 : 0 , @bitmap.object_id ,
  315. @bitmap.width , @bitmap.height , @extrusion , @power ,
  316. @diffuse.red / 255.0, @diffuse.green / 255.0,
  317. @diffuse.blue / 255.0, @diffuse.alpha / 255.0,
  318. @ambient.red / 255.0, @ambient.green / 255.0,
  319. @ambient.blue / 255.0, @ambient.alpha / 255.0,
  320. @specular.red / 255.0, @specular.green / 255.0,
  321. @specular.blue / 255.0, @specular.alpha / 255.0,
  322. @emissive.red / 255.0, @emissive.green / 255.0,
  323. @emissive.blue / 255.0, @emissive.alpha / 255.0 ].pack("SSLLLf*") +
  324. @light.to_s
  325. end
  326. end
  327. # ---------------------------------------------------------------------------
  328. # ◆ LOGFont
  329. # ---------------------------------------------------------------------------
  330. class LOGFont
  331. #--------------------------------------------------------------------------
  332. # ◆ 公開インスタンス変数
  333. #--------------------------------------------------------------------------
  334. attr_accessor :escapement #
  335. attr_accessor :orientation #
  336. attr_accessor :weight # フォントの太さ(100-900)
  337. attr_reader :italic # 斜体
  338. attr_reader :underline # 下線
  339. attr_reader :strikeout # 打ち消し線
  340. #--------------------------------------------------------------------------
  341. # ◆ オブジェクト初期化
  342. #--------------------------------------------------------------------------
  343. def initalize
  344. @facename = ""
  345. @height = 0
  346. @width = 0
  347. @escapement = 0
  348. @orientation = 0
  349. @weight = 400
  350. @italic = false
  351. @underline = false
  352. @strikeout = false
  353. end
  354. #--------------------------------------------------------------------------
  355. # ◆ 斜体
  356. #--------------------------------------------------------------------------
  357. def italic=(italic)
  358. @italic = italic ? true : false
  359. end
  360. #--------------------------------------------------------------------------
  361. # ◆ 下線
  362. #--------------------------------------------------------------------------
  363. def underline=(underline)
  364. @underline = underline ? true : false
  365. end
  366. #--------------------------------------------------------------------------
  367. # ◆ 打ち消し線
  368. #--------------------------------------------------------------------------
  369. def strikeout=(strikeout)
  370. @strikeout = strikeout ? true : false
  371. end
  372. #--------------------------------------------------------------------------
  373. # ◆ フォント書体決定
  374. #--------------------------------------------------------------------------
  375. def facename=(facename)
  376. face = String.utf82uni(facename)
  377. #if rpgvxace?
  378. @facename = face if face.bytesize < 64
  379. #~ else
  380. #~ @facename = face if face.size < 64
  381. #~ end
  382. end
  383. #--------------------------------------------------------------------------
  384. # ◆ データ書き出し
  385. #--------------------------------------------------------------------------
  386. def to_s
  387. [0 , 0, @escapement, @orientation , @weight,
  388. @italic ? 1 : 0, @underline ? 1 : 0,@strikeout ? 1 : 0 ,
  389. 0 , 0 , 0 , 5 , 2].pack("LLLLLC*") + @facename
  390. end
  391. end
  392.  
  393. # ---------------------------------------------------------------------------
  394. # ◆ Light_Type
  395. # ---------------------------------------------------------------------------
  396. class Light_Type
  397. #--------------------------------------------------------------------------
  398. # ◆ 公開インスタンス変数
  399. #--------------------------------------------------------------------------
  400. attr_accessor :x # x
  401. attr_accessor :y # y
  402. attr_accessor :z # z
  403. attr_accessor :mil # ハイライト 1-400
  404. attr_accessor :env # 環境光 1-100
  405. #--------------------------------------------------------------------------
  406. # ◆ オブジェクト初期化
  407. #--------------------------------------------------------------------------
  408. def initialize
  409. @x = 1.0
  410. @y = 1.0
  411. @z = 1.0
  412. @mil = 1.0
  413. @env = 1.0
  414. end
  415. #--------------------------------------------------------------------------
  416. # ◆ データ書き出し
  417. #--------------------------------------------------------------------------
  418. def to_s
  419. [@mil,@env,@x,@y,@z].pack("d*")
  420. end
  421. end
  422.  
  423. # ---------------------------------------------------------------------------
  424. # ◆ 組み込みクラス String
  425. # ---------------------------------------------------------------------------
  426. class String
  427. #--------------------------------------------------------------------------
  428. # ◆ UTF-8 → UNICODE 変換
  429. #--------------------------------------------------------------------------
  430. #~ unless rpgvxace?
  431. #~ def self.utf82uni( str )
  432. #~ to_widechar( str , CP_UTF8 )
  433. #~ end
  434. #~ else
  435. def self.utf82uni( str )
  436. to_widechar(str,CP_UTF8).force_encoding("ASCII-8BIT")
  437. end
  438. #~ end
  439. end
  440.  
  441. #==============================================================================
  442. # RGSS組み込みクラス Bitmap
  443. #------------------------------------------------------------------------------
  444. class Bitmap
  445. #--------------------------------------------------------------------------
  446. # ● クラス変数
  447. #--------------------------------------------------------------------------
  448. begin
  449. @@mosaic = Win32API.new('wfbitmap','mosaic',%w(l l l l l),'l').freeze
  450. @@reversing = Win32API.new('wfbitmap','Reversing',%w(l l l),'l').freeze
  451. @@diffusion = Win32API.new('wfbitmap','Diffusion',%w(l l l l),'l').freeze
  452. @@blur = Win32API.new('wfbitmap','blur',%w(l l l l),'l').freeze
  453. @@darkrndimg = Win32API.new('wfbitmap','DarkRndImg',%w(l l l),'l').freeze
  454. @@lightrndimg = Win32API.new('wfbitmap','lightRndImg',%w(l l l),'l').freeze
  455. @@radialblur = Win32API.new('wfbitmap','radialBlur',%w(l l l l),'l').freeze
  456. @@rotationblur = Win32API.new('wfbitmap','rotationBlur',%w(l l l l),'l').freeze
  457. @@whirlblur = Win32API.new('wfbitmap','WhirlBlur',%w(l l l l l),'l').freeze
  458. @@postaraiz = Win32API.new('wfbitmap','Postaraiz',%w(l l l),'l').freeze
  459. @@guage = Win32API.new('wfbitmap','drawGuage',%w(l l l p p p l l l l l l),'l').freeze
  460. @@png = Win32API.new('wfbitmap','pngWrite',%w(l p i i),'l').freeze
  461. @@pencil = Win32API.new('wfbitmap','pencilEffect',%w(l i i i i i),'l').freeze
  462. @@sharp = Win32API.new('wfbitmap','sharpFilter', %w(l i i),'l').freeze
  463. @@gamma = Win32API.new('wfbitmap','Gamma',%w(l i i i),'l').freeze
  464. @@blend = Win32API.new('wfbitmap','blend_blt',
  465. %w(l l l l l l i i l l l l l l),'l').freeze
  466. @@fontdraw = Win32API.new('wfbitmap','drawText',%w(p p l p p),'i').freeze
  467. @@gfontdraw = Win32API.new('wfbitmap','drawGradientText',%w(p p l p p p p),'i').freeze
  468. @@fontsize = Win32API.new('wfbitmap','getTextSize',%w(p p l p p),'i').freeze
  469. @@dispose = Win32API.new('wfbitmap','dispose','v','v').freeze
  470. @@line = Win32API.new('wfbitmap','drawLine',%w(l l l p p i),'v').freeze
  471. @@ellipse = Win32API.new('wfbitmap','drawEllipse',%w(l l l i i i i p p i i),'v').freeze
  472. @@polygon = Win32API.new('wfbitmap','drawPolygon',%w(l l l p i p p i i i),'i').freeze
  473. @@curve = Win32API.new('wfbitmap','drawCurve',%w(l l l p i p p i i),'i').freeze
  474. @@closedcurve = Win32API.new('wfbitmap','drawClosedCurve',%w(l l l p i p p i i i i),'i').freeze
  475. @@pie = Win32API.new('wfbitmap','drawPie',%w(l l l i i i i p p i i i i),'v').freeze
  476. @@antialias = Win32API.new('wfbitmap','setAntiAliasMode','l','v').freeze
  477. @@tellipse = Win32API.new('wfbitmap','textureEllipse',%w(p p l l l l),'v').freeze
  478. @@tpolygon = Win32API.new('wfbitmap','texturePolygon',%w(p p p l i),'i').freeze
  479. @@tclosedcurve = Win32API.new('wfbitmap','textureClosedCurve',%w(p p p l i i),'i').freeze
  480. @@tpie = Win32API.new('wfbitmap','texturePie',%w(p p i i i i i i),'v').freeze
  481. @@dashmode = Win32API.new('wfbitmap','setPenDashStyleMode','i','v').freeze
  482. @@gray = Win32API.new('wfbitmap','grayScale',%w(l l l),'v').freeze
  483. @@raster = Win32API.new('wfbitmap','rasterScroll',%w(l l l i i),'v').freeze
  484. @@startcap = Win32API.new('wfbitmap','setLineStartCapMode','i','v').freeze
  485. @@endcap = Win32API.new('wfbitmap','setLineEndCapMode','i','v').freeze
  486. @@join = Win32API.new('wfbitmap','setLineJoinMode','i','v').freeze
  487. @@arc = Win32API.new('wfbitmap','drawArc',%w(l l l i i i i p p i i i),'v').freeze
  488. @@bezier = Win32API.new('wfbitmap','drawBeziers',%w(l l l p l p p i),'i').freeze
  489. @@threedtrans = Win32API.new('wfbitmap','ThreeDTransform',%w(l i i p),'l').freeze
  490. @@threedfont = Win32API.new('wfbitmap','ThreeDDrawText',%w(l i i p p p p i),'l').freeze
  491. @@thrredsphere = Win32API.new('wfbitmap','ThreeDSphere',%w(l i i p p i),'l').freeze
  492. @@blend_stretch = Win32API.new('wfbitmap','stretch_blend_blt',%w(p p i i i),'l').freeze
  493. @@blend_rotate = Win32API.new('wfbitmap','rotate_blend_blt',%w(p p i i i i i),'l').freeze
  494. @@blend_transform = Win32API.new('wfbitmap','transform_blend_blt',%w(p p p p i i i),'l').freeze
  495. @@blend_circle = Win32API.new('wfbitmap','circle_blend_blt',%w(p p i i i),'l').freeze
  496. @@blend_sphere = Win32API.new('wfbitmap','sphere_blend_blt',%w(p p p i i i),'l').freeze
  497. rescue Exception
  498. raise if debug?
  499. raise(LoadError,"cannot read modules.(wfbitmap.dll)")
  500. end
  501. #--------------------------------------------------------------------------
  502. # ● 定数
  503. #--------------------------------------------------------------------------
  504. DASH_STYLE_SOLID = 0
  505. DASH_STYLE_DASH = 1
  506. DASH_STYLE_DOT = 2
  507. DASH_STYLE_DASHDOT = 3
  508. DASH_STYLE_DASHDOTDOT = 4
  509.  
  510. LINE_CAP_FLAT = 0
  511. LINE_CAP_SQUARE = 1
  512. LINE_CAP_ROUND = 2
  513. LINE_CAP_TRIANGLE = 3
  514. LINE_CAP_NOANCHOR = 4
  515. LINE_CAP_SQUAREANCHOR = 5
  516. LINE_CAP_ROUNDANCHOR = 6
  517. LINE_CAP_DIAMONDANCHOR = 7
  518. LINE_CAP_ARROWAMNCHOR = 8
  519. LINE_CAP_ANCHORMASK = 9
  520.  
  521. LINE_JOIN_MITER = 0
  522. LINE_JOIN_BEVEL = 1
  523. LINE_JOIN_ROUND = 2
  524. LINE_JOIN_MITERCLIPPED = 3
  525. #--------------------------------------------------------------------------
  526. # ● 解放
  527. #--------------------------------------------------------------------------
  528. def self.dispose
  529. @@dispose.call()
  530. end
  531. #--------------------------------------------------------------------------
  532. # ● アンチエイリアスモード
  533. #--------------------------------------------------------------------------
  534. def antialias_mode=( mode )
  535. @@antialias.call(mode ? 1 : 0 )
  536. end
  537. #--------------------------------------------------------------------------
  538. # ● 線の種類
  539. #--------------------------------------------------------------------------
  540. def dash_style=(style)
  541. @@dashmode.call( style )
  542. end
  543. #--------------------------------------------------------------------------
  544. # ● 開始点のスタイル
  545. #--------------------------------------------------------------------------
  546. def line_start_cap=(mode)
  547. @@startcap.call( mode )
  548. end
  549. #--------------------------------------------------------------------------
  550. # ● 終了点のスタイル
  551. #--------------------------------------------------------------------------
  552. def line_end_cap=(mode)
  553. @@endcap.call( mode )
  554. end
  555. #--------------------------------------------------------------------------
  556. # ● 線分の接続形
  557. #--------------------------------------------------------------------------
  558. def line_join=(mode)
  559. @@join.call( mode )
  560. end
  561. #--------------------------------------------------------------------------
  562. # ● モザイク
  563. #--------------------------------------------------------------------------
  564. def mosaic( msx = 2, msy = 2)
  565. raise(RGSSError,"disposed bitmap.") if self.disposed?
  566. b = self.dup
  567. @@mosaic.call( b.object_id , msx , msy , b.width , b.height )
  568. b
  569. end
  570. #--------------------------------------------------------------------------
  571. # ● モザイク
  572. #--------------------------------------------------------------------------
  573. def mosaic!( msx = 2, msy = 2)
  574. raise(RGSSError,"disposed bitmap.") if self.disposed?
  575. @@mosaic.call( object_id , msx , msy , self.width , self.height )
  576. self
  577. end
  578. #--------------------------------------------------------------------------
  579. # ● 色反転
  580. #--------------------------------------------------------------------------
  581. def reversing
  582. raise(RGSSError,"disposed bitmap.") if self.disposed?
  583. b = self.dup
  584. @@reversing.call( b.object_id , b.width , b.height )
  585. b
  586. end
  587. #--------------------------------------------------------------------------
  588. # ● 色反転
  589. #--------------------------------------------------------------------------
  590. def reversing!
  591. raise(RGSSError,"disposed bitmap.") if self.disposed?
  592. @@reversing.call( object_id , self.width , self.height )
  593. self
  594. end
  595. #--------------------------------------------------------------------------
  596. # ● 拡散
  597. #--------------------------------------------------------------------------
  598. def diffusion( noise = 2 )
  599. raise(RGSSError,"disposed bitmap.") if self.disposed?
  600. b = self.dup
  601. @@diffusion.call( b.object_id , noise , b.width , b.height )
  602. b
  603. end
  604. #--------------------------------------------------------------------------
  605. # ● 拡散
  606. #--------------------------------------------------------------------------
  607. def diffusion!( noise = 2 )
  608. raise(RGSSError,"disposed bitmap.") if self.disposed?
  609. @@diffusion.call( object_id , noise , self.width , self.height )
  610. self
  611. end
  612. #unless rpgvx?
  613. #--------------------------------------------------------------------------
  614. # ● ぼかし(※時間がかかります。) ※ XPのみ VXでは標準のものを使う
  615. #--------------------------------------------------------------------------
  616. def blur( sm = 5 )
  617. raise(RGSSError,"disposed bitmap.") if self.disposed?
  618. b = self.dup
  619. @@blur.call(b.object_id , sm , b.width , b.height )
  620. b
  621. end
  622. #~ else
  623. #~ #--------------------------------------------------------------------------
  624. #~ # ● ぼかし(※時間がかかります。) ※ VXのみ
  625. #~ #--------------------------------------------------------------------------
  626. #~ def blur2( sm = 5 )
  627. #~ raise(RGSSError,"disposed bitmap.") if self.disposed?
  628. #~ b = self.dup
  629. #~ @@blur.call(b.object_id , sm , b.width , b.height )
  630. #~ b
  631. #~ end
  632. #end
  633. #--------------------------------------------------------------------------
  634. # ● ぼかし(※時間がかかります。)
  635. #--------------------------------------------------------------------------
  636. def blur!( sm = 5 )
  637. raise(RGSSError,"disposed bitmap.") if self.disposed?
  638. @@blur.call(object_id , sm , self.width , self.height )
  639. self
  640. end
  641. #--------------------------------------------------------------------------
  642. # ● ランダム色(暗色)
  643. #--------------------------------------------------------------------------
  644. def darkrndimg
  645. raise(RGSSError,"disposed bitmap.") if self.disposed?
  646. b = self.dup
  647. @@darkrndimg.call( b.object_id , b.width , b.height)
  648. b
  649. end
  650. #--------------------------------------------------------------------------
  651. # ● ランダム色(暗色)
  652. #--------------------------------------------------------------------------
  653. def darkrndimg!
  654. raise(RGSSError,"disposed bitmap.") if self.disposed?
  655. @@darkrndimg.call( object_id , self.width , self.height)
  656. self
  657. end
  658. #--------------------------------------------------------------------------
  659. # ● ランダム色(明色)
  660. #--------------------------------------------------------------------------
  661. def lightrndimg
  662. raise(RGSSError,"disposed bitmap.") if self.disposed?
  663. b = self.dup
  664. @@lightrndimg.call( b.object_id , b.width , b.height)
  665. b
  666. end
  667. #--------------------------------------------------------------------------
  668. # ● ランダム色(明色)
  669. #--------------------------------------------------------------------------
  670. def lightrndimg!
  671. raise(RGSSError,"disposed bitmap.") if self.disposed?
  672. @@lightrndimg.call( object_id , self.width , self.height)
  673. self
  674. end
  675. #--------------------------------------------------------------------------
  676. # ● 放射状ブラー(※時間がかかります。)
  677. #--------------------------------------------------------------------------
  678. def radialblur( ef = 10 )
  679. raise(RGSSError,"disposed bitmap.") if self.disposed?
  680. b = self.dup
  681. @@radialblur.call( b.object_id , b.width , b.height , ef )
  682. b
  683. end
  684. #--------------------------------------------------------------------------
  685. # ● 放射状ブラー(※時間がかかります。)
  686. #--------------------------------------------------------------------------
  687. def radialblur!( ef = 10 )
  688. raise(RGSSError,"disposed bitmap.") if self.disposed?
  689. @@radialblur.call( object_id , self.width , self.height , ef )
  690. self
  691. end
  692. #--------------------------------------------------------------------------
  693. # ● 回転ブラー(※時間がかかります。)
  694. #--------------------------------------------------------------------------
  695. def rotationblur( ef = 10 )
  696. raise(RGSSError,"disposed bitmap.") if self.disposed?
  697. b = self.dup
  698. @@rotationblur.call( b.object_id , b.width , b.height , ef )
  699. b
  700. end
  701. #--------------------------------------------------------------------------
  702. # ● 回転ブラー(※時間がかかります。)
  703. #--------------------------------------------------------------------------
  704. def rotationblur!( ef = 10 )
  705. raise(RGSSError,"disposed bitmap.") if self.disposed?
  706. @@rotationblur.call( object_id , self.width , self.height , ef )
  707. self
  708. end
  709. #--------------------------------------------------------------------------
  710. # ● 渦巻き(※時間がかかります。)
  711. #--------------------------------------------------------------------------
  712. def whirlblur( ef = 10 , r = 1 )
  713. raise(RGSSError,"disposed bitmap.") if self.disposed?
  714. _fixnum_range_check( r , -12 , 12 )
  715. b = self.dup
  716. @@whirlblur.call( b.object_id , b.width , b.height , ef , r )
  717. b
  718. end
  719. #--------------------------------------------------------------------------
  720. # ● 渦巻き(※時間がかかります。)
  721. #--------------------------------------------------------------------------
  722. def whirlblur!( ef = 10 , r = 1 )
  723. raise(RGSSError,"disposed bitmap.") if self.disposed?
  724. _fixnum_range_check( r , -12 , 12 )
  725. @@whirlblur.call( object_id , self.width , self.height , ef , r )
  726. self
  727. end
  728. #--------------------------------------------------------------------------
  729. # ● ガンマ補正
  730. #--------------------------------------------------------------------------
  731. def gamma( gamma = 1.0 )
  732. raise(RGSSError,"disposed bitmap.") if self.disposed?
  733. b = self.dup
  734. @@gamma.call( b.object_id , b.width , b.height , (gamma * 100).to_i )
  735. b
  736. end
  737. #--------------------------------------------------------------------------
  738. # ● ガンマ補正
  739. #--------------------------------------------------------------------------
  740. def gamma!( gamma = 1.0 )
  741. raise(RGSSError,"disposed bitmap.") if self.disposed?
  742. @@gamma.call( object_id , width , height , (gamma * 100).to_i )
  743. self
  744. end
  745. #--------------------------------------------------------------------------
  746. # ● 先鋭化
  747. #--------------------------------------------------------------------------
  748. def sharp
  749. raise(RGSSError,"disposed bitmap.") if self.disposed?
  750. b = self.dup
  751. unless @@sharp.call( b.object_id , b.width , b.height ).zero?
  752. GC.start
  753. unless @@sharp.call( b.object_id , b.width , b.height ).zero?
  754. raise(NoMemoryError,"failed to allocate memory.")
  755. end
  756. end
  757. b
  758. end
  759. #--------------------------------------------------------------------------
  760. # ● 先鋭化
  761. #--------------------------------------------------------------------------
  762. def sharp!
  763. raise(RGSSError,"disposed bitmap.") if self.disposed?
  764. unless @@sharp.call( self.object_id , self.width , self.height ).zero?
  765. GC.start
  766. unless @@sharp.call( self.object_id ,self.width , self.height ).zero?
  767. raise(NoMemoryError,"failed to allocate memory.")
  768. end
  769. end
  770. self
  771. end
  772. #--------------------------------------------------------------------------
  773. # ● 鉛筆画調
  774. #--------------------------------------------------------------------------
  775. def pencil( act = 3 , st = 10 , sm = 3 )
  776. raise(RGSSError,"disposed bitmap.") if self.disposed?
  777. _fixnum_range_check( act , 0 , 6 )
  778. b = self.dup
  779. unless @@pencil.call(b.object_id,b.width,b.height,act,st,sm).zero?
  780. GC.start
  781. unless @@pencil.call(b.object_id,b.width,b.height,act,st,sm).zero?
  782. raise(NoMemoryError,"failed to allocate memory.")
  783. end
  784. end
  785. b
  786. end
  787. #--------------------------------------------------------------------------
  788. # ● 鉛筆画調
  789. #--------------------------------------------------------------------------
  790. def pencil!( act = 3 , st = 10 , sm = 3 )
  791. raise(RGSSError,"disposed bitmap.") if self.disposed?
  792. _fixnum_range_check( act , 0 , 6 )
  793. unless @@pencil.call(object_id,self.width,self.height,act,st,sm).zero?
  794. GC.start
  795. unless @@pencil.call(object_id,self.width,self.height,act,st,sm).zero?
  796. raise(NoMemoryError,"failed to allocate memory.")
  797. end
  798. end
  799. self
  800. end
  801. #--------------------------------------------------------------------------
  802. # ● ポスタライズ
  803. #--------------------------------------------------------------------------
  804. def postaraiz
  805. raise(RGSSError,"disposed bitmap.") if self.disposed?
  806. b = self.dup
  807. @@postaraiz.call( b.object_id , b.width , b.height )
  808. b
  809. end
  810. #--------------------------------------------------------------------------
  811. # ● ポスタライズ
  812. #--------------------------------------------------------------------------
  813. def postaraiz!
  814. raise(RGSSError,"disposed bitmap.") if self.disposed?
  815. @@postaraiz.call( object_id , self.width , self.height )
  816. self
  817. end
  818. #--------------------------------------------------------------------------
  819. # ● グレイスケール
  820. #--------------------------------------------------------------------------
  821. def gray_scale
  822. raise(RGSSError,"disposed bitmap.") if self.disposed?
  823. b = self.dup
  824. @@gray.call( b.object_id , b.width , b.height )
  825. b
  826. end
  827. #--------------------------------------------------------------------------
  828. # ● グレイスケール
  829. #--------------------------------------------------------------------------
  830. def gray_scale!
  831. raise(RGSSError,"disposed bitmap.") if self.disposed?
  832. @@gray.call(self.object_id , self.width , self.height )
  833. self
  834. end
  835. #--------------------------------------------------------------------------
  836. # ● ラスタースクロール
  837. #--------------------------------------------------------------------------
  838. def raster_scroll( amp , length )
  839. raise(RGSSError,"disposed bitmap.") if self.disposed?
  840. raise(RGSSError,"Invalid amp data.") if (self.width >> 1) <= amp
  841. b = self.dup
  842. @@raster.call(b.object_id , b.width , b.height ,amp , length )
  843. b
  844. end
  845. #--------------------------------------------------------------------------
  846. # ● ラスタースクロール
  847. #--------------------------------------------------------------------------
  848. def raster_scroll!( amp , length )
  849. raise(RGSSError,"disposed bitmap.") if self.disposed?
  850. raise(RGSSError,"Invalid amp data.") if (self.width >> 1) <= amp
  851. @@raster.call(self.object_id , self.width , self.height ,amp , length )
  852. self
  853. end
  854. #--------------------------------------------------------------------------
  855. # ● 横ゲージ描画
  856. #--------------------------------------------------------------------------
  857. def horizontal_gauge( x, y, width, height, color1, color2, basecolor,life )
  858. raise(RGSSError,"disposed bitmap.") if self.disposed?
  859. c1 = color_convert( color1 )
  860. c2 = color_convert( color2 )
  861. bc = color_convert( basecolor )
  862. @@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
  863. x , y + height, width , height , life , 0 )
  864. self
  865. end
  866. #--------------------------------------------------------------------------
  867. # ● 縦ゲージ描画
  868. #--------------------------------------------------------------------------
  869. def vertical_gauge( x, y, width, height, color1 , color2 , basecolor , life )
  870. raise(RGSSError,"disposed bitmap.") if self.disposed?
  871. c1 = color_convert( color1 )
  872. c2 = color_convert( color2 )
  873. bc = color_convert( basecolor )
  874. @@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
  875. x , y + height, width , height , life , 1 )
  876. self
  877. end
  878. #--------------------------------------------------------------------------
  879. # ● 横ゲージ描画2 ▽△
  880. #--------------------------------------------------------------------------
  881. def horizontal_gauge2( x, y, width, height, color1, color2, basecolor,life )
  882. raise(RGSSError,"disposed bitmap.") if self.disposed?
  883. c1 = color_convert( color1 )
  884. c2 = color_convert( color2 )
  885. bc = color_convert( basecolor )
  886. @@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
  887. x + height, y + height, width , height , life , 2 )
  888. self
  889. end
  890. #--------------------------------------------------------------------------
  891. # ● 横ゲージ描画3 △▽
  892. #--------------------------------------------------------------------------
  893. def horizontal_gauge3( x, y, width, height, color1, color2, basecolor,life )
  894. raise(RGSSError,"disposed bitmap.") if self.disposed?
  895. c1 = color_convert( color1 )
  896. c2 = color_convert( color2 )
  897. bc = color_convert( basecolor )
  898. @@guage.call( object_id , self.width , self.height , c1 , c2 , bc ,
  899. x, y + height, width , height , life , 3 )
  900. self
  901. end
  902. #--------------------------------------------------------------------------
  903. # ● PNG書き出し
  904. #--------------------------------------------------------------------------
  905. def write_png( filename )
  906. raise(RGSSError,"disposed bitmap.") if self.disposed?
  907. @@png.call( object_id , filename , self.width , self.height )
  908. end
  909. #--------------------------------------------------------------------------
  910. # ● ブレンディング
  911. #--------------------------------------------------------------------------
  912. def blend_blt( x, y , src, rect, blend_type = 0 , opacity = 255 )
  913. raise(RGSSError,"disposed bitmap.") if self.disposed?
  914. _fixnum_range_check( blend_type , 0 , 11 )
  915. @@blend.call( self.object_id , src.object_id , x , y , rect.x , rect.y ,
  916. blend_type , opacity , src.width , src.height ,
  917. self.width , self.height , rect.width , rect.height)
  918. self
  919. end
  920. #--------------------------------------------------------------------------
  921. # ● ブレンディング
  922. #--------------------------------------------------------------------------
  923. def stretch_blend_blt(dest_rect,bitmap,src_rect,blend_type = 0,
  924. mode = 1,opacity = 255)
  925. raise(RGSSError,"disposed bitmap.") if self.disposed?
  926. _fixnum_range_check( blend_type , 0 , 11 )
  927. src = make_bitmap_datas( src_rect , bitmap )
  928. dest = make_bitmap_datas( dest_rect , self )
  929. unless @@blend_stretch.call( src, dest, blend_type, opacity, mode ).zero?
  930. GC.start
  931. unless @@blend_stretch.call( src, dest, blend_type, opacity, mode ).zero?
  932. raise(NoMemoryError,"failed to allocate memory.")
  933. end
  934. end
  935. self
  936. end
  937. #--------------------------------------------------------------------------
  938. # ● ブレンディング
  939. #--------------------------------------------------------------------------
  940. def rotate_blend_blt(x,y,bitmap,src_rect,deg, zoom, blend_type = 0,mode = 1,
  941. opacity = 255)
  942. raise(RGSSError,"disposed bitmap.") if self.disposed?
  943. _fixnum_range_check( blend_type , 0 , 11 )
  944. b = Bitmap.new(src_rect.width, src_rect.height)
  945. b.blt( 0,0,bitmap,src_rect)
  946. src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
  947. dest = make_bitmap_datas( Rect.new(x,y,0,0) , self )
  948. ideg = (deg * 100).to_i
  949. izoom = (zoom * 1000).to_i
  950. m = mode
  951. unless @@blend_rotate.call(src,dest,ideg,izoom,blend_type,opacity,m).zero?
  952. GC.start
  953. unless @@blend_rotate.call(src,dest,ideg,izoom,blend_type,opacity,m).zero?
  954. raise(NoMemoryError,"failed to allocate memory.")
  955. end
  956. end
  957. b.dispose
  958. self
  959. end
  960. #--------------------------------------------------------------------------
  961. # ● ブレンディング
  962. #--------------------------------------------------------------------------
  963. def transform_blend_blt(x,y,bitmap,src_rect,dest_pos,blend_type = 0,mode = 1,
  964. opacity = 255)
  965. raise(RGSSError,"disposed bitmap.") if self.disposed?
  966. _fixnum_range_check( blend_type , 0 , 11 )
  967. b = Bitmap.new(src_rect.width, src_rect.height)
  968. b.blt( 0,0,bitmap,src_rect)
  969. src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
  970. dest = make_bitmap_datas( Rect.new(x,y,0,0) , self )
  971. raise(RGSSError,"Invalid dest data.") if dest_pos.size != 8
  972. destpos_x = [dest_pos.at(0).to_i,dest_pos.at(2).to_i,
  973. dest_pos.at(4).to_i,dest_pos.at(6).to_i].pack("i*")
  974. destpos_y = [dest_pos.at(1).to_i,dest_pos.at(3).to_i,
  975. dest_pos.at(5).to_i,dest_pos.at(7).to_i] .pack("i*")
  976. unless @@blend_transform.call( src, dest , destpos_x, destpos_y,
  977. blend_type,opacity,mode ).zero?
  978. GC.start
  979. unless @@blend_transform.call( src, dest , destpos_x, destpos_y,
  980. blend_type,opacity,mode ).zero?
  981. raise(NoMemoryError,"failed to allocate memory.")
  982. end
  983. end
  984. b.dispose
  985. self
  986. end
  987. #--------------------------------------------------------------------------
  988. # ● ブレンディング
  989. #--------------------------------------------------------------------------
  990. def circle_blend_blt(dest_rect,bitmap,src_rect,blend_type = 0,
  991. mode = 1,opacity = 255)
  992. raise(RGSSError,"disposed bitmap.") if self.disposed?
  993. _fixnum_range_check( blend_type , 0 , 11 )
  994. b = Bitmap.new(src_rect.width, src_rect.height)
  995. b.blt( 0,0,bitmap,src_rect)
  996. src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
  997. dest = make_bitmap_datas( dest_rect , self )
  998. unless @@blend_circle.call( src, dest, blend_type, opacity, mode ).zero?
  999. GC.start
  1000. unless @@blend_circle.call( src, dest, blend_type, opacity, mode ).zero?
  1001. raise(NoMemoryError,"failed to allocate memory.")
  1002. end
  1003. end
  1004. b.dispose
  1005. self
  1006. end
  1007. #--------------------------------------------------------------------------
  1008. # ● ブレンディング
  1009. #--------------------------------------------------------------------------
  1010. def sphere_blend_blt(dest_rect,bitmap,src_rect,light_type,blend_type = 0,
  1011. mode = 1,opacity = 255)
  1012. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1013. _fixnum_range_check( blend_type , 0 , 11 )
  1014. b = Bitmap.new(src_rect.width, src_rect.height)
  1015. b.blt( 0,0,bitmap,src_rect)
  1016. src = make_bitmap_datas( Rect.new(0,0,b.width,b.height),b)
  1017. dest = make_bitmap_datas( dest_rect , self )
  1018. _type_check_( light_type , Light_Type )
  1019. light = light_type.to_s
  1020. unless @@blend_sphere.call(src,dest,light,blend_type,opacity,mode).zero?
  1021. GC.start
  1022. unless @@blend_sphere.call(src,dest,light,blend_type,opacity,mode).zero?
  1023. raise(NoMemoryError,"failed to allocate memory.")
  1024. end
  1025. end
  1026. b.dispose
  1027. self
  1028. end
  1029. #--------------------------------------------------------------------------
  1030. # ● 3Dトランスフォーム
  1031. #--------------------------------------------------------------------------
  1032. def three_d_transform(rotx,roty,rotz,w =1.0,h = 1.0,x = 0.0,y = 0.0,d = 1.0)
  1033. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1034. rot = [rad2d(rotx),rad2d(roty),rad2d(rotz),w,h,x,y,d].pack("ffffffff")
  1035. @@threedtrans.call(self.object_id, self.width, self.height, rot)
  1036. self
  1037. end
  1038. #--------------------------------------------------------------------------
  1039. # ● 3Dフォント
  1040. #--------------------------------------------------------------------------
  1041. def three_d_draw_font( text , lf , data , overwrite ,
  1042. rotx,roty,rotz,w =1.0,h = 1.0,x = 0.0,y = 0.0,d = 1.0)
  1043. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1044. rot = [rad2d(rotx),rad2d(roty),rad2d(rotz),
  1045. w,h,x,y,d].pack("ffffffff")
  1046. utext = String.utf82uni(text)
  1047. _type_check_( lf , LOGFont )
  1048. _type_check_( data , ThreeDSetting )
  1049. plf = lf.to_s
  1050. pdata = data.to_s
  1051. @@threedfont.call(self.object_id , self.width , self.height , rot,
  1052. utext , plf, pdata , overwrite ? 1 : 0 )
  1053. self
  1054. end
  1055. #--------------------------------------------------------------------------
  1056. # ● 3D球体
  1057. #--------------------------------------------------------------------------
  1058. def three_d_sphere( data , overwrite , r ,w = 1.0,h=1.0,x = 0.0,y = 0.0)
  1059. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1060. rot = [rad2d(0.0),rad2d(0.0),rad2d(0.0),w,h,x,y,r].pack("ffffffff")
  1061. _type_check_( data , ThreeDSetting )
  1062. pdata = data.to_s
  1063. @@thrredsphere.call(self.object_id , self.width , self.height , rot,
  1064. pdata , overwrite ? 1 : 0 )
  1065. self
  1066. end
  1067. #--------------------------------------------------------------------------
  1068. # ● ライン描画
  1069. #--------------------------------------------------------------------------
  1070. def simple_draw_line(start_x , start_y , end_x , end_y , color , width = 1)
  1071. draw_line( start_x , start_y , end_x , end_y , color , color , width)
  1072. end
  1073. #--------------------------------------------------------------------------
  1074. # ● ライン描画
  1075. #--------------------------------------------------------------------------
  1076. def draw_line( start_x, start_y, end_x, end_y,
  1077. start_color, end_color, width = 1)
  1078. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1079. pstart = [ start_x , start_y , start_color.blue , start_color.green ,
  1080. start_color.red , start_color.alpha ].pack("iiCCCC")
  1081. pend = [ end_x , end_y , end_color.blue , end_color.green ,
  1082. end_color.red , end_color.alpha ].pack("iiCCCC")
  1083. w = Integer( width * 100.0 )
  1084. @@line.call(self.object_id ,self.width,self.height,pstart,pend,w)
  1085. self
  1086. end
  1087. #--------------------------------------------------------------------------
  1088. # ● 円描画
  1089. #--------------------------------------------------------------------------
  1090. def simple_draw_ellipse(start_x,start_y,end_x,end_y,color,fill,width = 1)
  1091. draw_ellipse( start_x , start_y , end_x , end_y , 0, 0, 1 , 1 ,
  1092. color , color , fill , width)
  1093. end
  1094. #--------------------------------------------------------------------------
  1095. # ● 円描画
  1096. #--------------------------------------------------------------------------
  1097. def draw_ellipse( start_x , start_y , end_x , end_y ,
  1098. gra_start_x , gra_start_y, gra_end_x , gra_end_y ,
  1099. start_color , end_color , fill , width = 1)
  1100. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1101. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1102. start_color.red , start_color.alpha ].pack("iiCCCC")
  1103. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1104. end_color.red , end_color.alpha ].pack("iiCCCC")
  1105. w = Integer( width * 100.0 )
  1106. @@ellipse.call(self.object_id,self.width,self.height,
  1107. start_x,start_y,end_x,end_y,pstart,pend,fill ? 1 : 0, w)
  1108. self
  1109. end
  1110. #--------------------------------------------------------------------------
  1111. # ● ポリゴン描画
  1112. #--------------------------------------------------------------------------
  1113. def simple_draw_polygon(polygon,count,color,fill,mode = true,width = 1)
  1114. draw_polygon( polygon, count, 0, 0, 1, 1, color, color,fill, mode,width)
  1115. end
  1116. #--------------------------------------------------------------------------
  1117. # ● ポリゴン描画
  1118. #--------------------------------------------------------------------------
  1119. def draw_polygon( polygon , count , gra_start_x , gra_start_y, gra_end_x ,
  1120. gra_end_y , start_color , end_color ,
  1121. fill , mode = true, width = 1)
  1122. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1123. unless polygon.size > 5 and polygon.size & 0x1 == 0 and
  1124. (polygon.size >> 1) == count
  1125. raise(RGSSError,"Invalid polygon data.")
  1126. end
  1127. poly = polygon.pack("s*")
  1128. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1129. start_color.red , start_color.alpha ].pack("iiCCCC")
  1130. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1131. end_color.red , end_color.alpha ].pack("iiCCCC")
  1132. w = Integer( width * 100.0 )
  1133. @@polygon.call( self.object_id , self.width , self.height , poly , count ,
  1134. pstart , pend , fill ? 1 : 0 , mode ? 1 : 0 , w)
  1135. self
  1136. end
  1137. #--------------------------------------------------------------------------
  1138. # ● カーブ描画
  1139. #--------------------------------------------------------------------------
  1140. def simple_draw_curve( curve , count , color , width = 1 , tension = 50 )
  1141. draw_curve( curve , count , 0, 0, 1, 1, color, color,width,tension)
  1142. end
  1143. #--------------------------------------------------------------------------
  1144. # ● カーブ描画
  1145. #--------------------------------------------------------------------------
  1146. def draw_curve( curve , count , gra_start_x , gra_start_y, gra_end_x ,
  1147. gra_end_y , start_color ,end_color,width = 1 ,tension = 50)
  1148. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1149. unless curve.size > 5 and curve.size & 0x1 == 0 and
  1150. (curve.size >> 1) == count
  1151. raise(RGSSError,"Invalid curve data.")
  1152. end
  1153. poly = curve.pack("s*")
  1154. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1155. start_color.red , start_color.alpha ].pack("iiCCCC")
  1156. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1157. end_color.red , end_color.alpha ].pack("iiCCCC")
  1158. w = Integer( width * 100.0 )
  1159. @@curve.call( self.object_id , self.width , self.height , poly , count ,
  1160. pstart , pend , w , tension)
  1161. self
  1162. end
  1163. #--------------------------------------------------------------------------
  1164. # ● 閉カーブ描画
  1165. #--------------------------------------------------------------------------
  1166. def simple_draw_closed_curve( curve, count, color, fill, mode = true,
  1167. width = 1, tension = 50)
  1168. draw_closed_curve(curve,count,0,0,1,1,color,color,fill,mode,width,tension)
  1169. end
  1170. #--------------------------------------------------------------------------
  1171. # ● 閉カーブ描画
  1172. #--------------------------------------------------------------------------
  1173. def draw_closed_curve( curve , count , gra_start_x , gra_start_y, gra_end_x ,
  1174. gra_end_y , start_color ,end_color,
  1175. fill , mode = true , width = 1 ,tension = 50)
  1176. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1177. unless curve.size > 5 and curve.size & 0x1 == 0 and
  1178. (curve.size >> 1) == count
  1179. raise(RGSSError,"Invalid curve data.")
  1180. end
  1181. poly = curve.pack("s*")
  1182. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1183. start_color.red , start_color.alpha ].pack("iiCCCC")
  1184. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1185. end_color.red , end_color.alpha ].pack("iiCCCC")
  1186. w = Integer( width * 100.0 )
  1187. @@closedcurve.call( self.object_id, self.width, self.height, poly, count,
  1188. pstart , pend , fill ? 1 : 0 , mode ? 1 : 0 , w , tension)
  1189. self
  1190. end
  1191. #--------------------------------------------------------------------------
  1192. # ● パイ描画
  1193. #--------------------------------------------------------------------------
  1194. def simple_draw_pie(start_x, start_y, end_x, end_y,
  1195. color,start_angle,sweep_angle,fill,width = 1)
  1196. draw_pie( start_x, start_y, end_x, end_y, 0, 0, 1, 1,
  1197. color,color,start_angle,sweep_angle,fill,width)
  1198. end
  1199. #--------------------------------------------------------------------------
  1200. # ● パイ描画
  1201. #--------------------------------------------------------------------------
  1202. def draw_pie( start_x, start_y, end_x, end_y,
  1203. gra_start_x, gra_start_y, gra_end_x , gra_end_y ,
  1204. start_color,end_color,start_angle,sweep_angle,fill,width = 1)
  1205. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1206. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1207. start_color.red , start_color.alpha ].pack("iiCCCC")
  1208. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1209. end_color.red , end_color.alpha ].pack("iiCCCC")
  1210. w = Integer( width * 100.0 )
  1211. @@pie.call(self.object_id,self.width,self.height,start_x,start_y,
  1212. end_x,end_y, pstart, pend, start_angle, sweep_angle,
  1213. fill ? 1 : 0 , w )
  1214. self
  1215. end
  1216. #--------------------------------------------------------------------------
  1217. # ● 円弧描画
  1218. #--------------------------------------------------------------------------
  1219. def simple_draw_arc( start_x, start_y, end_x, end_y,
  1220. color,start_angle,sweep_angle,width = 1)
  1221. draw_arc( start_x, start_y, end_x, end_y, 0, 0, 1, 1,
  1222. color, color,start_angle,sweep_angle,width)
  1223. end
  1224. #--------------------------------------------------------------------------
  1225. # ● 円弧描画
  1226. #--------------------------------------------------------------------------
  1227. def draw_arc( start_x, start_y, end_x, end_y,
  1228. gra_start_x, gra_start_y, gra_end_x , gra_end_y ,
  1229. start_color,end_color,start_angle,sweep_angle,width = 1)
  1230. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1231. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1232. start_color.red , start_color.alpha ].pack("iiCCCC")
  1233. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1234. end_color.red , end_color.alpha ].pack("iiCCCC")
  1235. w = Integer( width * 100.0 )
  1236. @@arc.call(self.object_id,self.width,self.height,start_x,start_y,
  1237. end_x,end_y, pstart, pend, start_angle, sweep_angle, w )
  1238. self
  1239. end
  1240. #--------------------------------------------------------------------------
  1241. # ● べジエ曲線描画
  1242. #--------------------------------------------------------------------------
  1243. def simple_draw_beziers( curve , count , color , width = 1 )
  1244. draw_beziers( curve , count , 0, 0, 1, 1, color ,color, width)
  1245. end
  1246. #--------------------------------------------------------------------------
  1247. # ● ベジエ曲線描画
  1248. #--------------------------------------------------------------------------
  1249. def draw_beziers( curve , count , gra_start_x , gra_start_y, gra_end_x ,
  1250. gra_end_y , start_color ,end_color, width = 1 )
  1251. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1252. unless curve.size > 7 and curve.size & 0x1 == 0 and
  1253. (curve.size >> 1) == count
  1254. raise(RGSSError,"Invalid bezier data.")
  1255. end
  1256. poly = curve.pack("s*")
  1257. pstart = [ gra_start_x , gra_start_y , start_color.blue , start_color.green ,
  1258. start_color.red , start_color.alpha ].pack("iiCCCC")
  1259. pend = [ gra_end_x , gra_end_y , end_color.blue , end_color.green ,
  1260. end_color.red , end_color.alpha ].pack("iiCCCC")
  1261. w = Integer( width * 100.0 )
  1262. @@bezier.call( self.object_id, self.width, self.height, poly, count,
  1263. pstart , pend , w )
  1264. self
  1265. end
  1266. #--------------------------------------------------------------------------
  1267. # ● テクスチャ円形
  1268. #--------------------------------------------------------------------------
  1269. def texture_ellipse( bitmap , start_x , start_y , end_x , end_y )
  1270. psrc = [self.object_id,self.width,self.height].pack("III")
  1271. pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
  1272. @@tellipse.call(psrc,pdest,start_x , start_y , end_x , end_y )
  1273. self
  1274. end
  1275. #--------------------------------------------------------------------------
  1276. # ● テクスチャポリゴン
  1277. #--------------------------------------------------------------------------
  1278. def texture_polygon( bitmap , polygon , count , mode)
  1279. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1280. unless polygon.size > 5 and polygon.size & 0x1 == 0 and
  1281. (polygon.size >> 1) == count
  1282. raise(RGSSError,"Invalid polygon data.")
  1283. end
  1284. poly = polygon.pack("s*")
  1285. psrc = [self.object_id,self.width,self.height].pack("III")
  1286. pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
  1287. @@tpolygon.call( psrc , pdest , poly , count , mode ? 1 : 0 )
  1288. self
  1289. end
  1290. #--------------------------------------------------------------------------
  1291. # ● テクスチャ閉カーブ
  1292. #--------------------------------------------------------------------------
  1293. def texture_closed_curve( bitmap , curve , count, mode , tension = 50)
  1294. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1295. unless curve.size > 5 and curve.size & 0x1 == 0 and
  1296. (curve.size >> 1) == count
  1297. raise(RGSSError,"Invalid curve data.")
  1298. end
  1299. poly = curve.pack("s*")
  1300. psrc = [self.object_id,self.width,self.height].pack("III")
  1301. pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
  1302. @@tclosedcurve.call( psrc , pdest , poly, count, mode ? 1 : 0 , tension)
  1303. self
  1304. end
  1305. #--------------------------------------------------------------------------
  1306. # ● テクスチャパイ
  1307. #--------------------------------------------------------------------------
  1308. def texture_pie(bitmap,start_x,start_y,end_x,end_y,start_angle,sweep_angle)
  1309. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1310. psrc = [self.object_id,self.width,self.height].pack("III")
  1311. pdest = [bitmap.object_id,bitmap.width,bitmap.height].pack("III")
  1312. @@tpie.call(psrc,pdest,start_x,start_y,end_x,end_y,start_angle,sweep_angle)
  1313. self
  1314. end
  1315. #--------------------------------------------------------------------------
  1316. # ● 文字描画
  1317. #--------------------------------------------------------------------------
  1318. def draw_gradient_text(*args)
  1319. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1320. x, y, width, height, text, align, mode = get_text_args_s(args)
  1321. w2 = text_size(text).width
  1322. ry = height - self.font.size
  1323. rect = [x, y + ry / 2, width , self.font.size ,
  1324. self.width , self.height, w2].pack("s*")
  1325. data = [Integer( self.font.frame_color.red ),
  1326. Integer( self.font.frame_color.green ),
  1327. Integer( self.font.frame_color.blue ),
  1328. Integer( self.font.frame_color.alpha ),self.font.size,
  1329. mode & 0x1,(self.font.italic ? 2 : 0) | (self.font.bold ? 1 : 0),
  1330. ((mode & 0x2) >> 1),align ].pack("C*")
  1331. start_color = self.font.gradient_start_color
  1332. end_color = self.font.gradient_end_color
  1333. pstart = [ x , y - 2, start_color.blue , start_color.green ,
  1334. start_color.red , start_color.alpha ].pack("iiCCCC")
  1335. pend = [ x , y + self.font.size + 2, end_color.blue , end_color.green ,
  1336. end_color.red , end_color.alpha ].pack("iiCCCC")
  1337.  
  1338. @@gfontdraw.call(text.dup,self.font.exist_font.dup,
  1339. self.object_id,rect,data, pstart, pend) == 1
  1340. end
  1341. #--------------------------------------------------------------------------
  1342. # ● 文字描画
  1343. #--------------------------------------------------------------------------
  1344. def draw_text_s(*args)
  1345. raise(RGSSError,"disposed bitmap.") if self.disposed?
  1346. x, y, width, height, text, align, mode = get_text_args_s(args)
  1347. w2 = text_size(text).width
  1348. ry = height - self.font.size
  1349. rect = [x, y + ry / 2, width , self.font.size ,
  1350. self.width , self.height, w2].pack("s*")
  1351. data = [Integer( self.font.color.red ),
  1352. Integer( self.font.color.green ),
  1353. Integer( self.font.color.blue ),
  1354. Integer( self.font.color.alpha ),self.font.size,
  1355. mode & 0x1,(self.font.italic ? 2 : 0) | (self.font.bold ? 1 : 0),
  1356. ((mode & 0x2) >> 1),align ].pack("C*")
  1357. @@fontdraw.call(text.dup,self.font.exist_font.dup,
  1358. self.object_id,rect,data) == 1
  1359. end
  1360. private
  1361. #--------------------------------------------------------------------------
  1362. # ◆(内部専用)◆ ビットマップデータ
  1363. #--------------------------------------------------------------------------
  1364. def make_bitmap_datas( rect , bitmap )
  1365. [bitmap.object_id , 0 , 0 , bitmap.width.to_i , bitmap.height.to_i ,
  1366. rect.x.to_i , rect.y.to_i , rect.width.to_i , rect.height.to_i].pack("L*")
  1367. end
  1368. #--------------------------------------------------------------------------
  1369. # ◆(内部専用)◆ 描画引数
  1370. #--------------------------------------------------------------------------
  1371. def get_text_args_s(args)
  1372. if args.at(0).is_a?(Rect)
  1373. if args.size.between?(2, 5)
  1374. rect = args.at(0)
  1375. x, y = rect.x, rect.y
  1376. width, height = rect.width, rect.height
  1377. text = args.at(1).to_s
  1378. align = (args.at(2).equal?(nil) ? 0 : args.at(2))
  1379. mode = (args.at(3).equal?(nil) ? 1 : args.at(3))
  1380. else
  1381. as = args.size < 2 ? 2 : 5
  1382. raise(ArgumentError,
  1383. "wrong number of arguments(#{args.size} of #{as})")
  1384. end
  1385. elsif args.size.between?(5, 8)
  1386. x, y, width, height = args
  1387. text = args.at(4).to_s
  1388. align = (args.at(5).equal?(nil) ? 0 : args.at(5))
  1389. mode = (args.at(6) ? args.at(6) : 1 )
  1390. else
  1391. as = args.size < 5 ? 5 : 8
  1392. raise(ArgumentError,
  1393. "wrong number of arguments(#{args.size} of #{as})")
  1394. end
  1395. return [x, y, width, height, text, align, mode]
  1396. end
  1397. #--------------------------------------------------------------------------
  1398. # ◆(内部専用)◆ カラーコンバート ( bgra の順になっていることに注意する)
  1399. #--------------------------------------------------------------------------
  1400. def color_convert(color)
  1401. str = [color.blue.to_i , color.green.to_i ,
  1402. color.red.to_i , color.alpha.to_i ].pack("C*")
  1403. str
  1404. end
  1405.  
  1406. def rad2d( rad )
  1407. (rad * Math::PI) / 180.0
  1408. end
  1409.  
  1410. unless method_defined?(:original_draw_text)
  1411. alias original_draw_text draw_text
  1412. if WFRGSS_BitmapEX::USE_DRAW_TEXT
  1413. alias draw_text draw_text_s
  1414. end
  1415. end
  1416. end
  1417.  
  1418. #==============================================================================
  1419. # GIFFile クラス
  1420. #------------------------------------------------------------------------------
  1421.  
  1422. class GIFFile
  1423. #--------------------------------------------------------------------------
  1424. # ● クラス変数
  1425. #--------------------------------------------------------------------------
  1426. begin
  1427. @@loader = Win32API.new('wfbitmap','gifLoader',%w(p i p p p p),'l').freeze
  1428. @@load = Win32API.new('wfbitmap','gifLoadImage',%w(l i),'l').freeze
  1429. @@count = Win32API.new('wfbitmap','gifImageCount','v','l').freeze
  1430. @@close = Win32API.new('wfbitmap','GifClose','v','v').freeze
  1431. rescue Exception
  1432. raise if debug?
  1433. raise(LoadError,"cannot read modules.(wfbitmap.dll)")
  1434. end
  1435. #--------------------------------------------------------------------------
  1436. # ● 定数
  1437. #--------------------------------------------------------------------------
  1438. RGSSA_FILE = "Game.rgss3a"#rpgvx? ? (rpgvxace? ? "Game.rgss3a" : "Game.rgss2a") :
  1439. # "Game.rgssad"
  1440. RGSSA_VERSION = 3#rpgvx? ? (rpgvxace? ? 3 : 2) : 1
  1441. #--------------------------------------------------------------------------
  1442. # ● 公開インスタンス変数
  1443. #--------------------------------------------------------------------------
  1444. attr_reader :bitmap
  1445. attr_reader :count
  1446. #--------------------------------------------------------------------------
  1447. # ● オブジェクト初期化
  1448. #--------------------------------------------------------------------------
  1449. def initialize( giffile )
  1450. w = "\x00" * 2
  1451. h = "\x00" * 2
  1452. @loaded = false
  1453. begin
  1454. infile = giffile.gsub(/\//){ "\\" }
  1455. i = @@loader.call(RGSSA_FILE,RGSSA_VERSION,
  1456. infile,String.utf82ansi(infile), w , h )
  1457. raise(Errno::ENOENT,infile) if i < 0
  1458. @loaded = true
  1459. @count = @@count.call()
  1460. width = w.unpack("S").first
  1461. height = h.unpack("S").first
  1462. @bitmap = Array.new( @count ){ Bitmap.new( width , height ) }
  1463. i = 0
  1464. for bitmap in @bitmap
  1465. @@load.call( bitmap.object_id , i )
  1466. i += 1
  1467. end
  1468. ensure
  1469. @@close.call() if @loaded
  1470. end
  1471. end
  1472. #--------------------------------------------------------------------------
  1473. # ● 解放
  1474. #--------------------------------------------------------------------------
  1475. def dispose
  1476. for bitmap in @bitmap
  1477. bitmap.dispose
  1478. end
  1479. end
  1480. end
  1481.  
  1482. #==============================================================================
  1483. # GifSprite クラス
  1484. #------------------------------------------------------------------------------
  1485.  
  1486. class GifSprite < Sprite
  1487. #--------------------------------------------------------------------------
  1488. # ● オブジェクト初期化
  1489. #--------------------------------------------------------------------------
  1490. def initialize( giffile , wait = 1 , viewport = nil)
  1491. super(viewport)
  1492. @gif = GIFFile.new( giffile )
  1493. @wait = wait
  1494. self.bitmap = @gif.bitmap.at(0)
  1495. @_count = 0
  1496. @_index = 0
  1497. end
  1498. #--------------------------------------------------------------------------
  1499. # ● 解放
  1500. #--------------------------------------------------------------------------
  1501. def dispose
  1502. @gif.dispose
  1503. super
  1504. end
  1505. #--------------------------------------------------------------------------
  1506. # ● フレーム更新
  1507. #--------------------------------------------------------------------------
  1508. def update
  1509. super
  1510. @_count += 1
  1511. if @_count >= @wait
  1512. @_index += 1
  1513. @_index %= @gif.count
  1514. self.bitmap = @gif.bitmap.at(@_index)
  1515. @_count = 0
  1516. end
  1517. end
  1518. end
Advertisement
Add Comment
Please, Sign In to add comment