Class: PDF::Writer::TagDisc

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/writer.rb

Overview

A callback function to support drawing of a disc bullet style.

Constant Summary collapse

DEFAULT_FOREGROUND =

The default disc bullet foreground.

Color::RGB::Black
DEFAULT_BACKGROUND =

The default disc bullet background.

Color::RGB::White

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.backgroundObject

The background color for <C:disc> bullets. Default is Color::RGB::White.

Set to nil to get the default color.


2681
2682
2683
# File 'lib/pdf/writer.rb', line 2681

def background
  @background
end

.foregroundObject

The foreground color for <C:disc> bullets. Default is Color::RGB::Black.

Set to nil to get the default color.


2676
2677
2678
# File 'lib/pdf/writer.rb', line 2676

def foreground
  @foreground
end

Class Method Details

.[](pdf, info) ⇒ Object


2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
# File 'lib/pdf/writer.rb', line 2682

def [](pdf, info)
  @foreground ||= DEFAULT_FOREGROUND
  @background ||= DEFAULT_BACKGROUND

  desc  = info[:descender].abs
  xpos  = info[:x] - (desc * 2.00)
  ypos  = info[:y] + (desc * 1.05)

  ss = StrokeStyle.new(desc)
  ss.cap  = :butt
  ss.join = :miter
  pdf.stroke_style! ss
  pdf.stroke_color @foreground
  pdf.circle_at(xpos, ypos, 1).stroke
  pdf.stroke_color @background
  pdf.circle_at(xpos, ypos, 0.5).stroke
end