Class: Ucode::Glyphs::LastResort::Glif::Outline

Inherits:
Struct
  • Object
show all
Defined in:
lib/ucode/glyphs/last_resort/glif.rb

Overview

Parsed outline value object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#advanceObject

Returns the value of attribute advance

Returns:

  • (Object)

    the current value of advance



44
45
46
# File 'lib/ucode/glyphs/last_resort/glif.rb', line 44

def advance
  @advance
end

#contoursObject

Returns the value of attribute contours

Returns:

  • (Object)

    the current value of contours



44
45
46
# File 'lib/ucode/glyphs/last_resort/glif.rb', line 44

def contours
  @contours
end

Instance Method Details

#bboxObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ucode/glyphs/last_resort/glif.rb', line 45

def bbox
  return nil if contours.empty?

  xs = []
  ys = []
  contours.each do |contour|
    contour.points.each do |point|
      xs << point.x
      ys << point.y
    end
  end
  return nil if xs.empty?

  { min_x: xs.min, min_y: ys.min, max_x: xs.max, max_y: ys.max }
end