3
4
5
6
7
8
9
10
11
12
13
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
42
|
# File 'lib/asposeimagingjava/drawing/drawingrectangle.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
create_options = Rjb::import('com.aspose.imaging.imageoptions.BmpOptions').new
create_options.setBitsPerPixel(32)
create_options.setSource(Rjb::import('com.aspose.imaging.sources.StreamSource').new(Rjb::import('java.io.ByteArrayInputStream').new(Array.new)))
image = Rjb::import('com.aspose.imaging.Image').create(create_options,100,100)
color = Rjb::import('com.aspose.imaging.Color')
pen = Rjb::import('com.aspose.imaging.Pen')
graphic = Rjb::import('com.aspose.imaging.Graphics').new(image)
graphic.clear(color.getYellow())
solid_brush = Rjb::import('com.aspose.imaging.brushes.SolidBrush')
rectangle = Rjb::import('com.aspose.imaging.Rectangle')
graphic.drawRectangle(pen.new(color.getRed()), rectangle.new(30, 10, 40, 80))
graphic.drawRectangle(pen.new(solid_brush.new(color.getBlue())), rectangle.new(10, 30, 80, 40))
image.save(data_dir + "DrawRectanleExample.bmp")
puts "Rectangle have been drawn in image successfully!"
end
|