Class: Sketchup::Color
- Inherits:
-
Object
- Object
- Sketchup::Color
- Defined in:
- lib/sketchup-api-stubs/stubs/Sketchup/Color.rb
Overview
The Color class is used to create and manipulate colors within SketchUp Models. The class can also be used the same way with LayOut documents.
For methods that accept a Color object, such as the face.material method, you can pass in an actual Color object, or an object that can be converted to a Color. For example:
SketchUp ships with several built in colors in the Materials Browser. These colors are listed in the following table.
Class Method Summary collapse
-
.names ⇒ Array
The Color.names method is used to retrieve an array of all color names recognized by SketchUp.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#alpha ⇒ Integer
The #alpha method is used to retrieve the opacity of the color.
-
#alpha=(alpha) ⇒ Integer, Float
The #alpha= method is used to set the opacity of the color.
-
#blend(color2, weight) ⇒ Sketchup::Color
The #blend method is used to blend two colors.
-
#blue ⇒ Integer
The #blue method is used to retrieve the blue value of a color.
-
#blue=(blue) ⇒ Integer, Float
The #blue= method is used to set the blue value of a color.
-
#green ⇒ Integer
The #green method is used to retrieve the green value of a color.
-
#green=(green) ⇒ Integer, Float
The #green= method is used to set the green component of a RGB Color.
-
#initialize(*args) ⇒ Color
constructor
The new method is used to create a new Color object.
-
#red ⇒ Integer
The #red method is used to retrieve the red component of a RGB Color.
-
#red=(red) ⇒ Integer, Float
The #red= method is used to set the red component of a RGB Color.
-
#to_a ⇒ Array
The #to_a method is used to convert a Color object to an Array object.
-
#to_i ⇒ Integer
The #to_i method is used to convert a Color object to an 32 bit integer.
- #to_s ⇒ String
Constructor Details
#initialize(red, green, blue, alpha = 255) ⇒ Sketchup::Color #initialize(red, green, blue, alpha = 1.0) ⇒ Sketchup::Color #initialize(name) ⇒ Sketchup::Color #initialize(hex) ⇒ Sketchup::Color
The new method is used to create a new Color object.
222 223 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 222 def initialize(*args) end |
Class Method Details
Instance Method Details
#==(other) ⇒ Boolean
The #== method checks to see if the two Sketchup::Colors are equal. This checks whether the RGBA values are the same. In versions prior to SketchUp 2018 two color objects with the same values would be considered different.
58 59 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 58 def ==(other) end |
#alpha ⇒ Integer
The #alpha method is used to retrieve the opacity of the color. A value of 0 is transparent, 255 is opaque.
71 72 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 71 def alpha end |
#alpha=(alpha) ⇒ Integer, Float
The #alpha= method is used to set the opacity of the color. A value of 0 is transparent, 255 is opaque.
87 88 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 87 def alpha=(alpha) end |
#blend(color2, weight) ⇒ Sketchup::Color
The #blend method is used to blend two colors.
The blended color will be the result of taking (1 - weight) * color1 + weight * color2. If weight = 0, you will get color2. If weight = 1 you will get color1.
111 112 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 111 def blend(color2, weight) end |
#blue ⇒ Integer
The #blue method is used to retrieve the blue value of a color.
Value range is 0 to 255.
125 126 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 125 def blue end |
#blue=(blue) ⇒ Integer, Float
The #blue= method is used to set the blue value of a color.
Value range is 0 to 255.
142 143 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 142 def blue=(blue) end |
#green ⇒ Integer
The #green method is used to retrieve the green value of a color.
Value range is 0 to 255.
156 157 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 156 def green end |
#green=(green) ⇒ Integer, Float
The #green= method is used to set the green component of a RGB Color.
Value range is 0 to 255.
173 174 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 173 def green=(green) end |
#red ⇒ Integer
The #red method is used to retrieve the red component of a RGB Color.
Value range is 0 to 255.
236 237 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 236 def red end |
#red=(red) ⇒ Integer, Float
The #red= method is used to set the red component of a RGB Color.
Value range is 0 to 255.
253 254 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 253 def red=(red) end |
#to_a ⇒ Array
The #to_a method is used to convert a Color object to an Array object. The returned array will contain 4 integer values (RGBA) between 0 and 255.
266 267 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 266 def to_a end |
#to_i ⇒ Integer
The #to_i method is used to convert a Color object to an 32 bit integer.
278 279 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 278 def to_i end |
#to_s ⇒ String
The #to_s method returns a string representation of the Sketchup::Color object, in the form of “Color(255, 255, 255, 255)”.
291 292 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Color.rb', line 291 def to_s end |