Class: Sketchup::Material
Relationships | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Entity
|
|
Instance Chain:
self,
Comparable,
Entity
|
|
Inherits: |
Sketchup::Entity
|
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
-
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 Attribute Summary
-
#alpha ⇒ Float
rw
The alpha method is used to get the opacity of the material.
-
#alpha=(alpha) ⇒ Float
rw
The alpha= method is used to set the opacity of the material.
-
#color ⇒ Sketchup::Color
rw
The color method is used to retrieve the color of the material.
-
#color=(color) ⇒ Sketchup::Color, ...
rw
The color= method is used to set the color of the material.
-
#colorize_type ⇒ Integer
rw
The colorize_type method retrieves the type of colorization of the material.
-
#colorize_type=(type) ⇒ Integer
rw
The colorize_type method set the type of colorization of the material.
-
#name ⇒ String
rw
The name method retrieves the name of the material.
-
#name=(str) ⇒ String
rw
The #name= method sets the name of the material.
-
#texture ⇒ Sketchup::Texture?
rw
The texture method retrieves the texture of the material.
-
#texture=(filename)
rw
The texture= method sets the texture for the material.
-
#use_alpha? ⇒ Boolean
readonly
The use_alpha? method tells if the material uses transparency.
Entity
- Inherited
Instance Method Summary
-
#<=>(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.
-
#colorize_deltas ⇒ Array(Float, Float, Float)
The colorize_deltas method retrieves the HLS delta for colorized materials.
-
#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.
-
#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.
-
#write_thumbnail(path, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.
Entity
- Inherited
#add_observer | The add_observer method is used to add an observer to the current object. |
#attribute_dictionaries | The attribute_dictionaries method is used to retrieve the |
#attribute_dictionary | The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an |
#delete_attribute | The |
#entityID | The entityID method is used to retrieve a unique ID assigned to an entity. |
#get_attribute | The |
#inspect | The |
#model | The model method is used to retrieve the model for the entity. |
#parent | The parent method is used to retrieve the parent of the entity. |
#persistent_id | The |
#remove_observer | The remove_observer method is used to remove an observer from the current object. |
#set_attribute | The set attribute is used to set the value of an attribute in an attribute dictionary with the given name. |
#to_s | The |
#typename | The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”. |
Instance Attribute Details
#alpha ⇒ Float
(rw)
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
(rw)
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 (rw)
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, ... (rw)
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_type ⇒ Integer
(rw)
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
(rw)
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),
#name ⇒ String (rw)
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 (rw)
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.
#texture ⇒ Sketchup::Texture? (rw)
The texture method retrieves the texture of the material.
#texture=(filename) (rw)
#texture=(properties)
#texture=(image_rep)
The texture= method sets the texture for the material.
Setting the texture to nil
will turn it into a solid color
#use_alpha? ⇒ Boolean
(readonly)
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.
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.
#colorize_deltas ⇒ Array(Float
, Float
, Float
)
The colorize_deltas method retrieves the HLS delta for colorized materials.
#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.
#owner_type ⇒ Integer
The #owner_type
method is used to determine if the material is owned by a 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.
#write_thumbnail(path, resolution) ⇒ Boolean
The write_thumbnail method writes a bitmap thumbnail to the given file name.