File: stroke_dasharray.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (41 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
1
2
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
require 'rmagick'

imgl = Magick::ImageList.new
imgl.new_image(500, 180, Magick::HatchFill.new('white', 'lightcyan2'))
gc = Magick::Draw.new

gc.stroke_width(5)
gc.fill('transparent')

gc.stroke_dasharray(30, 10, 10, 10)
gc.stroke('green')
gc.line(10, 20, 490, 20)

gc.stroke_dasharray(5, 10, 5)
gc.stroke_dashoffset(10)
gc.stroke('blue')
gc.line(10, 80, 490, 80)

gc.stroke_dasharray(10, 10)
gc.stroke_dashoffset(0)
gc.stroke('red')
gc.line(10, 140, 490, 140)

gc.fill('black')
gc.fill_opacity(1)
gc.stroke('transparent')
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)

gc.gravity(Magick::CenterGravity)
gc.text(0, -60, "'gc.stroke_dasharray(30, 10, 10, 10)'")
gc.text(0,   0, "'gc.stroke_dasharray(5, 10, 5)'")
gc.text(0,  12, "'gc.stroke_dashoffset(10)'")
gc.text(0,  60, "'gc.stroke_dasharray(10, 10)'")

gc.draw(imgl)

imgl.border!(1, 1, 'lightcyan2')
# imgl.display
imgl.write('stroke_dasharray.gif')
exit