Method: HDLRuby::Viz::Node#arrow_svg
- Defined in:
- lib/HDLRuby/hruby_viz.rb
#arrow_svg(x0, y0, x1, y1) ⇒ Object
Generate an arrow description SVG text for connection nodes. +x0+, +y0+, +x1+ and +y1+ are the coordinates of the arrow.
3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 |
# File 'lib/HDLRuby/hruby_viz.rb', line 3794 def arrow_svg(x0,y0,x1,y1) # Draw the line. # Vertical part res = "<line stroke=\"#000\" " + "stroke-width=\"#{@scale/12.0}\" stroke-linecap=\"round\" " + "x1=\"#{x0*@scale}\" " + "y1=\"#{y0*@scale}\" " + "x2=\"#{x0*@scale}\" " + "y2=\"#{y1*@scale}\" " + "/>\n" # Horizontal part res += "<line stroke=\"#000\" " + "stroke-width=\"#{@scale/12.0}\" stroke-linecap=\"round\" " + "x1=\"#{x0*@scale}\" " + "y1=\"#{y1*@scale}\" " + "x2=\"#{x1*@scale}\" " + "y2=\"#{y1*@scale}\" " + "/>\n" # The head. if x0 == x1 then # Vertical case res += "<polygon fill=\"#000\" stroke=\"none\" " + "points=\"#{(x1-1/4.0)*@scale},#{(y1-1/2.0-1/8.0)*@scale} " + "#{(x1+1/4.0)*@scale},#{(y1-1/2.0-1/8.0)*@scale} " + "#{(x1)*@scale},#{(y1)*@scale}\"/>\n" elsif x0 < x1 then # Horizontal left case: always end horizontally. res += "<polygon fill=\"#000\" stroke=\"none\" " + "points=\"#{(x1-1/2.0)*@scale},#{(y1-1/4.0)*@scale} " + "#{(x1-1/2.0)*@scale},#{(y1+1/4.0)*@scale} " + "#{(x1+1/8.0)*@scale},#{(y1)*@scale}\"/>\n" else # Horizontal right case: always end horizontally. res += "<polygon fill=\"#000\" stroke=\"none\" " + "points=\"#{(x1)*@scale},#{(y1+1/4.0)*@scale} " + "#{(x1)*@scale},#{(y1-1/4.0)*@scale} " + "#{(x1-1/8.0-1/2.0)*@scale},#{(y1)*@scale}\"/>\n" end return res end |