FlightGear Newsletter July 2014: Difference between revisions

Jump to navigation Jump to search
m (Added youtube link)
Line 83: Line 83:
   }}
   }}
}}
}}
== Adding backdrop styling to Canvas (by Gijs) ==
Gijs was looking for an outline that follows the shape of the text, which is what backdrop provides.
For his solution, see the two diffs below. He didn't add the full range of backdrop options, just outline for now [http://forum.flightgear.org/viewtopic.php?f=71&t=23500&p=214278#p214275].
{{FGCquote
  |And this is how it looks in FlightGear now :-) Notice how the overlapping waypoints are easier to read (this image is a little exaggerated with all those fixes).<br/>
<br/>
(see the [http://i.imgur.com/dqMzBS4.png linked image])
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=214268#p214268
    |title=<nowiki>Re: osgText backdrop</nowiki>
    |author=<nowiki>Gijs</nowiki>
    |date=<nowiki>Mon Jul 07</nowiki>
  }}
}}
<syntaxhighlight lang="diff">
commit 5cc0adc778bda1773189b0119d24fbaf5ecd4500
Author: Gijs de Rooy
Date:  Mon Jul 7 18:26:16 2014 +0200
    Canvas: add backdrop option to text
diff --git a/simgear/canvas/elements/CanvasText.cxx b/simgear/canvas/elements/CanvasText.cxx
index d99760a..3a986e1 100644
--- a/simgear/canvas/elements/CanvasText.cxx
+++ b/simgear/canvas/elements/CanvasText.cxx
@@ -39,6 +39,7 @@ namespace canvas
      void setLineHeight(float factor);
      void setFill(const std::string& fill);
      void setBackgroundColor(const std::string& fill);
+      void setOutlineColor(const std::string& backdrop);
      SGVec2i sizeForWidth(int w) const;
      osg::Vec2 handleHit(const osg::Vec2f& pos);
@@ -97,6 +98,15 @@ namespace canvas
  }
  //----------------------------------------------------------------------------
+  void Text::TextOSG::setOutlineColor(const std::string& backdrop)
+  {
+    osg::Vec4 color;
+    setBackdropType(osgText::Text::OUTLINE);
+    if( parseColor(backdrop, color) )
+      setBackdropColor( color );
+  }
+
+  //----------------------------------------------------------------------------
  // simplified version of osgText::Text::computeGlyphRepresentation() to
  // just calculate the size for a given weight. Glpyh calculations/creating
  // is not necessary for this...
@@ -546,6 +556,7 @@ namespace canvas
    addStyle("fill", "color", &TextOSG::setFill, text);
    addStyle("background", "color", &TextOSG::setBackgroundColor, text);
+    addStyle("backdrop", "color", &TextOSG::setOutlineColor, text);
    addStyle("character-size",
              "numeric",
              static_cast<
</syntaxhighlight>
<syntaxhighlight lang="diff">commit 838cabd2a551834cbcac2b3edd21500409ff2e98
Author: Gijs de Rooy
Date:  Mon Jul 7 18:27:50 2014 +0200
    Canvas: add backdrop option to text
diff --git a/Nasal/canvas/api.nas b/Nasal/canvas/api.nas
index 8bc12d8..3047dbf 100644
--- a/Nasal/canvas/api.nas
+++ b/Nasal/canvas/api.nas
@@ -634,6 +634,8 @@ var Text = {
  setColorFill: func me.set('background', _getColor(arg)),
  getColorFill: func me.get('background'),
+  setBackdropColor: func me.set('backdrop', _getColor(arg)),
};
# Path
</syntaxhighlight>


== FGCanvas Updates ==
== FGCanvas Updates ==

Navigation menu