Class: Sketchup::Texture
Overview
The Texture class contains methods for obtaining information about textures that are part of your materials in your model (within the In-Model section of the Materials Browser). Remember, textures are repeatable images that “tile” when painted on a surface.
Instance Method Summary # collapse
- 
  
    
      #average_color  ⇒ Sketchup::Color? 
    
    
  
  
  
  
  
  
  
  
  
    
The average_color method retrieves a color object with the average color found in the texture.
 - 
  
    
      #filename  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
The #filename method retrieves the full path, if available, for a texture object.
 - 
  
    
      #height  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
The height method is used to get the height of a repeatable texture image, in inches.
 - 
  
    
      #image_height  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
The image_height method retrieves the height of the repeatable texture image, in pixels.
 - 
  
    
      #image_rep(colorized = false)  ⇒ Sketchup::ImageRep 
    
    
  
  
  
  
  
  
  
  
  
    
The #image_rep method returns a copy of a ImageRep object representing the texture pixel data.
 - 
  
    
      #image_width  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
The image_width method retrieves the width of the repeatable texture image, in pixels.
 - 
  
    
      #size=(size)  ⇒ Integer, Array(Integer, Integer) 
    
    
  
  
  
  
  
  
  
  
  
    
The size= method allows you to set the size of the repeatable texture image, in inches,.
 - 
  
    
      #valid?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
The valid? method ensures that a texture is valid.
 - 
  
    
      #width  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
The width method is used to get the width of a repeatable texture image, in inches.
 - 
  
    
      #write(path, colorize = false)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Writes the texture to file with option to preserve the color adjustments made by the material.
 
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
Instance Method Details
↑ #average_color ⇒ Sketchup::Color?
The average_color method retrieves a color object with the average color found in the texture.
↑ #filename ⇒ String
Since SketchUp 2021.0 this method will append a file extension matching the image format if the file extension is missing from stored filepath.
The #filename method retrieves the full path, if available, for a texture object.
Textures for materials shipping with SketchUp might only have a filename, since the path would be invalid on the end user's machine. Textures dynamically created from ImageRep objects may have an empty path unless saved with ImageRep#save_file or until the texture is saved with #write.
If you need only the filename of the texture use filename = File.basename(texture.filename).
↑ #height ⇒ Integer
The height method is used to get the height of a repeatable texture image, in inches.
↑ #image_height ⇒ Integer
The image_height method retrieves the height of the repeatable texture image, in pixels.
↑ #image_rep(colorized = false) ⇒ Sketchup::ImageRep
The #image_rep method returns a copy of a ImageRep object representing the texture pixel data.
↑ #image_width ⇒ Integer
The image_width method retrieves the width of the repeatable texture image, in pixels.
↑ #size=(size) ⇒ Integer, Array(Integer, Integer)
The size= method allows you to set the size of the repeatable texture image, in inches,
↑ #valid? ⇒ Boolean
The valid? method ensures that a texture is valid.
↑ #width ⇒ Integer
The width method is used to get the width of a repeatable texture image, in inches.
↑ #write(path, colorize = false) ⇒ Boolean
Writes the texture to file with option to preserve the color adjustments made by the material.