1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX 25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 29 #include <drawinglayer/attribute/fillgradientattribute.hxx> 30 31 ////////////////////////////////////////////////////////////////////////////// 32 // predefines 33 34 namespace basegfx { class B2DPolygon; } 35 36 ////////////////////////////////////////////////////////////////////////////// 37 // FillGradientPrimitive2D class 38 39 namespace drawinglayer 40 { 41 namespace primitive2d 42 { 43 /** FillGradientPrimitive2D class 44 45 This class defines a gradient filling for a rectangular area. The 46 Range is defined by the Transformation, the gradient by the FillGradientAttribute. 47 48 The decomposition will deliver the decomposed gradient, e.g. for an ellipse 49 gradient the various ellipses in various color steps will be created. 50 51 I have added functionality to create both versions of filled decompositions: 52 Those who overlap and non-overlapping ones. The overlapping version is the 53 default one since it works with and without AntiAliasing. The non-overlapping 54 version is used in the MetafilePrimitive2D decomposition when the old XOR 55 paint was recorded. 56 */ 57 class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D 58 { 59 private: 60 /// the geometric definition 61 basegfx::B2DRange maObjectRange; 62 63 /// the gradient definition 64 attribute::FillGradientAttribute maFillGradient; 65 66 /// local helpers 67 void generateMatricesAndColors( 68 std::vector< basegfx::B2DHomMatrix >& rMatrices, 69 std::vector< basegfx::BColor >& rColors) const; 70 Primitive2DSequence createOverlappingFill( 71 const std::vector< basegfx::B2DHomMatrix >& rMatrices, 72 const std::vector< basegfx::BColor >& rColors, 73 const basegfx::B2DPolygon& rUnitPolygon) const; 74 Primitive2DSequence createNonOverlappingFill( 75 const std::vector< basegfx::B2DHomMatrix >& rMatrices, 76 const std::vector< basegfx::BColor >& rColors, 77 const basegfx::B2DPolygon& rUnitPolygon) const; 78 79 protected: 80 /// local helper 81 Primitive2DSequence createFill(bool bOverlapping) const; 82 83 /// local decomposition. 84 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 85 86 public: 87 /// constructor 88 FillGradientPrimitive2D( 89 const basegfx::B2DRange& rObjectRange, 90 const attribute::FillGradientAttribute& rFillGradient); 91 92 /// data read access 93 const basegfx::B2DRange& getObjectRange() const { return maObjectRange; } 94 const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } 95 96 /// compare operator 97 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 98 99 /// get range 100 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; 101 102 /// provide unique ID 103 DeclPrimitrive2DIDBlock() 104 }; 105 } // end of namespace primitive2d 106 } // end of namespace drawinglayer 107 108 ////////////////////////////////////////////////////////////////////////////// 109 110 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX 111 112 ////////////////////////////////////////////////////////////////////////////// 113 // eof 114