Module: Asposeslidesjava::FillingShapes
- Defined in:
- lib/asposeslidesjava/Shapes/fillingshapes.rb
Instance Method Summary collapse
- #fill_shapes_with_pattern ⇒ Object
- #fill_shapes_with_picture ⇒ Object
- #fill_shapes_with_solid_color ⇒ Object
- #initialize ⇒ Object
Instance Method Details
#fill_shapes_with_pattern ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/asposeslidesjava/Shapes/fillingshapes.rb', line 14 def fill_shapes_with_pattern() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/' # Create an instance of Presentation class pres = Rjb::import('com.aspose.slides.Presentation').new # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 50, 150, 75, 150) # Set the fill type to Pattern shp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Pattern) # Set the pattern style shp.getFillFormat().getPatternFormat().setPatternStyle(Rjb::import('com.aspose.slides.PatternStyle').Trellis) # Set the pattern back and fore colors shp.getFillFormat().getPatternFormat().getBackColor().setColor(Rjb::import('java.awt.Color').LIGHT_GRAY) shp.getFillFormat().getPatternFormat().getForeColor().setColor(Rjb::import('java.awt.Color').YELLOW) # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "RectShpPatt.pptx", save_format.Pptx) puts "Filled shapes with Pattern, please check the output file." end |
#fill_shapes_with_picture ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/asposeslidesjava/Shapes/fillingshapes.rb', line 43 def fill_shapes_with_picture() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/' # Create an instance of Presentation class pres = Rjb::import('com.aspose.slides.Presentation').new # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 50, 150, 75, 150) # Set the fill type to Picture shp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Picture) # Set the picture fill mode shp.getFillFormat().getPictureFillFormat().setPictureFillMode(Rjb::import('com.aspose.slides.PictureFillMode').Tile) # Set the picture imgx = pres.getImages().addImage(Rjb::import('java.io.FileInputStream').new(Rjb::import('java.io.File').new(data_dir + "night.jpg"))) shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx) # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "RectShpPic.pptx", save_format.Pptx) puts "Filled shapes with Picture, please check the output file." end |
#fill_shapes_with_solid_color ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/asposeslidesjava/Shapes/fillingshapes.rb', line 73 def fill_shapes_with_solid_color() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/' # Create an instance of Presentation class pres = Rjb::import('com.aspose.slides.Presentation').new # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 50, 150, 75, 150) # Set the fill type to Solid shp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid) # Set the color of the rectangle shp.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').YELLOW) # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "RectShpSolid.pptx", save_format.Pptx) puts "Filled shapes with Solid Color, please check the output file." end |
#initialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/asposeslidesjava/Shapes/fillingshapes.rb', line 3 def initialize() # Filling Shapes with Pattern fill_shapes_with_pattern() # Filling Shapes with Picture fill_shapes_with_picture() # Filling Shapes with Solid Color fill_shapes_with_solid_color() end |