File indexing completed on 2024-05-12 05:10:16

0001 #ifndef __BLITZ_H
0002 #define __BLITZ_H
0003 
0004 /*
0005  Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007
0006       Daniel M. Duley <daniel.duley@verizon.net>
0007  (C) 2004 Zack Rusin <zack@kde.org>
0008  (C) 2000 Josef Weidendorfer <weidendo@in.tum.de>
0009  (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
0010  (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
0011  (C) 1998, 1999 Dirk Mueller <mueller@kde.org>
0012 
0013 Redistribution and use in source and binary forms, with or without
0014 modification, are permitted provided that the following conditions
0015 are met:
0016 
0017 1. Redistributions of source code must retain the above copyright
0018    notice, this list of conditions and the following disclaimer.
0019 2. Redistributions in binary form must reproduce the above copyright
0020    notice, this list of conditions and the following disclaimer in the
0021    documentation and/or other materials provided with the distribution.
0022 
0023 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0024 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0025 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0026 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0027 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0028 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0029 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0030 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0032 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0033 
0034 */
0035 
0036 #include <QImage>
0037 
0038 namespace Tellico {
0039 
0040     enum GradientType {VerticalGradient=0, HorizontalGradient, DiagonalGradient,
0041         CrossDiagonalGradient, PyramidGradient, RectangleGradient,
0042         PipeCrossGradient, EllipticGradient};
0043 
0044     /**
0045      * Create a gradient from color a to color b of the specified type.
0046      *
0047      * @param size The desired size of the gradient.
0048      * @param ca Color a
0049      * @param cb Color b
0050      * @param type The type of gradient.
0051      * @return The gradient.
0052      */
0053     QImage gradient(QSize size, const QColor &ca,
0054                     const QColor &cb, GradientType type);
0055     /**
0056      * Creates an 8bit grayscale gradient suitable for use as an alpha channel
0057      * using QImage::setAlphaChannel().
0058      *
0059      * @param size The desired size of the gradient.
0060      * @param ca The grayscale start value.
0061      * @param cb The grayscale end value.
0062      * @param type The type of gradient.
0063      * @return The gradient.
0064      */
0065     QImage grayGradient(QSize size, unsigned char ca,
0066                         unsigned char cb, GradientType type);
0067     /**
0068      * Create an unbalanced gradient. An unbalanced gradient is a gradient
0069      * where the transition from color a to color b is not linear, but in this
0070      * case exponential.
0071      *
0072      * @param size The desired size of the gradient.
0073      * @param ca Color a
0074      * @param cb Color b
0075      * @param type The type of gradient.
0076      * @param xfactor The x decay length. Use a value between -200 and 200.
0077      * @param yfactor The y decay length.
0078      * @return The gradient.
0079      */
0080     QImage unbalancedGradient(QSize size, const QColor &ca,
0081                               const QColor &cb, GradientType type,
0082                               int xfactor=100, int yfactor=100);
0083     /**
0084      * Creates an 8bit grayscale gradient suitable for use as an alpha channel
0085      * using QImage::setAlphaChannel().
0086      *
0087      * @param size The desired size of the gradient.
0088      * @param type The type of gradient.
0089      * @param ca The grayscale start value.
0090      * @param cb The grayscale end value.
0091      * @param xfactor The x decay length. Use a value between -200 and 200.
0092      * @param yfactor The y decay length.
0093      * @return The gradient.
0094      */
0095     QImage grayUnbalancedGradient(QSize size, unsigned char ca,
0096                                   unsigned char cb, GradientType type,
0097                                   int xfactor=100, int yfactor=100);
0098 }
0099 
0100 #endif