]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/elements/CanvasPath.cxx
Canvas: add chainable helpers to Path for adding segments.
[simgear.git] / simgear / canvas / elements / CanvasPath.cxx
index 045aabf5e0ff6799cc11553b65f6c2be736067be..5e9efa083b9e820655c8586764ead75caa5ef2a5 100644 (file)
@@ -429,6 +429,9 @@ namespace canvas
        */
       void update()
       {
+        if( !vgHasContextSH() )
+          return;
+
         if( _attributes_dirty & PATH )
         {
           const VGbitfield caps = VG_PATH_CAPABILITY_APPEND_TO
@@ -521,6 +524,60 @@ namespace canvas
     return _path->getTransformedBounds(m);
   }
 
+  //----------------------------------------------------------------------------
+  Path& Path::moveTo(float x_abs, float y_abs)
+  {
+    return addSegment(VG_MOVE_TO_ABS, x_abs, y_abs);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::move(float x_rel, float y_rel)
+  {
+    return addSegment(VG_MOVE_TO_REL, x_rel, y_rel);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::lineTo(float x_abs, float y_abs)
+  {
+    return addSegment(VG_LINE_TO_ABS, x_abs, y_abs);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::line(float x_rel, float y_rel)
+  {
+    return addSegment(VG_LINE_TO_REL, x_rel, y_rel);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::horizTo(float x_abs)
+  {
+    return addSegment(VG_HLINE_TO_ABS, x_abs);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::horiz(float x_rel)
+  {
+    return addSegment(VG_HLINE_TO_REL, x_rel);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::vertTo(float y_abs)
+  {
+    return addSegment(VG_VLINE_TO_ABS, y_abs);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::vert(float y_rel)
+  {
+    return addSegment(VG_VLINE_TO_REL, y_rel);
+  }
+
+  //----------------------------------------------------------------------------
+  Path& Path::close()
+  {
+    return addSegment(VG_CLOSE_PATH);
+  }
+
   //----------------------------------------------------------------------------
   void Path::childRemoved(SGPropertyNode* child)
   {