KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wetphysicsfilter.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * This file is part of Chalk
  3. *
  4. * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef WET_PHYSICS_FILTER_H
  21. #define WET_PHYSICS_FILTER_H
  22. #include <tdelocale.h>
  23. #include <kis_filter.h>
  24. #include <kis_types.h>
  25. #include "kis_wet_colorspace.h"
  26. class KisID;
  27. class TQRect;
  28. /**
  29. * The wet physics filter must be run regularly from a timer
  30. * or preferably from a thread. Every time the filter is processed
  31. * the paint flows; every third time, the paint is adsorbed unto the
  32. * lower pixel and dried.
  33. *
  34. * Note: this might also be implemented as three separate filters.
  35. * That might even be better.
  36. */
  37. class WetPhysicsFilter: public KisFilter
  38. {
  39. public:
  40. WetPhysicsFilter();
  41. public:
  42. virtual void process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration*, const TQRect& r);
  43. static inline KisID id() { return KisID("wetphysics", i18n("Watercolor Physics Simulation Filter")); };
  44. virtual bool supportsPainting() { return false; }
  45. virtual bool supportsPreview() { return false; }
  46. virtual ColorSpaceIndependence colorSpaceIndependence() { return FULLY_INDEPENDENT; };
  47. virtual bool workWith(KisColorSpace* cs) { return (cs->id() == KisID("WET")); };
  48. private:
  49. void flow(KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect & r);
  50. void dry(KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect & r);
  51. // Move stuff from the upperlayer to the lower layer. This is filter-level stuff.
  52. void adsorb(KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect & r);
  53. // NOTE: this does not set the height fields
  54. void combinePixels (WetPixDbl *dst, WetPixDbl *src1, WetPixDbl *src2);
  55. void dilutePixel (WetPixDbl *dst, WetPix *src, double dilution);
  56. void reducePixel (WetPixDbl *dst, WetPix *src, double dilution);
  57. /*
  58. * Allows visualization of adsorption by rotating the hue 120 degrees
  59. * layer-merge combining. src1 is the top layer
  60. *
  61. * This does not set the dst h or w fields.
  62. */
  63. void mergePixel (WetPixDbl *dst, WetPixDbl *src1, double dilution1, WetPixDbl *src2);
  64. private:
  65. TQ_INT32 m_adsorbCount;
  66. };
  67. #endif