Class: Sketchup::Material
- Includes:
- Comparable
- Defined in:
- lib/sketchup-api-stubs/stubs/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
- OWNER_IMAGE =
Stub value.
nil
- OWNER_LAYER =
Stub value.
nil
- OWNER_MANAGER =
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.
-
#owner_type ⇒ Integer
The #owner_type method is used to determine if the material is owned by a Materials.
-
#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(path, 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.
57 58 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 57 def <=>(material2) end |
#==(material2) ⇒ Boolean
The == method is used to test if two materials are the same.
80 81 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 80 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.
95 96 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 95 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.
116 117 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 116 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.
133 134 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 133 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.
156 157 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 156 def color=(color) end |
#colorize_deltas ⇒ Array(Float, Float, Float)
The colorize_deltas method retrieves the HLS delta for colorized materials.
168 169 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 168 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),
186 187 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 186 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),
207 208 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 207 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.
229 230 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 229 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.
248 249 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 248 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.
270 271 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 270 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.
295 296 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 295 def name=(str) end |
#owner_type ⇒ Integer
The #owner_type method is used to determine if the material is owned by a Sketchup::Materials.
Returned value is one of:
-
Sketchup::Material::OWNER_MANAGER
-
Sketchup::Material::OWNER_IMAGE
-
Sketchup::Material::OWNER_LAYER
309 310 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 309 def owner_type 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.
330 331 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 330 def save_as(filename) end |
#texture ⇒ Sketchup::Texture?
The texture method retrieves the texture of the material.
346 347 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 346 def texture end |
#texture=(filename) ⇒ Object #texture=(properties) ⇒ Object #texture=(image_rep) ⇒ Object
The texture= method sets the texture for the material.
Setting the texture to nil
will turn it into a solid color
375 376 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 375 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.
390 391 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 390 def use_alpha? end |
#write_thumbnail(path, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.
411 412 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Material.rb', line 411 def write_thumbnail(path, resolution) end |