Advertisement
QuasiXi

Quasi Core

Mar 7th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.49 KB | None | 0 0
  1. =begin
  2. #==============================================================================#
  3.                          ***Quasi Core v1.01***
  4.  
  5.   Common methods that Quasi scripts will use
  6.   -Small changes to default scripts
  7. #==============================================================================#
  8. #   Change Log
  9. #------------------------------------------------------------------------------
  10. 3/16/14 - Version 1.01
  11. -Added New Method
  12.  Quasi::circle(center x, center y, radius, angle)
  13.  # angle ranged from 0 to 2PI (PI = 180, 2PI = 360)
  14.  # Used to move a sprite around in a circle
  15.  # Returns an array [x, y]
  16.  
  17. -Sprite
  18.  # New methods:
  19.  #  quasi_flash(color,duration,repeat?)
  20.  #   -changes into new color then back to orginal
  21.  #  quasi_color(color,duration)
  22.  #   -changes color to new color within duration
  23.  
  24. -Updated Methods
  25.  Quasi::sprite_efx
  26.  # Added :color, :flash, :expand, :wave(Reworked)
  27.  # Renamed variables
  28.  
  29.  Quasi::sprite_efx_trans
  30.  # Added: :flash, :slide
  31.  # Renamed variables
  32.  
  33. 3/7/14 - Version 1.0
  34. -Released
  35.  
  36. #------------------------------------------------------------------------------
  37.  
  38. New methods in module
  39.  Quasi::odd?(value)
  40.  # returns if value is odd or even
  41.  
  42.  Quasi::slope(x1,y1,x2,y2,speed)
  43.  #  - Can be used for moving sprites around on a slope
  44.  # returns [slopeX, slopeY]
  45.   - Quasi::normalize (Special thanks to Resource Dragon)
  46.  #   Part of slope.  Normalizes the slope.
  47.    
  48.  Quasi::find_exp(x, nth)
  49.  # Def: y = x^(nth)   <=>  y = nth√x
  50.  # Returns y
  51.  
  52.  
  53. # Following can be called in Window_Base/Scene_Base without 'Quasi::' prefix
  54.  Quasi::sprite_efx_trans(sprite, settings)
  55.  # settings = :zoom, :zoom2, :spin, :fade
  56.  #     :zoom  - zooms the sprite at start, then zooms out to default zoom.
  57.  #     :zoom2 - is for images that are already zoomed and need to be zoomed out
  58.  Quasi::sprite_efx(sprite, settings)
  59.  # settings = :spin, :slidehorz, :slidevert, :slidedia, :wave, :color (incomplete)
  60.  Quasi::draw_qsprite(sprite, symbol, frames, index)
  61.  # symbol = :horz or :vert
  62.  # Splits sprite into X frames either horz or vert.
  63.  # Then moves location to the set index
  64.  
  65. #==============================================================================#
  66.                           Changes to Default Scripts:
  67. #==============================================================================#
  68. Game_Event
  69. ATTR
  70.   attr_reader  :event            # Can grab event name,x,y,id
  71.  
  72. Game_Interpreter
  73. NEW METHODS
  74.  New Variable method.
  75.  Makes variable into an array
  76.  And methods to grab the arrays values.
  77.  ** This aren't to be used as normal variables!
  78.      Only use them with the methods below!
  79.      Unless you know what you are doing.
  80.  
  81.   array(vari,ar,value)
  82.   # Converts $data_variables into an array.
  83.   # Ex
  84.   #  script call: array(1,0,100); array(1,1,50); array(1,2,'string')
  85.   #  would make variable 1 into an array with [100,50,'string']
  86.  
  87.   array_value(vari,ar)
  88.   # Grabs value for selected index.
  89.   # Using the array from first Ex.
  90.   #   script call: array_value(1,0)
  91.   #    returns 100
  92.   #   script call: array(1,2)
  93.   #    returns 'string'
  94.  
  95.   show_array(vari)
  96.   # Shows the whole array.
  97.   # Using the array from first Ex.
  98.   #  script call: show_array(1)
  99.   #   returns [100,50,'string']
  100.  
  101. Window_Base
  102. ALIAS
  103.   alias convert_escape_characters
  104.  
  105. NEW METHODS
  106.   convert_quasi_characters
  107.   # New codes for message box
  108.   #  \VA[variable,index]
  109.   #    - Displays the variable array in message
  110.   #    - Using the earlier Ex from converting a variable to an array
  111.   #       \VA[1,2] would be replaced with 'string'
  112.  
  113. Game_party
  114. NEW METHODS
  115.   lowest_level
  116.   # Returns the lowest lvl in party
  117.  
  118.   who_level(value)
  119.   # Returns the actor/s whose level is equal to the set value
  120.   #  - If multiple actors, it returns an array
  121.  
  122.   avg_level
  123.   # Grabs the average level of party
  124.  
  125.   # param =
  126.   # 0   => mhp
  127.   # 1   => mmp
  128.   # 2   => atk
  129.   # 3   => def
  130.   # 4   => mat
  131.   # 5   => mdf
  132.   # 6   => agi
  133.   # 7   => luk
  134.  
  135.   lowest_param(param)
  136.   # Returns lowest param value from party
  137.  
  138.   highest_param(param)
  139.   # Returns highest param value from party
  140.  
  141.   avg_param(param)
  142.   # Grabs the average value of param of party
  143.  
  144.   who_param(value,x)
  145.   # Returns the actor/s whose param is equal to the set value
  146.   #  - If multiple actors, it returns an array
  147.  
  148. class Game_CharacterBase
  149. NEW METHODS
  150.  fade_in(x)
  151.  # fades in character by x speed
  152.  fade_out(x)
  153.  # fades out character by x speed
  154.  fade?
  155.  # checks if character is fading in/out is complete.
  156. =end
  157.  
  158. $imported = {} if $imported.nil?
  159. $imported["Quasi_Core"] = 1.01
  160. $quasi = {} if $quasi.nil?
  161. module Quasi
  162.   # Set True/False to display Msg Popup Boxes
  163.   SHOW_MSG    = true
  164.  
  165.  
  166.   def self.version(req, script)
  167.     if req > $imported["Quasi_Core"]
  168.       @quasi_update = true
  169.       quasi_msg(script)
  170.     end
  171.   end
  172.  
  173.   def self.quasi_msg(script)
  174.     return unless SHOW_MSG
  175.     if !@quasi_update.nil?
  176.       txt = "[#{script}] Needs a newer version of [Quasi Engine]\n"
  177.       txt += "In order to run."
  178.       msgbox(sprintf(txt))
  179.       $quasi[script] = true
  180.     end
  181.   end
  182.  
  183.   # Just a simple math formula I like to use
  184.   # returns false if number input is even
  185.   # returns true if number input is odd
  186.   def self.odd?(value)
  187.     value += 2 if value == 0
  188.     odd = value % 2
  189.     return true if odd != 0
  190.     return false
  191.   end
  192.  
  193.   # Slope Formula
  194.   # returns in an array [x, y]
  195.   def self.slope(xf,xi,yf,yi,speed=2)
  196.     array = [xf-xi,yf-yi]
  197.     dir  = normalize(array[0],array[1])
  198.     slopex = dir[0] * speed
  199.     slopey = dir[1] * speed
  200.     return [slopex, slopey]
  201.   end
  202.  
  203.   def self.circle(cx, cy, rad, angle)
  204.     x = cx + Math.sin(angle)*rad
  205.     y = cy + Math.cos(angle)*rad
  206.     return [x, y]
  207.   end
  208.  
  209.   # Normalize a Slope
  210.   # returns in an array [x, y]
  211.   # ** Thanks to Resource Dragon **
  212.   def self.normalize(x,y)
  213.     distance = Math.sqrt(x * x + y * y).to_f
  214.     return [x / distance, y / distance]
  215.   end
  216.  
  217.   # Used as a replacement for NthRoot
  218.   # Ex: find y in 100 = y^5
  219.   # Def: y = 100^(1/5)
  220.   # Returns: y = 2.511886432
  221.   # Which is the same as:
  222.   #      y = 5√100
  223.   def self.find_exp(x,nth)
  224.     x = x.to_f
  225.     nth = nth.to_f
  226.     exp = x**(1/nth)
  227.     return exp
  228.   end
  229.  
  230.   # Openning transition effects
  231.    def self.sprite_efx_trans(sprite,settings)
  232.     return if settings.nil?
  233.     return if sprite.nil?
  234.     case settings[1]
  235.     when :zoom
  236.       if sprite.zoom_x > settings[2].to_f/100
  237.         sprite.zoom_x -= settings[3].to_f/100
  238.         sprite.zoom_y -= settings[3].to_f/100
  239.       else
  240.         @qtefx = false
  241.       end
  242.     when :zoom2
  243.       if sprite.zoom_x > 1.0
  244.         sprite.zoom_x -= settings[3].to_f/100
  245.         sprite.zoom_y -= settings[3].to_f/100
  246.       else
  247.         @qtefx = false
  248.       end
  249.     when :spin
  250.       if sprite.angle < settings[2]
  251.         sprite.angle += settings[3]
  252.       else
  253.         @qtefx = false
  254.       end
  255.     when :fade
  256.       if @qtefx
  257.         @qtefx = sprite.opacity < 255 ? true : false
  258.         sprite.opacity += settings[3]
  259.       end
  260.     when :flash
  261.       @qtefxd = {} if @qtefxd.nil?
  262.       @qtefxd[sprite] = 0 if @qtefxd[sprite].nil?
  263.       if settings[2] > @qtefxd[sprite]
  264.         if @qtefxfl.nil?
  265.           alpha = settings[3][3].nil? ? 255  : settings[3][3]
  266.           color = Color.new(settings[3][0],settings[3][1],settings[3][2],alpha)
  267.           sprite.flash(color,settings[2])
  268.           @qtefxfl = true
  269.         end
  270.         sprite.update
  271.         @qtefxd[sprite] += 1
  272.       else
  273.         @qtefx = false
  274.       end
  275.     when :slide
  276.       case settings[2]
  277.       when :horz
  278.         @qtefxx = settings[3][0].to_f/settings[3][1].to_f if @qtefxx.nil?
  279.         @qtefxnx = sprite.x if @qtefxnx.nil?
  280.         if !(settings[3][0]-1..settings[3][0]+1).include?(@qtefxnx)
  281.           @qtefxnx += settings[3][2] ? @qtefxx*-1 : @qtefxx
  282.           sprite.x = @qtefxnx
  283.         else
  284.           @qtefx = false
  285.           @qtefxx = nil
  286.           @qtefxnx = nil
  287.         end
  288.       when :vert
  289.         @qtefxy = settings[3][0].to_f/settings[3][1].to_f if @qtefxy.nil?
  290.         @qtefxny = sprite.y if @qtefxny.nil?
  291.         if !(settings[3][0]-1..settings[3][0]+1).include?(@qtefxny)
  292.           @qtefxny += settings[3][2] ? @qtefxy*-1 : @qtefxy
  293.           sprite.y = @qtefxny
  294.         else
  295.           @qtefx = false
  296.           @qtefxy = nil
  297.           @qtefxny = nil
  298.         end
  299.       end
  300.     else
  301.       # If no settings[1] was found it waits 60 frames
  302.       @qtefxw = 0 if @qtefxw.nil?
  303.       @qtefxw += 1 if @qtefxw < 60
  304.       @qtefx = false if @qtefxw >= 60
  305.     end
  306.   end
  307.  
  308.   def self.efx?
  309.     return @qtefx
  310.   end
  311.  
  312.   def self.efx=(efx)
  313.     @qtefx=efx
  314.   end
  315.  
  316.   # settings[efx, speed/dur, str1, str2]
  317.   def self.sprite_efx(sprite,settings)
  318.     return if settings.nil?
  319.     return if sprite.nil?
  320.     case settings[0]
  321.     when :spin
  322.       sprite.angle += settings[1][1].to_f / settings[1][0]
  323.     when :slidehorz
  324.       sprite.ox += settings[1][1].to_f / settings[1][0]
  325.     when :slidevert
  326.       sprite.oy += settings[1][1].to_f / settings[1][0]
  327.     when :slidedia
  328.       sprite.ox += settings[1][1].to_f / settings[1][0]
  329.       sprite.oy += settings[1][2].to_f / settings[1][0]
  330.     when :wave
  331.       @qefxw = {} if @qefxw.nil?
  332.       if @qefxw[sprite].nil?
  333.         sprite.wave_amp = settings[1][0]
  334.         sprite.wave_length = settings[1][1]
  335.         sprite.wave_speed = settings[1][2]
  336.         @qefxw[sprite] = true
  337.       end  
  338.       sprite.update
  339.     when :frame
  340.       @qefxfi = 0 if @qefxfi.nil?
  341.       @qefxfw = 0 if @qefxfw.nil?
  342.       if @qefxfw < settings[1][0]
  343.         @qefxfw += 1
  344.       else
  345.         @qefxfi += 1
  346.         @qefxfi = 0 if @qefxfi > (settings[1][2]-1)
  347.         @qefxfw = 0
  348.       end
  349.       draw_qsprite(sprite, settings[1][1], settings[1][2], @qefxfi)
  350.       sprite.opacity = 255 if sprite.opacity != 255
  351.     when :color
  352.       alpha = settings[1][1][3].nil? ? 255 : settings[1][1][3]
  353.       color = Color.new(settings[1][1][0],settings[1][1][1],settings[1][1][2],alpha)
  354.       sprite.quasi_flash(color,settings[1][0],settings[1][2])
  355.       sprite.update
  356.     when :flash
  357.       @qefxfld = {} if @qefxfld.nil?
  358.       @qefxfld[sprite] = 0 if @qefxfld[sprite].nil?
  359.       @qefxfl = {} if @qefxfl.nil?
  360.       if settings[1][0] > @qefxfld[sprite]
  361.         if !@qefxfl[sprite]
  362.           alpha = settings[1][4].nil? ? 255 : settings[1][4]
  363.           color = Color.new(settings[1][1],settings[1][2],settings[1][3],alpha) if !settings[1][1].nil?
  364.           color = nil if settings[1][1].nil?
  365.           sprite.flash(color,settings[1][0])
  366.           @qefxfl[sprite] = true
  367.         end
  368.         sprite.update
  369.         @qefxfld[sprite] += 1
  370.       else
  371.         @qefxfl[sprite] = nil
  372.         @qefxfld[sprite] = 0
  373.       end
  374.     when :expand
  375.       zx = settings[1][1]
  376.       zy = settings[1][2]
  377.      
  378.       spx = (settings[1][1]/settings[1][0])
  379.       spy = (settings[1][2]/settings[1][0])
  380.      
  381.       spx = zx < 1.0 ? spx * -1 : spx
  382.       spy = zy < 1.0 ? spy * -1 : spy
  383.      
  384.       if !@qefxzi
  385.         sprite.zoom_x += spx if sprite.zoom_x.round(2) != zx
  386.         sprite.zoom_y += spy if sprite.zoom_y.round(2) != zy
  387.         @qefxzi = true if sprite.zoom_x.round(2) == zx and sprite.zoom_y.round(2) == zy
  388.       else
  389.         sprite.zoom_x -= spx if sprite.zoom_x.round(2) != 1.0
  390.         sprite.zoom_y -= spy if sprite.zoom_y.round(2) != 1.0
  391.         @qefxzi = false if sprite.zoom_x.round(2) == 1.0 and sprite.zoom_y.round(2) == 1.0
  392.       end
  393.     end
  394.   end
  395.  
  396.   # Splits a sprite into frames
  397.   # * For animted sprite purposes
  398.   def self.draw_qsprite(sprite, symbol, frames, index)
  399.     return if sprite.nil?
  400.     return if sprite.bitmap.nil?
  401.     w = sprite.bitmap.width
  402.     h = sprite.bitmap.height
  403.     x = 0
  404.     y = 0
  405.     case symbol
  406.     when :vert
  407.       h = sprite.bitmap.height / frames
  408.       y = h * index
  409.     when :horz
  410.       w = sprite.bitmap.width / frames
  411.       x = w * index
  412.     end
  413.      sprite.src_rect.set(x,y,w,h)
  414.   end
  415. end
  416.  
  417. #==============================================================================
  418. # Some new methods for existing class
  419. #==============================================================================
  420.  
  421. #==============================================================================
  422. # ** Game_Event
  423. #------------------------------------------------------------------------------
  424. #  This class handles events. Functions include event page switching via
  425. # condition determinants and running parallel process events. Used within the
  426. # Game_Map class.
  427. #==============================================================================
  428.  
  429. class Game_Event < Game_Character
  430.     attr_reader   :event                # Grab Event
  431. end
  432.  
  433.  
  434. #==============================================================================
  435. # ** Game_Interpreter
  436. #------------------------------------------------------------------------------
  437. #  An interpreter for executing event commands. This class is used within the
  438. # Game_Map, Game_Troop, and Game_Event classes.
  439. #==============================================================================
  440.  
  441. class Game_Interpreter
  442.   #--------------------------------------------------------------------------
  443.   # * New Method
  444.   #    Makes Variables into an Array.
  445.   #--------------------------------------------------------------------------
  446.   def array(variable_id, array_index, value)
  447.     begin
  448.       $game_variables[variable_id] = Array.new if !$game_variables[variable_id].is_a?(Array)
  449.       $game_variables[variable_id][array_index] = value
  450.     rescue
  451.       $game_variables[variable_id][array_index] = "?Error?"
  452.     end
  453.   end
  454.  
  455.   #--------------------------------------------------------------------------
  456.   # * New Method
  457.   #    Grab the value from the Variable Array
  458.   #--------------------------------------------------------------------------
  459.   def array_value(variable_id, array_index)
  460.     return unless $game_variables[variable_id].is_a?(Array)
  461.     return $game_variables[variable_id][array_index]
  462.   end
  463.  
  464.   #--------------------------------------------------------------------------
  465.   # * New Method
  466.   #    Show all Values from Array
  467.   #--------------------------------------------------------------------------
  468.   def show_array(variable_id)
  469.     return unless $game_variables[variable_id].is_a?(Array)
  470.     return $game_variables[variable_id]
  471.   end
  472. end
  473.  
  474. #==============================================================================
  475. # ** Window_Base
  476. #------------------------------------------------------------------------------
  477. #  This is a super class of all windows within the game.
  478. #==============================================================================
  479.  
  480. class Window_Base < Window
  481.   alias quasi_escape_characters convert_escape_characters
  482.   #--------------------------------------------------------------------------
  483.   # * Preconvert Control Characters
  484.   #    As a rule, replace only what will be changed into text strings before
  485.   #    starting actual drawing. The character "\" is replaced with the escape
  486.   #    character (\e).
  487.   #--------------------------------------------------------------------------
  488.   def convert_escape_characters(text)
  489.     convert_quasi_characters(quasi_escape_characters(text))
  490.   end
  491.  
  492.   #--------------------------------------------------------------------------
  493.   # * New Control Character
  494.   #    Displays an Array with \VA[x,y]
  495.   #--------------------------------------------------------------------------
  496.   def convert_quasi_characters(text)
  497.     text.gsub!(/\eVA\[(\d+),(\d+)\]/i) { $game_variables[$1.to_i][$2.to_i]}
  498.     return text
  499.   end
  500.  
  501.   def sprite_efx_trans(sprite,settings)
  502.     Quasi.sprite_efx_trans(sprite, settings)
  503.     @qtefx = Quasi.efx?
  504.   end
  505.  
  506.   def sprite_efx(sprite,settings)
  507.     Quasi.sprite_efx(sprite, settings)
  508.   end
  509.  
  510.   def draw_qsprite(sprite, symbol, frames, index)
  511.     Quasi.draw_qsprite(sprite, symbol, frames, index)
  512.   end
  513. end
  514.  
  515. #==============================================================================
  516. # ** Scene_Base
  517. #------------------------------------------------------------------------------
  518. #  This is a super class of all scenes within the game.
  519. #==============================================================================
  520.  
  521. class Scene_Base
  522.   def sprite_efx_trans(sprite,settings)
  523.     Quasi.sprite_efx_trans(sprite, settings)
  524.     @qtefx = Quasi.efx?
  525.   end
  526.  
  527.   # settings[efx, speed, str1, str2]
  528.   def sprite_efx(sprite,settings)
  529.     Quasi.sprite_efx(sprite, settings)
  530.   end
  531.  
  532.   def draw_qsprite(sprite, symbol, frames, index)
  533.     Quasi.draw_qsprite(sprite, symbol, frames, index)
  534.   end
  535. end
  536.  
  537. #==============================================================================
  538. # ** Game_Party
  539. #------------------------------------------------------------------------------
  540. #  This class handles parties. Information such as gold and items is included.
  541. # Instances of this class are referenced by $game_party.
  542. #==============================================================================
  543.  
  544. class Game_Party < Game_Unit
  545.   #--------------------------------------------------------------------------
  546.   # * Get Lowest Level of Party Members
  547.   #--------------------------------------------------------------------------
  548.   def lowest_level
  549.     lv = members.collect {|actor| actor.level }.min
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # * Get Who the Level belongs too
  553.   # ** If multiple have the same level, it returns an array with both
  554.   #--------------------------------------------------------------------------
  555.   def who_level(value)
  556.     who = []
  557.     members.each do |mem|
  558.       next unless mem.level == value
  559.       who.push(mem.name)
  560.     end
  561.     return if who.empty?
  562.     return who[0] if who.size == 1
  563.     return who
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # * Get Average Level of Party Members
  567.   #--------------------------------------------------------------------------
  568.   def avg_level
  569.     avg = 0
  570.     members.each {|actor| avg += actor.level}
  571.     avg /= members.size
  572.     return avg
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # * Get Lowest Value of param of Party Members
  576.   #--------------------------------------------------------------------------
  577.   def lowest_param(x)
  578.     param = members.collect {|actor| actor.param(x) }.min
  579.   end
  580.   #--------------------------------------------------------------------------
  581.   # * Get Highest Value of param of Party Members
  582.   #--------------------------------------------------------------------------
  583.   def highest_param(x)
  584.     param = members.collect {|actor| actor.param(x) }.max
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # * Get Average Value of param of Party Members
  588.   #--------------------------------------------------------------------------
  589.   def avg_param(x)
  590.     avg = 0
  591.     members.each {|actor| avg += actor.param(x)}
  592.     avg /= members.size
  593.     return avg
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # * Get Who the param belongs too
  597.   #--------------------------------------------------------------------------
  598.   def who_param(value, x)
  599.     who = []
  600.     members.each do |mem|
  601.       next unless mem.param(x) == value
  602.       who.push(mem.name)
  603.     end
  604.     return if who.empty?
  605.     return who[0] if who.size == 1
  606.     return who
  607.   end
  608. end
  609.  
  610.  
  611. #==============================================================================
  612. # ** Game_CharacterBase
  613. #------------------------------------------------------------------------------
  614. #  This base class handles characters. It retains basic information, such as
  615. # coordinates and graphics, shared by all characters.
  616. #==============================================================================
  617.  
  618. class Game_CharacterBase
  619.   #--------------------------------------------------------------------------
  620.   # * Public Instance Variables
  621.   #--------------------------------------------------------------------------
  622.   attr_accessor   :opacity                  # opacity level
  623.  
  624.   def fade_in(x)
  625.     if @opacity < 255
  626.       @opacity += x
  627.       @fade = false
  628.     else
  629.       @fade = true
  630.     end
  631.   end
  632.  
  633.   def fade_out(x)
  634.     if @opacity > 0
  635.       @opacity -= x
  636.       @fade = false
  637.     else
  638.       @fade = true
  639.     end
  640.   end
  641.  
  642.   def fade?
  643.     return @fade
  644.   end
  645. end
  646.  
  647. class Sprite
  648.   def quasi_flash(nc,duration,repeat=false)
  649.     return if @qrep == false
  650.     @old = self.color.clone if @old.nil?
  651.    
  652.     if @qcolor.nil?
  653.       a = self.color.alpha
  654.       a += nc.alpha/duration.to_f if a != nc.alpha
  655.       self.color = Color.new(nc.red,nc.green,nc.blue,a)
  656.       @qcolor = true if self.color == nc
  657.     else
  658.       a = self.color.alpha
  659.       a -= nc.alpha/duration.to_f if a != @old.alpha
  660.       self.color = Color.new(nc.red,nc.green,nc.blue,a)
  661.       @qrep = repeat if self.color.alpha == @old.alpha
  662.       @qcolor = nil if self.color.alpha == @old.alpha and @qrep
  663.     end
  664.   end
  665.  
  666.   def quasi_color(nc,duration)
  667.     @old = self.color.clone if @old.nil?
  668.     if @qcolor.nil?
  669.       nc = nc.nil? ? Color.new(0,0,0,0) : nc
  670.       r = self.color.red
  671.       g = self.color.green
  672.       b = self.color.blue
  673.       a = nc.alpha
  674.      
  675.       rn = (nc.red - @old.red)/duration.to_f
  676.       gn = (nc.green - @old.green)/duration.to_f
  677.       bn = (nc.blue - @old.blue)/duration.to_f
  678.      
  679.       r += rn if r != nc.red
  680.       g += gn if g != nc.green
  681.       b += bn if b != nc.blue
  682.      
  683.       self.color = Color.new(r,g,b,a)
  684.       @qcolor = true if self.color == nc
  685.     end
  686.   end
  687. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement