Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 976 lines (706 sloc) 27.34 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1st December 2004), see www.w3.org" />

  <title>RMagick 0.0.0: RVG Reference: RVG Class</title>
  <meta http-equiv="Content-Type" content=
  "text/html; charset=us-ascii" />
  <meta name="GENERATOR" content="Quanta Plus" />
  <meta name="Copyright" content=
  "Copyright (C) 2006 by Timothy P. Hunter" />
  <link rel="stylesheet" type="text/css" href="css/doc.css" />
<script type="text/javascript" src="scripts/doc.js">
</script>
<script type="text/javascript">
  //<![CDATA[
  //]]>
</script>
<style type="text/css">
  /*<![CDATA[*/
    }
  /*]]>*/
</style>
</head>

<body>
  <h6 id="header">RMagick 0.0.0 User's Guide and Reference</h6>

  <div class="nav">
    &laquo;&nbsp;<a href="rvgtut.html">Prev</a> | <a href=
    "index.html">Contents</a> | <a href=
    "rvggroup.html">Next</a>&nbsp;&raquo;
  </div>

  <h1>class RVG <span class="superclass">&lt; Object</span></h1>

  <div id="toc">
    <h2>Table of Contents</h2>

    <h3>class methods</h3>

    <ul>
      <li><a href="#new">new</a></li>
    </ul>

    <h3>attributes</h3>

    <div class="toccol">
      <ul>
        <li><a href=
        "#RVG_background_fill">background_fill=</a></li>

        <li><a href=
        "#RVG_background_fill_opacity">background_fill_opacity=</a></li>

        <li><a href=
        "#RVG_background_image">background_image=</a></li>

        <li><a href=
        "#RVG_background_pattern">background_pattern=</a></li>

        <li><a href=
        "#RVG_background_position">background_position=</a></li>
      </ul>
    </div>

    <div class="toccol">
      <ul>
        <li><a href="#RVG_canvas">canvas</a></li>

        <li><a href="#RVG_desc">desc, desc=</a></li>

        <li><a href="#RVG_height">height</a></li>

        <li><a href="#RVG_metadata">metadata, metadata=</a></li>
      </ul>
    </div>

    <div class="toccol">
      <ul>
        <li><a href="#RVG_title">title, title=</a></li>

        <li><a href="#RVG_width">width</a></li>

        <li><a href="#RVG_x">x</a></li>

        <li><a href="#RVG_y">y</a></li>
      </ul>
    </div>

    <h3>instance methods</h3>

    <div>
      <div class="toccol">
        <ul>
          <li><a href="#RVG_draw">draw</a></li>

          <li><a href="#RVG_g">g</a></li>

          <li><a href="#RVG_image">image</a></li>
        </ul>
      </div>

      <div class="toccol">
        <ul>
          <li><a href=
          "#RVG_preserve_aspect_ratio">preserve_aspect_ratio</a></li>

          <li><a href="#RVG_rvg">rvg</a></li>

          <li><a href="#RVG_text">text</a></li>
        </ul>
      </div>

      <div class="toccol">
        <ul>
          <li><a href="#RVG_use">use</a></li>

          <li><a href="#RVG_viewbox">viewbox</a></li>
        </ul>
      </div>
    </div>

    <h3>shared methods</h3>

    <p>In addition to the methods listed above, <code>class
    RVG</code> also implements the <a href=
    "rvgstyle.html">styles</a> method, the <a href=
    "rvgshape.html">shape methods</a> and the <a href=
    "rvgxform.html">transform methods</a>.</p>

    <h3>Units</h3>

    <div class="toccol">
      <ul>
        <li><a href="#units">Units conversion methods</a></li>
      </ul>
    </div>
  </div>

  <h2 class="methods">class methods</h2>

  <div class="sig">
    <h3 id="RVG_new">new</h3>

    <p>RVG.new(<span class="arg">width</span>=nil, <span class=
    "arg">height</span>=nil) [ <span class="arg">{ |canvas| drawing
    method calls }</span> ] -&gt; anRVG</p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Creates a container that can have its own coordinate system.
    Within the block, call drawing methods on <em>canvas</em> to
    render shapes, text, and raster images in the container.</p>

    <p>An RVG object is always the outermost container for a
    drawing. Call the <a href="#RVG_draw">draw</a> method on the
    returned RVG object to produce the final image.</p>

    <h4>Arguments</h4>

    <p>If the RVG object is the outermost container, <span class=
    "arg">width</span> and <span class="arg">height</span> are
    required and specify the width and height of the final drawing
    in pixels. You can call <a href="#units">conversion methods</a>
    to use units such as inches and millimeters instead of
    pixels.</p>

    <p>Otherwise, <span class="arg">width</span> and <span class=
    "arg">height</span> specify the area of the viewbox. If the RVG
    object will be used as an argument to the <a href=
    "rvguse.html#use">use</a> method, then <span class=
    "arg">width</span> and <span class="arg">height</span> may be
    omitted here, then specified as arguments to
    <code>use</code>.</p>

    <h4>Returns</h4>

    <p>An RVG object</p>

    <h4>Example</h4>

    <p>See the <a href="rvgtut.html">tutorial</a> for a simple
    example. The image below demonstrates an advanced use of
    <code>RVG.new</code>. This example creates an RVG object that
    draws an orange-and-green target. The <span class=
    "arg">width</span> and <span class="arg">height</span>
    arguments are omitted in the <code>RVG.new</code> call.
    Instead, the viewport width and height are specified as
    arguments to 4 invocations of <a href=
    "rvguse.html#use">use</a>. Each <code>use</code> specifies a
    different viewport size, so the same RVG object draws 4
    different-sized targets.</p>

    <p>Click the image to see the example script.</p>

    <p><a href="javascript:popup('nested_rvg.rb.html')"><img src=
    "ex/nested_rvg.gif" title="Click to see the example script"
    alt="nested RVG example" /></a></p>

    <h4>See also</h4>

    <p><a href="rvggroup.html">Group</a></p>
  </div>

  <h2 class="methods">attributes</h2>

  <div class="sig">
    <h3 id='RVG_background_fill'>background_fill=</h3>

    <p><span class="arg">canvas</span>.background_fill =
    <span class="arg">value</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Specify a background fill color. The attribute value may be
    either a <a href="struct.html#Pixel">pixel</a> or a <a href=
    "imusage.html#color_names">color name.</a> The default fill
    color is "#000000ff". This color is usually called "none". This
    attribute has no effect on nested RVG objects.</p>

    <h4>Example</h4>
    <pre>
