/* * This file is part of the KDE project * * Copyright (c) Michael Thaler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _KIS_CUBISM_FILTER_H_ #define _KIS_CUBISM_FILTER_H_ #include "kis_filter.h" #include "kis_filter_config_widget.h" #include class KisPolygon; class KisCubismFilterConfiguration : public KisFilterConfiguration { public: KisCubismFilterConfiguration(TQ_UINT32 tileSize, TQ_UINT32 tileSaturation) : KisFilterConfiguration( "cubism", 1 ) , m_tileSize(tileSize) , m_tileSaturation(tileSaturation) { setProperty("tileSize", tileSize); setProperty("tileSaturation", tileSaturation); }; public: inline TQ_UINT32 tileSize() { return getInt("tileSize"); }; inline TQ_UINT32 tileSaturation() {return getInt("tileSaturation"); }; private: TQ_UINT32 m_tileSize; TQ_UINT32 m_tileSaturation; }; class KisCubismFilter : public KisFilter { public: KisCubismFilter(); public: virtual void process(KisPaintDeviceSP,KisPaintDeviceSP, KisFilterConfiguration* , const TQRect&); static inline KisID id() { return KisID("cubism", i18n("Cubism")); }; virtual bool supportsPainting() { return false; } virtual bool supportsPreview() { return true; } virtual std::list listOfExamplesConfiguration(KisPaintDeviceSP ) { std::list list; list.insert(list.begin(), new KisCubismFilterConfiguration(10,10)); return list; } virtual bool workWith(KisColorSpace* cs); virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; }; public: virtual KisFilterConfigWidget * createConfigurationWidget(TQWidget* parent, KisPaintDeviceSP dev); virtual KisFilterConfiguration* configuration(TQWidget*); virtual KisFilterConfiguration* configuration() { return new KisCubismFilterConfiguration( 10, 10); }; private: //this function takes an array of ordered indices i1,i2,i3,... and randomizes them i3,i1,i2,... void randomizeIndices (TQ_INT32 count, TQ_INT32* indices); TQ_INT32 randomIntNumber(TQ_INT32 lowestNumber, TQ_INT32 highestNumber); double randomDoubleNumber(double lowestNumber, double highestNumber); double calcAlphaBlend(double *vec, double oneOverDist, double x, double y); void convertSegment(TQ_INT32 x1, TQ_INT32 y1, TQ_INT32 x2, TQ_INT32 y2, TQ_INT32 offset, TQ_INT32* min, TQ_INT32* max, TQ_INT32 xmin, TQ_INT32 xmax); void fillPolyColor(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisPolygon* poly, const TQ_UINT8* col, TQ_UINT8* dest, TQRect rect); void cubism(KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect& rect, TQ_UINT32 tileSize, TQ_UINT32 tileSaturation); }; #endif