1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <basegfx/color/bcolormodifier.hxx>
22 //////////////////////////////////////////////////////////////////////////////
26 ::basegfx::BColor
BColorModifier::getModifiedColor(const ::basegfx::BColor
& aSourceColor
) const
30 case BCOLORMODIFYMODE_INTERPOLATE
:
32 return interpolate(maBColor
, aSourceColor
, mfValue
);
34 case BCOLORMODIFYMODE_GRAY
:
36 const double fLuminance(aSourceColor
.luminance());
37 return ::basegfx::BColor(fLuminance
, fLuminance
, fLuminance
);
39 case BCOLORMODIFYMODE_BLACKANDWHITE
:
41 const double fLuminance(aSourceColor
.luminance());
43 if(fLuminance
< mfValue
)
45 return ::basegfx::BColor::getEmptyBColor();
49 return ::basegfx::BColor(1.0, 1.0, 1.0);
52 case BCOLORMODIFYMODE_INVERT
:
54 return ::basegfx::BColor(1.0 - aSourceColor
.getRed(), 1.0 - aSourceColor
.getGreen(), 1.0 - aSourceColor
.getBlue());
56 case BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA
:
58 const double fAlpha(1.0 - ((aSourceColor
.getRed() * 0.2125) + (aSourceColor
.getGreen() * 0.7154) + (aSourceColor
.getBlue() * 0.0721)));
59 return ::basegfx::BColor(fAlpha
, fAlpha
, fAlpha
);
61 default : // BCOLORMODIFYMODE_REPLACE
67 } // end of namespace basegfx
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */