diff --git a/src/netanim/examples/resources_demo.cc b/src/netanim/examples/resources_demo.cc index 5e1031ef7..3d90d8298 100644 --- a/src/netanim/examples/resources_demo.cc +++ b/src/netanim/examples/resources_demo.cc @@ -171,7 +171,7 @@ int main (int argc, char *argv[]) // Provide the absolute path to the resource resourceId1 = pAnim->AddResource ("./ns-3-logo1.png"); resourceId2 = pAnim->AddResource ("./ns-3-logo2.png"); - pAnim->SetBackgroundImage ("./ns-3-background.png", 0, 0, 1, 1); + pAnim->SetBackgroundImage ("./ns-3-background.png", 0, 0, 0.2, 0.2, 0.1); Simulator::Schedule (Seconds (0.1), modify); // Set up the acutal simulation diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index eb9236aec..c145318b6 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -1798,10 +1798,14 @@ void AnimationInterface::SetBoundary (double minX, double minY, double maxX, dou userBoundary->yMin = minY; } -void AnimationInterface::SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY) +void AnimationInterface::SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity) { + if ((opacity < 0) || (opacity > 1)) + { + NS_FATAL_ERROR ("Opacity must be between 0.0 and 1.0"); + } std::ostringstream oss; - oss << GetXMLOpenCloseUpdateBackground (fileName, x, y, scaleX, scaleY); + oss << GetXMLOpenCloseUpdateBackground (fileName, x, y, scaleX, scaleY, opacity); WriteN (oss.str (), m_f); } @@ -2264,7 +2268,7 @@ std::string AnimationInterface::GetXMLOpenCloseUpdateNodeDescription (uint32_t n return oss.str (); } -std::string AnimationInterface::GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY) +std::string AnimationInterface::GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity) { std::ostringstream oss; oss << "" << std::endl; return oss.str (); } diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index eb7776cd4..8e0938dec 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -352,8 +352,10 @@ public: * \param y Y co-ordinate of the image * \param scaleX X scale of the image * \param scaleY Y scale of the image + * \param opacity Opacity of the background: A value between 0.0 and 1.0. 0.0 is transparent, + * 1.0 is opaque */ - void SetBackgroundImage (std::string fileName, double x, double y, double scaleX=1, double scaleY=1); + void SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity); /** * \brief Helper function to set the description for a link @@ -712,7 +714,7 @@ private: std::string GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType); std::string GetXMLOpenClose_routing (uint32_t id, std::string routingInfo); std::string GetXMLOpenClose_rp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements); - std::string GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY); + std::string GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity); void AppendXMLNodeDescription (std::ostream& ostream, uint32_t id) const; void AppendXMLNodeColor (std::ostream& ostream, const Rgb& color) const;