Method: HDLRuby::Viz::Node#case_svg
- Defined in:
- lib/HDLRuby/hruby_viz.rb
#case_svg(n, no = false) ⇒ Object
Generate a case description SVG text for node +n+, where +no+ tells if there is an else branch.
3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 |
# File 'lib/HDLRuby/hruby_viz.rb', line 3680 def case_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 |