canvas.background_fill = 'white'
</pre>

    <h4>Returns</h4><span class="arg">value</span>
  </div>

  <div class="sig">
    <h3 id='RVG_background_fill_opacity'>
    background_fill_opacity=</h3>

    <p><span class="arg">canvas</span>.background_fill_opacity =
    <span class="arg">value</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Specify the opacity of the background fill color when the
    <a href="#RVG_background_fill">background fill</a> is not the
    default. The value is a number between 0.0 (fully transparent)
    and 1.0 (fully opaque). The default is 1.0. The attribute is
    ignored unless <code>background_fill</code> is specified. This
    attribute has no effect on nested RVG objects.</p>

    <h4>Example</h4>
    <pre>
canvas.background_fill = 'white'
canvas.background_fill_opacity = 0.50
</pre>

    <h4>Returns</h4><span class="arg">value</span>
  </div>

  <div class="sig">
    <h3 id='RVG_background_image'>background_image=</h3>

    <p><span class="arg">canvas</span>.background_image =
    <span class="arg">anImage</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Specify an image to be used as the canvas background. The
    value is an <a href="image1.html#new">Image</a> object. This
    attribute has no effect on nested RVG objects.</p>

    <h4>Example</h4>
    <pre>
canvas.background_image = Magick::Image.read('myBackground.gif').first
</pre>

    <h4>Returns</h4><span class="arg">anImage</span>

    <h4>See also</h4>

    <p><a href=
    "#RVG_background_position">background_position=</a></p>
  </div>

  <div class="sig">
    <h3 id='RVG_background_pattern'>background_pattern=</h3>

    <p><span class="arg">canvas</span>.background_pattern =
    <span class="arg">aFill</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Specify an <a href="struct.html#fill">Fill object</a> to
    fill the canvas background. This attribute has no effect on
    nested RVG objects.</p>

    <h4>Example</h4>
    <pre>
canvas.background_pattern = Magick::GradientFill.new(0, 0, 0, 100, "#900", "#000")
</pre>

    <h4>Returns</h4><span class="arg">aFill</span>
  </div>

  <div class="sig">
    <h3 id='RVG_background_position'>background_position=</h3>

    <p><span class="arg">canvas</span>.background_position =
    <span class="arg">pos</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>If the dimensions of the image specified by <a href=
    "#RVG_background_image">background_image</a> do not exactly
    match the canvas dimensions, this attribute specifies how to
    position the image on the background. This attribute has no
    effect on nested RVG objects.</p>

    <h4>Argument</h4>The value of <span class="arg">pos</span> can
    be any one of the following symbols :

    <dl>
      <dt>:scaled</dt>

      <dd>The image is scaled to fit. The image proportions are not
      retained.</dd>

      <dt>:tiled</dt>

      <dd>The image is tiled across the background.</dd>

      <dt>:fit</dt>

      <dd>The image is scaled to fit. The image proportions are
      retained. Any part of the background that is not covered by
      the image is colored with the <a href=
      "#RVG_background_color">background color</a>.</dd>
    </dl>

    <h4>Example</h4>
    <pre>
canvas.background_image = Magick::Image.read('myBackground.gif').first
canvas.background_position = :scaled
</pre>

    <h4>Returns</h4><span class="arg">pos</span>
  </div>

  <div class="sig">
    <h3 id='RVG_canvas'>canvas</h3>

    <p><span class="arg">rvg</span>.canvas -&gt; anImage</p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>After the <a href="#RVG_draw">draw</a> method has been used,
    returns the rendered image. This is the same image that
    <a href="#RVG_draw">draw</a> returns.</p>

    <h4>Returns</h4>

    <p>An image</p>
  </div>

  <div class="sig">
    <h3 id="RVG_desc">desc, desc=</h3>

    <p><span class="arg">rvg</span>.desc -&gt; <span class=
    "arg">aString</span><br />
    <span class="arg">rvg</span>.desc = <span class=
    "arg">aString</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>Use the <code>desc</code> attribute to
    assign a text description to the drawing. The description will
    be assigned to the "desc" property of the resulting image. This
    attribute has no effect on nested RVG objects.
  </div>

  <div class="sig">
    <h3 id='RVG_height'>height</h3>

    <p><span class="arg">rvg</span>.height -&gt; <span class=
    "arg">height</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>The height of the RVG object in user coordinates.</p>

    <h4>See also</h4>

    <p><a href="#RVG_width">width</a></p>
  </div>

  <div class="sig">
    <h3 id="RVG_metadata">metadata, metadata=</h3>

    <p><span class="arg">rvg</span>.metadata -&gt; <span class=
    "arg">aString</span><br />
    <span class="arg">rvg</span>.metadata = <span class=
    "arg">aString</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>Use the <code>metadata</code> attribute to
    assign additional metadata to the drawing. The metadata string
    will be assigned to the "metadata" property of the resulting
    image. This attribute has no effect on nested RVG objects.
  </div>

  <div class="sig">
    <h3 id="RVG_title">title, title=</h3>

    <p><span class="arg">rvg</span>.title -&gt; <span class=
    "arg">aString</span><br />
    <span class="arg">rvg</span>.title = <span class=
    "arg">aString</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>Use the <code>title</code> attribute to
    assign a title to the drawing. The title will be assigned to
    the "title" property of the resulting image. This attribute has
    no effect on nested RVG objects.
  </div>

  <div class="sig">
    <h3 id='RVG_width'>width</h3>

    <p><span class="arg">rvg</span>.width -&gt; <span class=
    "arg">width</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>The width of the RVG object in user coordinates.</p>

    <h4>See also</h4>

    <p><a href="#RVG_height">height</a></p>
  </div>

  <div class="sig">
    <h3 id='RVG_x'>x</h3>

    <p><span class="arg">rvg</span>.x -&gt; <span class=
    "arg">x-offset</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>If this RVG object is nested within another RVG object,
    returns the x-offset in user coordinates from the upper-left
    corner of the enclosing RVG object.</p>

    <h4>See also</h4>

    <p><a href="#RVG_y">y</a></p>
  </div>

  <div class="sig">
    <h3 id='RVG_y'>y</h3>

    <p><span class="arg">rvg</span>.y -&gt; <span class=
    "arg">y-offset</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>If this RVG object is nested within another RVG object,
    returns the y-offset in user coordinates from the upper-left
    corner of the enclosing RVG object.</p>

    <h4>See also</h4>

    <p><a href="#RVG_x">x</a></p>
  </div>

  <h2 class="methods">instance methods</h2>

  <div class="sig">
    <h3 id='RVG_draw'>draw</h3>

    <p><span class="arg">rvg</span>.draw -&gt; anImage</p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Causes all the drawing objects that have been added to the
    canvas to be rendered.</p>

    <p>Regardless of the order in which methods were called,
    <code>draw</code> executes the methods in this order:</p>

    <ol>
      <li>transforms, in the order they were called.</li>

      <li><code>viewbox</code> and
      <code>preserve_aspect_ratio</code></li>

      <li>styles</li>

      <li>nested groups, RVG objects, shapes, text, and images, in
      the order they were added to the containing object</li>
    </ol>

    <p>Nested groups and RVG objects also follow this sequence.</p>

    <h4>Returns</h4>

    <p>An image</p>

    <h4>Example</h4>
    <pre>
      img = rvg.draw
      img.write('myDrawing.jpg')
</pre>
  </div>

  <div class="sig">
    <h3 id='RVG_g'>g</h3>

    <p><span class="arg">rvg.</span>g [{|<span class=
    "arg">grp</span>| ...}] -&gt; <span class=
    "arg">aGroup</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Calls <a href="rvggroup.html#new">RVG::Group.new</a> to
    construct a group and adds it to the enclosing RVG object.
    Yields to a block if one is present, passing the new group as
    an argument.</p>

    <h4>Returns</h4>

    <p>Returns the new group, so <code>RVG::Group</code> methods
    can be chained to this method.</p>
  </div>

  <div class="sig">
    <h3 id='RVG_image'>image</h3>

    <p><span class="arg">rvg.</span>image(<span class=
    "arg">raster_image</span>, <span class="arg">width</span>=nil,
    <span class="arg">height</span>=nil, <span class=
    "arg">x</span>=0, <span class="arg">y</span>=0) -&gt;
    <span class="arg">anImage</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Calls <a href="rvgimage.html#new">RVG::Image.new</a> to
    construct an image and adds it to the enclosing RVG object.</p>

    <h4>Returns</h4>

    <p>Returns the new image, so <code>RVG::Image</code> methods
    can be chained to this method.</p>

    <h4>Notes</h4>

    <p>An <code>RVG::Image</code> object is <em>not</em> the same
    as a <a href="image1.html">Magick::Image</a> object!</p>
  </div>

  <div class="sig">
    <h3 id='RVG_preserve_aspect_ratio'>preserve_aspect_ratio</h3>

    <p><span class=
    "arg">rvg</span>.preserve_aspect_ratio(<span class=
    "arg">align</span>, <span class=
    "arg">meet_or_slice</span>='meet') [{|<span class=
    "arg">self</span>| ...}] -&gt; <span class=
    "arg">self</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>If you use the <a href="#RVG_viewbox">viewbox</a> method and
    the user coordinate system does not scale uniformly to the
    default coordinate system (for example, the width and height of
    the RVG object is 4x3 and the user coordinate system is 16x9),
    use the <code>preserve_aspect_ratio</code> method to specify
    whether or not the content is stretched to fit. If not, you can
    specify how to fit the content into the space.</p>

    <p><code>Preserve_aspect_ratio</code> yields to a block if one
    is present, passing <span class="arg">self</span> as an
    argument.</p>

    <h4>Arguments</h4>

    <dl>
      <dt>align</dt>

      <dd>
        When the value of the <code>meet_or_slice</code> argument
        is 'meet' or 'slice', this argument controls the placement
        of the content within the viewport. The <code>align</code>
        argument is the concatenation of an <em>x</em>-aligment and
        a <em>y</em>-alignment. The values are shown in these
        lists:

        <h6><em>x</em>-alignment</h6>

        <dl>
          <dt>xMin</dt>

          <dd>align the minimum <em>x</em> value of the content
          with the left corner of the viewport.</dd>

          <dt>xMid</dt>

          <dd>vertically center the content within the
          viewport.</dd>

          <dt>xMax</dt>

          <dd>align the maximum <em>x</em> value of the content
          with the right corner of the viewport.</dd>
        </dl>

        <h6><em>y</em>-alignment</h6>

        <dl>
          <dt>YMin</dt>

          <dd>align the minimum <em>y</em> value of the content
          with the top of the viewport.</dd>

          <dt>YMid</dt>

          <dd>horizontally center the content within the
          viewport.</dd>

          <dt>YMax</dt>

          <dd>align the maximum <em>y</em> value of the content
          with the bottom of the viewport</dd>
        </dl>
      </dd>

      <dt>meet_or_slice</dt>

      <dd>
        This argument can have one of these three values:

        <dl>
          <dt>'none'</dt>

          <dd>The content is scaled as necessary so that it fits
          exactly within the viewport. The aspect ratio is
          <em>not</em> maintained.</dd>

          <dt>'meet'</dt>

          <dd>The content is scaled as necessary so that the larger
          dimension exactly fits the viewport. There may be some
          unused space in the viewport. The aspect ratio is
          maintained.</dd>

          <dt>'slice'</dt>

          <dd>The content is scaled as necessary so that the
          smaller dimension exactly fits the viewport. Some of the
          content in the larger dimension may be cut off. The
          aspect ratio is maintained.</dd>
        </dl>
      </dd>
    </dl>

    <h4>Example</h4>

    <p><a href=
    "javascript:popup('PreserveAspectRatio.rb.html')"><img src=
    "ex/PreserveAspectRatio.gif" title=
    "Click to see the example script" alt=
    "preserve_aspect_ratio example" /></a></p>

    <h4>Returns</h4>

    <p><span class="arg">Self</span>, so other <code>RVG</code>
    methods can be chained to this method.</p>

    <h4>See Also</h4>

    <p><a href="#RVG_viewbox">viewbox</a></p>
  </div>

  <div class="sig">
    <h3 id="RVG_rvg">rvg</h3>

    <p><span class="arg">rvg</span>.rvg(<span class=
    "arg">width</span>, <span class="arg">height</span>,
    <span class="arg">x</span>=0, <span class="arg">y</span>=0)
    [{|<span class="arg">new_rvg</span>| ...}] -&gt; <span class=
    "arg">anRVG</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>This method constructs a new RVG object and adds it to the
    enclosing RVG object. Each nested RVG object can use the
    <a href="#RVG_viewbox">viewbox</a> method to define its own
    coordinate system. The <code>rvg</code> method yields to a
    block, passing the nested RVG object as an argument. Within the
    block, any drawing objects added to the nested RVG object are
    rendered within the nested RVG object's viewport.</p>

    <h4>Arguments</h4>

    <dl>
      <dt>width, height</dt>

      <dd>Specifies the viewport width and height. The units are in
      the user coordinate system of the parent container.</dd>

      <dt>x, y</dt>

      <dd>The x- and y-axis offsets of the viewport upper-left
      corner. The units are in the user coordinate system of the
      parent container.</dd>
    </dl>

    <h4>Example</h4>

    <p>See the example for <a href=
    "#RVG_preserve_aspect_ratio">preserve_aspect_ratio</a>.</p>

    <h4>Returns</h4>

    <p>The <code>RVG</code> object, so other <code>RVG</code>
    methods can be chained to this method.</p>
  </div>

  <div class="sig">
    <h3 id='RVG_text'>text</h3>

    <p><span class="arg">rvg.</span>text(<span class=
    "arg">x</span>=0, <span class="arg">y</span>=0, <span class=
    "arg">text</span>=nil) [{|<span class="arg">aText</span>| ...}]
    -&gt; <span class="arg">aText</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Calls <a href="rvgtext.html#new">RVG::Text.new</a> to
    construct a text object and adds it to the enclosing RVG
    object. Yields to a block if one is present, passing the new
    text object as an argument.</p>

    <h4>Returns</h4>

    <p>The <code>RVG::Text</code> object, so other
    <code>RVG::Text</code> methods can be chained to this
    method.</p>
  </div>

  <div class="sig">
    <h3 id="RVG_use">use</h3>

    <p><span class="arg">rvg</span>.use(<span class=
    "arg">obj</span>, <span class="arg">x</span>=0, <span class=
    "arg">y</span>=0, <span class="arg">width</span>=nil,
    <span class="arg">height</span>=nil) -&gt; <span class=
    "arg">aUse</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Calls <a href="rvguse.html#new">RVG::Use.new</a> to
    construct a <code>use</code> object and adds it to the RVG
    object.</p>

    <p>When the referenced argument is another RVG object,
    <span class="arg">width</span> and <span class=
    "arg">height</span> can be used to specify the width and height
    of the viewport. If present and non-nil, these arguments
    override any width and height specified when the RVG object was
    created. You must specify the viewport size either when
    creating the RVG object or when referencing it with
    <code>use</code>.</p>

    <h4>Examples</h4>

    <p>See <a href="rvguse.html#new">RVG::Use.new</a></p>

    <h4>Returns</h4>

    <p>The <code>RVG::Use</code> object, so other
    <code>RVG::Use</code> methods can be chained to this
    method.</p>
  </div>

  <div class="sig">
    <h3 id="RVG_viewbox">viewbox</h3>

    <p><span class="arg">rvg</span>.viewbox(<span class=
    "arg">min_x</span>, <span class="arg">min_y</span>,
    <span class="arg">width</span>, <span class=
    "arg">height</span>) [{|<span class="arg">self</span>| ...}]
    -&gt; <span class="arg">rvg</span></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>The area of the RVG object is called the <em>viewport</em>.
    By default the origin of the coordinate system for an RVG
    object is (0,0). The user coordinates are pixels and the width
    and height are established by the <span class=
    "arg">width</span> and <span class="arg">height</span>
    arguments to <code>RVG.new</code>.</p>

    <p>Use the <code>viewbox</code> method to superimpose a user
    coordinate system on the viewport. The <code>viewbox</code>
    method lets you set up a coordinate system using the units of
    your choice.</p>

    <p>The <code>viewbox</code> method yields to a block if one is
    present, passing <code>self</code> as an argument.</p>

    <h4>Arguments</h4>

    <dl>
      <dt>min_x, min_y</dt>

      <dd>The minimum <em>x</em>-coordinate and
      <em>y</em>-coordinate of the user coordinate system.</dd>

      <dt>width, height</dt>

      <dd>The width and height of the user coordinate system.</dd>
    </dl>

    <h4>Example</h4>

    <p>In the following examples, because the <code>viewbox</code>
    method specifies the dimensions of the coordinate system, the
    dimensions specified for the graphic objects can remain the
    same while the size of the canvas changes.</p>

    <p><strong>Rendered into a 300x200 viewport</strong><a href=
    "javascript:popup('ViewBox.rb.html')"><img src=
    "ex/ViewBox_300x200.gif" title=
    "Click to see the example script" alt=
    "viewbox 300x200 example" /></a></p>

    <p><strong>Rendered into a 150x200 viewport</strong><a href=
    "javascript:popup('ViewBox.rb.html')"><img src=
    "ex/ViewBox_150x200.gif" title=
    "Click to see the example script" alt=
    "viewbox 150x200 example" /></a></p>

    <h4>Returns</h4>

    <p><span class="arg">Self</span>, so other <code>RVG</code>
    methods may be chained to <code>viewbox</code>.</p>

    <h4>See Also</h4>

    <p><a href=
    "#RVG_preserve_aspect_ratio">preserve_aspect_ratio</a></p>
  </div>

  <h2 id="units" class="methods">Units</h2>

  <div style="margin-left: 235px; margin-top:1em">
    <p>RVG supports a subset of the unit identifiers defined by the
    SVG specification. In RVG, unit identifiers are methods in the
    Float and Fixnum classes. The units are (for the most part)
    defined in terms of "dots per inch," accordingly, the unit
    identifier methods are added only if the value</p>
    <pre>
    Magick::RVG.dpi = NN
</pre>

    <p>is defined, where NN is the number of "dots" (pixels) per
    inch you wish to use. (Hint: 90 is a good default.)</p>

    <p>For example, to specify a length of 10 inches, you can
    use</p>
    <pre>
    Magick::RVG.dpi = 90
    length = 10.in # =&gt; 900 pixels
</pre>

    <p>If the dpi is defined, the following methods are added to
    <code>Float</code> and <code>Fixnum</code></p>

    <dl>
      <dt>px</dt>

      <dd>Pixel. The default unit of measurement.</dd>

      <dt>in</dt>

      <dd>Converts inches to pixels</dd>

      <dt>mm</dt>

      <dd>Converts millimeters to pixels</dd>

      <dt>cm</dt>

      <dd>Converts centimeters to pixels</dd>

      <dt>pt</dt>

      <dd>Converts points to pixels. There are 72 points to the
      inch.</dd>

      <dt>pc</dt>

      <dd>Converts picas to pixels. There are 12 points to the
      pica.</dd>

      <dt>deg</dt>

      <dd>Degrees. The default unit of rotation.</dd>

      <dt>rad</dt>

      <dd>Converts radians to degrees.</dd>

      <dt>grad</dt>

      <dd>Converts grads to degrees. There are 400 grads in a
      circle.</dd>

      <dt>pct</dt>

      <dd>This conversion takes an numeric argument and returns a
      percentage of the argument. For example 20.pct(150) -&gt;
      30</dd>
    </dl>

    <p>SVG also supports <em>em</em> and <em>ex</em>, which are
    measurements based on the font size. RVG does not.</p>
  </div>

  <p class="spacer">&nbsp;</p>

  <div class="nav">
    &laquo; <a href="rvgtut.html">Prev</a> | <a href=
    "index.html">Contents</a> | <a href="rvggroup.html">Next</a>
    &raquo;
  </div>
</body>
</html>
Something went wrong with that request. Please try again.