Class: PFA::RelativePFA::Node

Inherits:
Object
  • Object
show all
Includes:
MagickPFA, PFAElementModule
Defined in:
lib/pfa/relative_pfa_node.rb

Constant Summary

Constants included from MagickPFA

MagickPFA::ABS_BORDERS, MagickPFA::ABS_FONTWEIGHTS, MagickPFA::BORDERS, MagickPFA::CODE_BOITE_ACTE, MagickPFA::CODE_HORLOGE, MagickPFA::CODE_IMAGEMAGICK_NOEUD, MagickPFA::CODE_IMAGEMAGICK_SEQUENCE, MagickPFA::CODE_OFFSET, MagickPFA::CODE_PART_NAME, MagickPFA::CODE_TITRE_PARADIGME, MagickPFA::COLORS, MagickPFA::CONVERT_CMD, MagickPFA::DARKERS, MagickPFA::DIMS_CONSTANTS_PER_THING, MagickPFA::FONTHEIGHT_MAIN_TITLE, MagickPFA::FONTWEIGHTS, MagickPFA::GRAVITIES, MagickPFA::RECTIFS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MagickPFA

#act_box_code, #act_name_code, code_for_intro, define_dims_constants, #horloge_code, #horloge_fin, #image_magick_code, rem_const_if_exists, #titre_pfa

Methods included from PFAElementModule

#drawnable?, #part?, #printable?

Constructor Details

#initialize(pfa, key, value = nil) ⇒ Node

Returns a new instance of Node.



13
14
15
16
17
# File 'lib/pfa/relative_pfa_node.rb', line 13

def initialize(pfa, key, value = nil)
  @pfa        = pfa
  @key        = key
  parse_raw_value(value)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/pfa/relative_pfa_node.rb', line 11

def key
  @key
end

#pfaObject (readonly)

Returns the value of attribute pfa.



11
12
13
# File 'lib/pfa/relative_pfa_node.rb', line 11

def pfa
  @pfa
end

Instance Method Details

#abs_bottomObject



112
113
114
# File 'lib/pfa/relative_pfa_node.rb', line 112

def abs_bottom
  @abs_bottom ||= MagickPFA::ABS_BOTTOMS[type]
end

#abs_dataObject

Hash Données absolues du nœud



177
178
179
# File 'lib/pfa/relative_pfa_node.rb', line 177

def abs_data
  @abs_data ||= AbsolutePFA.data[:nodes][key]
end

#abs_demiwidthObject



200
# File 'lib/pfa/relative_pfa_node.rb', line 200

def abs_demiwidth   ; @absdemiwidth ||= abs_width  / 2            end

#abs_durationObject



81
82
83
# File 'lib/pfa/relative_pfa_node.rb', line 81

def abs_duration
  @abs_duration ||= calc_with_fraction_of_duree(abs_data[:abs_duration])
end

#abs_endObject



77
78
79
# File 'lib/pfa/relative_pfa_node.rb', line 77

def abs_end
  @abs_end ||= abs_start + abs_duration
end

#abs_hcenterObject



202
# File 'lib/pfa/relative_pfa_node.rb', line 202

def abs_hcenter     ; @abshcenter   ||= abs_left + abs_demiwidth  end

#abs_heightObject



116
117
118
# File 'lib/pfa/relative_pfa_node.rb', line 116

def abs_height
  @abs_height ||= MagickPFA::HEIGHTS[type]
end

#abs_leftObject

– Dimensions Absolues –



89
90
91
# File 'lib/pfa/relative_pfa_node.rb', line 89

def abs_left
  @abs_left ||= abs_start.to_px(pfa)#.tap { |n| dbg "abs_left: #{n}".bleu}
end

#abs_rightObject



97
98
99
100
101
102
103
104
105
106
# File 'lib/pfa/relative_pfa_node.rb', line 97

def abs_right
  @abs_right ||= begin
    if id == 'DE' # denouement
      # Pour que le trait du dénouement soit dans l'image
      abs_left + abs_width - 2
    else
      abs_left + abs_width
    end
  end
end

#abs_startObject

PFA::NTime

Temps absolu (idéal) de départ



73
74
75
# File 'lib/pfa/relative_pfa_node.rb', line 73

def abs_start
  @abs_start ||= calc_with_fraction_of_duree(abs_data[:abs_start])
end

#abs_topObject



108
109
110
# File 'lib/pfa/relative_pfa_node.rb', line 108

def abs_top
  @abs_top ||= MagickPFA::ABS_TOPS[type]
end

#abs_widthObject



93
94
95
# File 'lib/pfa/relative_pfa_node.rb', line 93

def abs_width
  @abs_width ||= abs_duration.to_px(pfa)
end

#after?(node) ⇒ Bool

le nœud [RelativePFA::Node] node

Returns:

  • (Bool)

    true si le nœud courant est après



168
169
170
171
# File 'lib/pfa/relative_pfa_node.rb', line 168

def after?(node)
  # dbg "node = #{node.inspect}".orange
  return start_at > node.start_at
end

#bottomObject



149
150
151
# File 'lib/pfa/relative_pfa_node.rb', line 149

def bottom
  @bottom ||= MagickPFA::BOTTOMS[type]
end

#box_bottomObject

Le bas ultime du paradigme ?



205
# File 'lib/pfa/relative_pfa_node.rb', line 205

def box_bottom      ; @box_bottom   ||= top + 13 * MagickPFA::LINE_HEIGHT end

#code_image_magickObject



19
20
21
# File 'lib/pfa/relative_pfa_node.rb', line 19

def code_image_magick
  pfa.img_builder.code_image_magick
end

#demiheightObject

– Des valeurs qui peuvent servir… –



198
# File 'lib/pfa/relative_pfa_node.rb', line 198

def demiheight      ; @demiheight   ||= height / 2                end

#demiwidthObject



199
# File 'lib/pfa/relative_pfa_node.rb', line 199

def demiwidth       ; @demiwidth    ||= width  / 2                end

#description(ensure_output = false) ⇒ Object



23
24
25
26
27
# File 'lib/pfa/relative_pfa_node.rb', line 23

def description(ensure_output = false)
  @description || begin
    ensure_output ? "" : nil
  end
end

#durationObject

PFA::NTime Durée Soit elle a été explicitement définie en renseignant le noeud, soit on lui donne la valeur de la durée absolue. Sauf pour les actes, qui possèdent leur propre calcul, étant donné qu’ils dépendent d’autres éléments



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pfa/relative_pfa_node.rb', line 49

def duration
  @duration ||= begin
    if type == :part
      case key
      when :exposition          then @end_at = pfa.developpement_part1.start_at
      when :developpement_part1 then @end_at = pfa.developpement_part2.start_at
      when :developpement_part2 then @end_at = pfa.denouement.start_at
      when :denouement          then @end_at = PFA::NTime.new(pfa.duration.to_i)
      end
      end_at - start_at 
    else
      abs_duration
    end
  end
end

#end_atObject

PFA::NTime

Temps (relatif) de fin du noeud



40
41
42
# File 'lib/pfa/relative_pfa_node.rb', line 40

def end_at
  @end_at ||= start_at + duration # attention : 2 NTime
end

#hcenterObject



201
# File 'lib/pfa/relative_pfa_node.rb', line 201

def hcenter         ; @hcenter      ||= left  + demiwidth         end

#heightObject

Hauteur de la boite pour écrire le texte



154
155
156
# File 'lib/pfa/relative_pfa_node.rb', line 154

def height
  @height ||= (MagickPFA::HEIGHTS[type]).to_i
end

#horlogeObject

String

Horloge du temps (relatif) de départ



66
67
68
# File 'lib/pfa/relative_pfa_node.rb', line 66

def horloge
  @horloge ||= start_at.to_horloge
end

#idObject



189
190
191
# File 'lib/pfa/relative_pfa_node.rb', line 189

def id
  abs_data[:id]
end

#img_abs_surfaceObject



120
121
122
# File 'lib/pfa/relative_pfa_node.rb', line 120

def img_abs_surface
  @img_abs_surface ||= "#{abs_width}x#{abs_height}"
end

#img_surfaceObject



158
159
160
# File 'lib/pfa/relative_pfa_node.rb', line 158

def img_surface
  @img_surface ||= "#{width}x#{height}"
end

#leftObject

– Dimensions Relatives –



126
127
128
# File 'lib/pfa/relative_pfa_node.rb', line 126

def left
  @left ||= start_at.to_px(pfa)
end

#markObject



181
182
183
# File 'lib/pfa/relative_pfa_node.rb', line 181

def mark
  abs_data[:hname]
end

#rightObject



134
135
136
137
138
139
140
141
142
143
# File 'lib/pfa/relative_pfa_node.rb', line 134

def right
  @right ||= begin 
    if id == 'DE' # denouement
      # Pour que le trait du dénouement soit dans l'image
      left + width - 2
    else
      left + width
    end
  end
end

#start_atObject

Note:

: défini à l’instantiation

PFA::NTime

Temps (relatif) de début du nœud



35
36
37
# File 'lib/pfa/relative_pfa_node.rb', line 35

def start_at
  @start_at
end

#topObject



145
146
147
# File 'lib/pfa/relative_pfa_node.rb', line 145

def top
  @top ||= MagickPFA::TOPS[type]
end

#typeObject



185
186
187
# File 'lib/pfa/relative_pfa_node.rb', line 185

def type
  abs_data[:type].to_sym
end

#vcenterObject



203
# File 'lib/pfa/relative_pfa_node.rb', line 203

def vcenter         ; @vcenter      ||= top   + demiheight        end

#widthObject



130
131
132
# File 'lib/pfa/relative_pfa_node.rb', line 130

def width
  @width ||= duration.to_px(pfa)
end