Class: Sketchup::Material
- Includes:
- Comparable
- Defined in:
- SketchUp/Sketchup/Material.rb
Overview
The Material class represents a texture or color that can be applied to Drawingelements. It is most often applied to Faces.
You can pass any object that can be used as a material to a method that requires a material. Objects include actual materials, color, and classes that can be converted to a color.
The following are valid (assuming the existence of a Material mat1.)
Constant Summary collapse
- COLORIZE_SHIFT =
Constants
nil
- COLORIZE_TINT =
Stub value.
nil
- MATERIAL_COLORIZED_TEXTURED =
Stub value.
nil
- MATERIAL_SOLID =
Stub value.
nil
- MATERIAL_TEXTURED =
Stub value.
nil
Instance Method Summary collapse
-
#<=>(material2) ⇒ Integer
The <=> method is used to compare two materials based on name.
-
#==(material2) ⇒ Boolean
The == method is used to test if two materials are the same.
-
#alpha ⇒ Float
The alpha method is used to get the opacity of the material.
-
#alpha=(alpha) ⇒ Float
The alpha= method is used to set the opacity of the material.
-
#color ⇒ Sketchup::Color
The color method is used to retrieve the color of the material.
-
#color=(color) ⇒ Sketchup::Color, ...
The color= method is used to set the color of the material.
-
#colorize_deltas ⇒ Array(Float, Float, Float)
The colorize_deltas method retrieves the HLS delta for colorized materials.
-
#colorize_type ⇒ Integer
The colorize_type method retrieves the type of colorization of the material.
-
#colorize_type=(type) ⇒ Integer
The colorize_type method set the type of colorization of the material.
-
#display_name ⇒ String
The display_name method retrieves the name that is displayed within SketchUp for the material.
-
#materialType ⇒ Integer
The materialType method retrieves the type of the material.
-
#name ⇒ String
The name method retrieves the name of the material.
-
#name=(str) ⇒ String
The #name= method sets the name of the material.
-
#save_as(filename) ⇒ Boolean
The #save_as method is used to write a material to a SKM file.
-
#texture ⇒ Sketchup::Texture?
The texture method retrieves the texture of the material.
-
#texture=(arg) ⇒ Object
The texture= method sets the texture for the material.
-
#use_alpha? ⇒ Boolean
The use_alpha? method tells if the material uses transparency.
-
#write_thumbnail(filename, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.
Methods inherited from Entity
#add_observer, #attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #remove_observer, #set_attribute, #to_s, #typename, #valid?
Instance Method Details
#<=>(material2) ⇒ Integer
The <=> method is used to compare two materials based on name. The number returned relates to the “string distance” between the names.
53 54 |
# File 'SketchUp/Sketchup/Material.rb', line 53 def <=>(material2) end |
#==(material2) ⇒ Boolean
The == method is used to test if two materials are the same.
76 77 |
# File 'SketchUp/Sketchup/Material.rb', line 76 def ==(material2) end |
#alpha ⇒ Float
The alpha method is used to get the opacity of the material.
The value will be between 0.0 and 1.0. A value of 0.0 means that the material is completely transparent. A value of 1.0 means that the Material is completely opaque.
91 92 |
# File 'SketchUp/Sketchup/Material.rb', line 91 def alpha end |
#alpha=(alpha) ⇒ Float
The alpha= method is used to set the opacity of the material.
The value must be between 0.0 and 1.0. A value of 0.0 means that the material is completely transparent. A value of 1.0 means that the Material is completely opaque.
112 113 |
# File 'SketchUp/Sketchup/Material.rb', line 112 def alpha=(alpha) end |
#color ⇒ Sketchup::Color
The color method is used to retrieve the color of the material.
If it uses a Texture, this will return the average color.
129 130 |
# File 'SketchUp/Sketchup/Material.rb', line 129 def color end |
#color=(color) ⇒ Sketchup::Color, ...
The color= method is used to set the color of the material.
If the Material has a texture, then this turns it into a colorized texture.
To reset the color of a Material with a texture, set the color to nil.
152 153 |
# File 'SketchUp/Sketchup/Material.rb', line 152 def color=(color) end |
#colorize_deltas ⇒ Array(Float, Float, Float)
The colorize_deltas method retrieves the HLS delta for colorized materials.
164 165 |
# File 'SketchUp/Sketchup/Material.rb', line 164 def colorize_deltas end |
#colorize_type ⇒ Integer
The colorize_type method retrieves the type of colorization of the material. This value is only relevant when the materialType is set to 2 (colorized textured). Types include:
- 0 = shift (Sketchup::Material::COLORIZE_SHIFT),
- 1 = tint (Sketchup::Material::COLORIZE_TINT),
182 183 |
# File 'SketchUp/Sketchup/Material.rb', line 182 def colorize_type end |
#colorize_type=(type) ⇒ Integer
The colorize_type method set the type of colorization of the material. This value is only relevant when the materialType is set to 2 (colorized textured). Types include:
- 0 = shift (Sketchup::Material::COLORIZE_SHIFT),
- 1 = tint (Sketchup::Material::COLORIZE_TINT),
203 204 |
# File 'SketchUp/Sketchup/Material.rb', line 203 def colorize_type=(type) end |
#display_name ⇒ String
The display_name method retrieves the name that is displayed within SketchUp for the material.
This should be used when presenting the name in the UI, but the returned name cannot be used as a key in model.materials.
225 226 |
# File 'SketchUp/Sketchup/Material.rb', line 225 def display_name end |
#materialType ⇒ Integer
The materialType method retrieves the type of the material. Types include:
- 0 = solid (Sketchup::Material::MATERIAL_SOLID),
- 1 = textured (Sketchup::Material::MATERIAL_TEXTURED),
- 2 = colorized textured (Sketchup::Material::MATERIAL_COLORIZED_TEXTURED).
The constants where added in SketchUp 2015.
244 245 |
# File 'SketchUp/Sketchup/Material.rb', line 244 def materialType end |
#name ⇒ String
The name method retrieves the name of the material. This is the internal name of the object which should be used for retrieving the material from the model’s material list.
Use .display_name to display the name in the UI.
266 267 |
# File 'SketchUp/Sketchup/Material.rb', line 266 def name end |
#name=(str) ⇒ String
Since SketchUp 2018 this method will raise an ‘ArgumentError` if the name is not unique.
SketchUp 2018 would raise an error if you named material the name it already had.
The #name= method sets the name of the material.
291 292 |
# File 'SketchUp/Sketchup/Material.rb', line 291 def name=(str) end |
#save_as(filename) ⇒ Boolean
The #save_as method is used to write a material to a SKM file.
You must remember to append “.skm” to the filename as this will not be done automatically.
312 313 |
# File 'SketchUp/Sketchup/Material.rb', line 312 def save_as(filename) end |
#texture ⇒ Sketchup::Texture?
The texture method retrieves the texture of the material.
328 329 |
# File 'SketchUp/Sketchup/Material.rb', line 328 def texture end |
#texture=(filename) ⇒ String #texture=(properties) ⇒ Array(String, Integer, Integer) #texture=(image_rep) ⇒ Sketchup::ImageRep
The texture= method sets the texture for the material.
Setting the texture to nil
will turn it into a solid color
359 360 |
# File 'SketchUp/Sketchup/Material.rb', line 359 def texture=(arg) end |
#use_alpha? ⇒ Boolean
The use_alpha? method tells if the material uses transparency.
Note that this is not affected by the alpha value of the color object. Only the .alpha value and transparent texture will make this method return true.
376 377 |
# File 'SketchUp/Sketchup/Material.rb', line 376 def use_alpha? end |
#write_thumbnail(filename, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.
397 398 |
# File 'SketchUp/Sketchup/Material.rb', line 397 def write_thumbnail(filename, resolution) end |