Method: HDLRuby::Viz::Node#if_svg

Defined in:
lib/HDLRuby/hruby_viz.rb

#if_svg(n, no = false) ⇒ Object

Generate an if description SVG text for node +n+, where +no+ tells if there is an else branch.



3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
# File 'lib/HDLRuby/hruby_viz.rb', line 3640

def if_svg(n,no=false)
  # The shape representing the instance.
  res = "<path fill=\"#B0E2FF\" stroke=\"#000\" " +
    "stroke-width=\"#{@scale/12.0}\" " +
    "d=\"M #{(n.xpos)*@scale} #{(n.ypos+n.height/2.0)*@scale} " +
    "L #{(n.xpos+n.width/2.0)*@scale} #{(n.ypos+n.height)*@scale} " + 
    "L #{(n.xpos+n.width)*@scale} #{(n.ypos+n.height/2.0)*@scale} " +
    "L #{(n.xpos+n.width/2.0)*@scale} #{(n.ypos)*@scale} " + 
    "Z \" />\n"
  # Its text.
  res += "<text id=\"text#{n.name}\" " +
    "style=\"text-anchor: middle; dominant-baseline: middle;\" " +
    "font-family=\"monospace\" font-size=\"1px\" " +
    "x=\"#{(n.xpos + n.width/2.0)*@scale}\" "+
    "y=\"#{(n.ypos + n.height/2.0)*@scale}\">" +
    n.to_s + "</text>\n"
  # Its text resizing.
  res += Viz.svg_text_fit("text#{n.name}",(n.width-3)*@scale,
                           0.6*@scale)
  # The yes text.
  res += "<text " +
    "style=\"text-anchor: middle; dominant-baseline: middle;\" " +
    "font-family=\"monospace\" font-size=\"#{@scale/2.0}px\" " +
    "x=\"#{(n.xpos + n.width+0.1)*@scale}\" "+
    "y=\"#{(n.ypos + n.height/2.0+0.5)*@scale}\">" +
    "Yes" + "</text>\n"
  # The no text if any.
  if no then
    res += "<text " +
      "style=\"text-anchor: middle; dominant-baseline: middle;\" " +
      "font-family=\"monospace\" font-size=\"#{@scale/2.0}px\" " +
      "x=\"#{(n.xpos + n.width/2.0+0.7)*@scale}\" "+
      "y=\"#{(n.ypos + n.height+0.3)*@scale}\">" +
      "No" + "</text>\n"
  end
  return res
end