Allow boolean values to be converted to Random. The link's value (0 or 1) has a...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 14 Feb 2008 09:31:11 +0000 (09:31 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 14 Feb 2008 09:31:11 +0000 (09:31 +0000)
git-svn-id: http://svn.voria.com/code@1690 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/modules/mod_noise/valuenode_random.cpp

index 0488189..fdfa331 100644 (file)
@@ -67,6 +67,9 @@ ValueNode_Random::ValueNode_Random(const ValueBase &value):
        case ValueBase::TYPE_ANGLE:
                set_link("link",ValueNode_Const::create(value.get(Angle())));
                break;
+       case ValueBase::TYPE_BOOL:
+               set_link("link",ValueNode_Const::create(value.get(bool())));
+               break;
        case ValueBase::TYPE_COLOR:
                set_link("link",ValueNode_Const::create(value.get(Color())));
                break;
@@ -124,6 +127,10 @@ ValueNode_Random::operator()(Time t)const
                return ((*link_)(t).get( Angle()) +
                                Angle::deg(random(Smooth(smooth), 0, 0, 0, speed) * radius));
 
+       case ValueBase::TYPE_BOOL:
+               return round_to_int((*link_)(t).get(  bool()) +
+                                                       random(Smooth(smooth), 0, 0, 0, speed) * radius) > 0;
+
        case ValueBase::TYPE_COLOR:
                return (((*link_)(t).get( Color()) +
                                 Color(random(Smooth(smooth), 0, 0, 0, speed),
@@ -258,6 +265,7 @@ ValueNode_Random::check_type(ValueBase::Type type)
 {
        return
                type==ValueBase::TYPE_ANGLE             ||
+               type==ValueBase::TYPE_BOOL              ||
                type==ValueBase::TYPE_COLOR             ||
                type==ValueBase::TYPE_INTEGER   ||
                type==ValueBase::TYPE_REAL              ||