File indexing completed on 2024-05-12 15:58:45
0001 /* 0002 * SPDX-License-Identifier: GPL-3.0-or-later 0003 */ 0004 0005 #ifndef KIS_TIMING_INFORMATION_H 0006 #define KIS_TIMING_INFORMATION_H 0007 0008 #include "kritaimage_export.h" 0009 0010 /** 0011 * A time in milliseconds that is assumed to be longer than any stroke (or other paint operation) 0012 * will ever last. This is used instead of infinity to avoid potential errors. The value is 0013 * approximately ten years. 0014 */ 0015 const qreal LONG_TIME = 320000000000.0; 0016 0017 /** 0018 * Contains information about timing settings in a stroke (mainly for airbrushing effects). The 0019 * timing settings may be different at different parts of a stroke, e.g. if the airbrush rate is 0020 * linked to pressure; a KisTimingInformation represents the effective timing at a single specific 0021 * part of a stroke. 0022 */ 0023 class KRITAIMAGE_EXPORT KisTimingInformation 0024 { 0025 public: 0026 0027 /** Makes a KisTimingInformation with timed spacing disabled. */ 0028 explicit KisTimingInformation() 0029 : m_timedSpacingEnabled(false) 0030 , m_timedSpacingInterval(LONG_TIME) 0031 { 0032 } 0033 0034 /** 0035 * Makes a KisTimingInformation with timed spacing enabled, using the specified interval in 0036 * milliseconds. 0037 */ 0038 explicit KisTimingInformation(qreal interval) 0039 : m_timedSpacingEnabled(true) 0040 , m_timedSpacingInterval(interval) 0041 { 0042 } 0043 0044 /** 0045 * @return True if and only if time-based spacing is enabled. 0046 */ 0047 inline bool isTimedSpacingEnabled() const { 0048 return m_timedSpacingEnabled; 0049 } 0050 0051 /** 0052 * @return The desired maximum amount of time between dabs, in milliseconds. Returns LONG_TIME 0053 * if time-based spacing is disabled. 0054 */ 0055 inline qreal timedSpacingInterval() const { 0056 return isTimedSpacingEnabled() ? 0057 m_timedSpacingInterval : 0058 LONG_TIME; 0059 } 0060 0061 private: 0062 // Time-interval-based spacing 0063 bool m_timedSpacingEnabled; 0064 qreal m_timedSpacingInterval; 0065 }; 0066 0067 #endif // KIS_TIMING_INFORMATION_H