Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Color Experiment
- # Version : 1.0
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (English Documentation)
- # =============================================================================
- =begin
- Just a simple script to experiment color
- =end
- # =============================================================================
- # Little configuration
- # =============================================================================
- module THEO
- module COLOR
- SAMPLE_WIDTH = Graphics.width
- # Width of the window
- # Graphics.width stand for width of the screen
- SAMPLE_TEXT = "Sample Text"
- # String for sample text
- EXPERIMENT = true
- # Set true if you want to experiment the color
- INITIAL_COLOR = [255, 255, 255]
- # Initial color in [red, green, blue]
- end
- end
- # =============================================================================
- # Rest of script
- # =============================================================================
- class Color_Experiment < Scene_Base
- def start
- super
- create_bg_sprite
- create_rgb_window
- create_window_samples
- create_help
- create_color_list
- end
- def create_bg_sprite
- @bg_sprite = Sprite.new
- @bg_sprite.bitmap = Cache.parallax("BlueSky")
- @bg_sprite.viewport = @viewport
- end
- def create_rgb_window
- @window_rgb = Window_RGBColor.new
- @window_rgb.viewport = @viewport
- end
- def create_window_samples
- @samples = []
- for i in 1..3
- x = Graphics.width/2 - THEO::COLOR::SAMPLE_WIDTH/2
- y = 48 * (i-1)
- sample = Window_SampleColor.new(x,y,i)
- sample.viewport = @viewport
- sample.refresh(@window_rgb.color)
- @samples.push(sample)
- end
- @window_rgb.sample_windows = @samples
- end
- def create_help
- @help_window = Window_ColorExHelp.new
- @help_window.viewport = @viewport
- end
- def create_color_list
- @color_list = []
- color = ["RED","GREEN","BLUE"]
- for i in 0..2
- x = (Graphics.width/3) * i
- colorlist = Window_ColorList.new(x,Graphics.height - 48*3,color[i],i)
- colorlist.viewport = @viewport
- @color_list.push(colorlist)
- end
- end
- end
- class Window_ColorList < Window_Base
- def initialize(x,y,text,id)
- super(x,y,Graphics.width/3,fitting_height(1))
- color_args = [0,0,0,255]
- color_args[id] = [255,255,255][id]
- change_color(Color.new(*color_args))
- draw_text(0,0,contents.width,line_height,text,1)
- end
- end
- class Window_RGBColor < Window_HorzCommand
- attr_writer :sample_windows
- def initialize
- @color = THEO::COLOR::INITIAL_COLOR.clone
- super(0,Graphics.height - 48*2)
- end
- def col_max
- return 3
- end
- def color_list
- @color
- end
- def color
- Color.new(*@color)
- end
- def window_width
- Graphics.width
- end
- def update
- super
- increase if Input.repeat?(:UP)
- decrease if Input.repeat?(:DOWN)
- ten_increase if Input.press?(:SHIFT) && Input.repeat?(:UP)
- ten_decrease if Input.press?(:SHIFT) && Input.repeat?(:DOWN)
- end
- def make_command_list
- add_command(@color[0],:red)
- add_command(@color[1],:green)
- add_command(@color[2],:blue)
- end
- def increase
- @color[index] += 1 unless max?
- refresh
- end
- def decrease
- @color[index] -= 1 unless min?
- refresh
- end
- def ten_increase
- @color[index] = [@color[index]+10,255].min
- refresh
- end
- def ten_decrease
- @color[index] = [@color[index]-10,0].max
- refresh
- end
- def max?
- @color[index] >= 255
- end
- def min?
- @color[index] <= 0
- end
- def refresh
- super
- @sample_windows.each {|window| window.refresh(color)} if @sample_windows
- end
- end
- class Window_SampleColor < Window_Base
- def initialize(x,y,type)
- super(x,y,THEO::COLOR::SAMPLE_WIDTH,fitting_height(1))
- @type = type
- case @type
- when 1
- self.opacity = 255
- when 2,3
- self.opacity = 0
- end
- end
- def refresh(color)
- contents.clear
- change_color(color)
- if @type == 2
- color2 = Color.new(0,0,0,128)
- color1 = Color.new(0,0,0,0)
- contents.gradient_fill_rect(0,0,contents.width/2,contents.height,
- color1, color2)
- contents.gradient_fill_rect(contents.width/2,0,contents.width/2,
- contents.height,color2, color1)
- end
- draw_text(0,0,contents.width,line_height,THEO::COLOR::SAMPLE_TEXT,1)
- end
- end
- class Window_ColorExHelp < Window_Base
- def initialize
- super(0,Graphics.height-48,Graphics.width,fitting_height(1))
- text = "Press up / down to change the value. Press shift for more"
- draw_text(0,0,contents.width,line_height,text,1)
- end
- end
- if THEO::COLOR::EXPERIMENT
- class << SceneManager
- def first_scene_class
- Color_Experiment
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment