Class: CTioga::TangentSemiPrimitive
- Inherits:
-
TiogaPrimitiveMaker
- Object
- TiogaPrimitiveMaker
- CTioga::TangentSemiPrimitive
- Defined in:
- lib/CTioga/elements/tioga_primitives.rb
Constant Summary
Constants inherited from TiogaPrimitiveMaker
CTioga::TiogaPrimitiveMaker::Alignment, CTioga::TiogaPrimitiveMaker::Boolean, CTioga::TiogaPrimitiveMaker::Color, CTioga::TiogaPrimitiveMaker::FloatArray, CTioga::TiogaPrimitiveMaker::Justification, CTioga::TiogaPrimitiveMaker::LineStyle, CTioga::TiogaPrimitiveMaker::Marker, CTioga::TiogaPrimitiveMaker::Number, CTioga::TiogaPrimitiveMaker::PRIMITIVES, CTioga::TiogaPrimitiveMaker::Point
Instance Attribute Summary
Attributes inherited from TiogaPrimitiveMaker
#compulsory, #optional, #symbol
Instance Method Summary collapse
Methods inherited from TiogaPrimitiveMaker
#initialize, introspect, #parse_args, parse_spec
Methods included from Debug
#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right
Methods included from Log
#identify, #init_logger, #logger, #logger_options, #spawn
Constructor Details
This class inherits a constructor from CTioga::TiogaPrimitiveMaker
Instance Method Details
#make_funcall(args, plotmaker) ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/CTioga/elements/tioga_primitives.rb', line 259 def make_funcall(args, plotmaker) dict = parse_args(args) curve = plotmaker.last_curve raise 'The tangent drawing command needs to be specified *after* the curve it applies to' unless curve # We now need to transform index = curve.parse_position(dict["spec"]) dict.delete('spec') debug "Tangent point index is #{index}" tangent = plotmaker.last_curve.tangent(index) debug "Tangent slope is #{tangent}" point = curve.function.point(index) debug "Tangent point is #{point}" # We are now preparing the coordinates of the arrow: # * if markonly is on, it doesn't matter much # * if xextent, we take the array as X extents in either # direction # * the same obviously applies for yextent. # Only one spec can be used at a time if dict['xextent'] fact = dict['xextent'][0]/tangent[0] dict['head'] = point + (tangent * fact) fact = (dict['xextent'][1] || 0.0)/tangent[0] dict['tail'] = point - (tangent * fact) elsif dict['yextent'] fact = dict['yextent'][0]/tangent[1] dict['head'] = point + (tangent * fact) fact = (dict['yextent'][1] || 0.0)/tangent[1] dict['tail'] = point - (tangent * fact) # We prolong the tangent until it intersects the given # X= or Y= positions elsif dict['xuntil'] fact = (dict['xuntil'][0] - point[0])/tangent[0] dict['head'] = point + (tangent * fact) if dict['xuntil'][1] fact = (dict['xuntil'][1] - point[0])/tangent[0] else fact = 0 end dict['tail'] = point + (tangent * fact) elsif dict['yuntil'] fact = (dict['yuntil'][0] - point[1])/tangent[1] dict['head'] = point + (tangent * fact) if dict['yuntil'][1] fact = (dict['yuntil'][1] - point[1])/tangent[1] else fact = 0 end dict['tail'] = point + (tangent * fact) else dict['line_width'] = 0 dict['head'] = point dict['tail'] = point - tangent end # Remove unnecessary keys... %w(spec xextent yextent xuntil yuntil).map {|k| dict.delete(k)} # We setup other defaults than the usual ones, from # the current curve. dict['color'] ||= curve.style.color # color from curve dict['line_width'] ||= curve.style.linewidth dict['tail_marker'] ||= 'None' # No tail by default. debug "Tangent coordinates: #{dict['head']} -> #{dict['tail']}" # And we return the Funcall... return TiogaFuncall.new(@symbol, dict) end |