Sha256: 5b306e3ead85a15f8175154a3f54acc2b712464bc4141ceb1e072b868e5e48ac
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# encoding: utf-8 # frozen_string_literal: true # Creating Colors (Homage to Albers). # require 'propane' # Creating variables for colors that may be referred to # in the program by their name, rather than a number. class CreatingColors < Propane::App attr_reader :redder, :yellower, :orangish def setup size 640, 360 # palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'].to_java(:string)) palette = web_to_color_array(['#CC6600', '#CC9900', '#993300']) # @redder = color 204, 102, 0 # @yellower = color 204, 153, 0 # @orangish = color 153, 51, 0 # These statements are equivalent to the statements above. # Programmers may use the format they prefer. # hex color as a String (NB quotes are required) @redder = palette[0] @yellower = palette[1] @orangish = palette[2] # @redder = color '#CC6600' # @yellower = color '#CC9900' # @orangish = color '#993300' # or alternatively as a hexadecimal # @redder = color 0xFFCC6600 # @yellower = color 0xFFCC9900 # @orangish = color 0xFF993300 end def draw no_stroke background 51, 0, 0 push_matrix translate 80, 80 fill orangish rect 0, 0, 200, 200 fill yellower rect 40, 60, 120, 120 fill redder rect 60, 90, 80, 80 pop_matrix push_matrix translate 360, 80 fill redder rect 0, 0, 200, 200 fill orangish rect 40, 60, 120, 120 fill yellower rect 60, 90, 80, 80 pop_matrix end end CreatingColors.new title: 'Homage to Albers'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
propane-0.6.0-java | examples/regular/colors_two.rb |