Quite a lot of the example canvases use the trick of blending a transparent shape...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 24 Jan 2008 17:20:08 +0000 (17:20 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 24 Jan 2008 17:20:08 +0000 (17:20 +0000)
git-svn-id: http://svn.voria.com/code@1457 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/modules/mod_geometry/circle.cpp
synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp
synfig-core/trunk/src/synfig/layer_composite.cpp
synfig-core/trunk/src/synfig/layer_composite.h
synfig-core/trunk/src/synfig/layer_shape.cpp

index b5d59e2..cef640a 100644 (file)
@@ -73,7 +73,9 @@ Circle::Circle():
 bool
 Circle::ImportParameters(const String &param, const ValueBase &value)
 {
-       IMPORT(color);
+       IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) {
+                                       set_blend_method(Color::BLEND_ALPHA_OVER);
+                                       color.set_a(1); } else transparent_color_ = true; });
        IMPORT(radius);
        IMPORT(feather);
        IMPORT(invert);
index eea1a21..ab1be69 100644 (file)
@@ -87,7 +87,9 @@ Rectangle::Rectangle():
 bool
 Rectangle::set_param(const String & param, const ValueBase &value)
 {
-       IMPORT(color);
+       IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) {
+                                       set_blend_method(Color::BLEND_ALPHA_OVER);
+                                       color.set_a(1); } else transparent_color_ = true; });
        IMPORT(point1);
        IMPORT(point2);
        IMPORT(expand);
index 2cd6a17..16f2c33 100644 (file)
@@ -176,7 +176,16 @@ Layer_Composite::set_param(const String & param, const ValueBase &value)
                                                warning("loaded a version %s canvas with a 'Straight' blended PasteCanvas (%s) - check it renders OK",
                                                                version.c_str(), get_non_empty_description().c_str());
                                        else
+                                       {
                                                blend_method_ = Color::BLEND_COMPOSITE;
+                                               converted_blend_ = true;
+
+                                               // if this layer has a transparent color, go back and set the color again
+                                               // now that we know we are converting the blend method as well.  that will
+                                               // make the color non-transparent, and change the blend method to alpha over
+                                               if (transparent_color_)
+                                                       set_param("color", get_param("color"));
+                                       }
                        }
                }
        }
index 1db98e2..50aeeff 100644 (file)
@@ -60,9 +60,14 @@ protected:
                Color::BlendMethod      blend_method=Color::BLEND_COMPOSITE
        ):
                amount_                         (amount),
-               blend_method_           (blend_method)
+               blend_method_           (blend_method),
+               converted_blend_        (false),
+               transparent_color_      (false)
        { }
 
+       bool converted_blend_;
+       bool transparent_color_;
+
 public:
 
        float get_amount()const { return amount_; }
index 32dde4d..269eaf1 100644 (file)
@@ -1149,7 +1149,9 @@ Layer_Shape::clear()
 bool
 Layer_Shape::set_param(const String & param, const ValueBase &value)
 {
-       IMPORT(color);
+       IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) {
+                                       set_blend_method(Color::BLEND_ALPHA_OVER);
+                                       color.set_a(1); } else transparent_color_ = true; });
        IMPORT(offset);
        IMPORT(invert);
        IMPORT(antialias);