Class: Fontisan::Ufo::Point
- Inherits:
-
Object
- Object
- Fontisan::Ufo::Point
- Defined in:
- lib/fontisan/ufo/point.rb
Overview
A single outline point. UFO's point element has:
- x, y (Float, font units)
- type (one of "move", "line", "offcurve", "curve", "qcurve")
- smooth (Bool, optional)
"offcurve" is the UFO 1/2 name; UFO 3 uses "qcurve". Both are accepted on read.
Instance Attribute Summary collapse
-
#smooth ⇒ Object
readonly
Returns the value of attribute smooth.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(x:, y:, type:, smooth: false) ⇒ Point
constructor
A new instance of Point.
- #off_curve? ⇒ Boolean
- #on_curve? ⇒ Boolean
-
#to_h ⇒ Hash
Suitable for
to_glifoutput.
Constructor Details
#initialize(x:, y:, type:, smooth: false) ⇒ Point
Returns a new instance of Point.
15 16 17 18 19 20 |
# File 'lib/fontisan/ufo/point.rb', line 15 def initialize(x:, y:, type:, smooth: false) @x = x @y = y @type = type.to_s @smooth = smooth end |
Instance Attribute Details
#smooth ⇒ Object (readonly)
Returns the value of attribute smooth.
13 14 15 |
# File 'lib/fontisan/ufo/point.rb', line 13 def smooth @smooth end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/fontisan/ufo/point.rb', line 13 def type @type end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
13 14 15 |
# File 'lib/fontisan/ufo/point.rb', line 13 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
13 14 15 |
# File 'lib/fontisan/ufo/point.rb', line 13 def y @y end |
Instance Method Details
#off_curve? ⇒ Boolean
26 27 28 |
# File 'lib/fontisan/ufo/point.rb', line 26 def off_curve? @type == "offcurve" || @type == "qcurve" end |
#on_curve? ⇒ Boolean
22 23 24 |
# File 'lib/fontisan/ufo/point.rb', line 22 def on_curve? @type == "line" || @type == "move" || @type == "curve" end |
#to_h ⇒ Hash
Returns suitable for to_glif output.
31 32 33 34 35 |
# File 'lib/fontisan/ufo/point.rb', line 31 def to_h h = { x: @x, y: @y, type: @type } h[:smooth] = true if @smooth h end |