Class: Sketchup::Material
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 #
- Sketchup::Material::MATERIAL_SOLID
- Sketchup::Material::MATERIAL_TEXTURED
- Sketchup::Material::MATERIAL_COLORIZED_TEXTURED
- Sketchup::Material::COLORIZE_SHIFT
- Sketchup::Material::COLORIZE_TINT
- Sketchup::Material::OWNER_MANAGER
- Sketchup::Material::OWNER_IMAGE
- Sketchup::Material::OWNER_LAYER
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.
↑ #==(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.
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.
↑ #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.
↑ #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.
↑ #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.
↑ #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. 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),
↑ #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),
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #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
↑ #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.
↑ #texture ⇒ Sketchup::Texture?
The texture method retrieves the texture of the material.
↑ #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
↑ #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.
↑ #write_thumbnail(path, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.