[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/krita/plugins/paintops/sumie
From:       Lukáš Tvrdý <lukast.dev () gmail ! com>
Date:       2008-07-14 13:26:47
Message-ID: 1216042007.387344.13027.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 832355 by lukast:

Ink depletion through UI with KCurve works.

 M  +33 -10    brush.cpp  
 M  +3 -1      brush.h  
 M  +24 -5     kis_sumipaintop.cpp  
 M  +6 -3      kis_sumipaintop.h  
 M  +3 -3      wdgsumieoptions.ui  


--- trunk/koffice/krita/plugins/paintops/sumie/brush.cpp #832354:832355
@@ -25,10 +25,14 @@
 
 #include <QVariant>
 #include <QHash>
+#include <QList>
 
 #include "kis_random_accessor.h"
+#include "widgets/kcurve.h"
+
 #include <cmath>
 
+
 Brush::Brush(const BrushShape &initialShape, KoColor inkColor){
 	m_initialShape = initialShape;
 	m_inkColor = inkColor;	
@@ -46,7 +50,20 @@
 	srand48(1045);
 }
 
+void Brush::setInkDepletion(QList<float> *curveData){
+	int count = curveData->size();
 
+	for (int i = 0; i< count ;i++)
+	{
+		m_inkDepletion.append( curveData->at(i) );
+	}
+
+	dbgKrita << "size: " << curveData->size() ;
+	dbgKrita << "size depletion: " << m_inkDepletion.size() << endl;
+	delete curveData;
+	 // thank you
+}
+
 void Brush::paint(KisPaintDeviceSP dev, float x, float y,const KoColor &color){
 	/*if (m_counter == 1){
 		m_inkColor = color;
@@ -55,6 +72,7 @@
 	m_inkColor = color;
 
 	m_counter++;
+	
 	float decr = (m_counter*m_counter*m_counter)/1000000.0f;
 
 	Bristle *bristle;
@@ -69,23 +87,29 @@
 
 	QHash<QString, QVariant> params;
 
-	if (true){
-		params["h"] = 0.0;
+	double result;
+	if ( m_counter >= m_inkDepletion.size()-1 ){
+		result = m_inkDepletion[m_inkDepletion.size() - 1];
+	}else{
+		result = m_inkDepletion[m_counter];
+	}
 
-		double result = log (m_counter);
-		result = -(result * 10)/100.0;
-		params["s"] = result;
-		//dbgPlugins << "log (m_counter): "<< result << endl;
 
+	dbgPlugins << "result:" << result << endl;
+	dbgPlugins << "m_counter:" << m_counter << endl;
+		
+		params["h"] = 0.0;
+		params["s"] = -result;
 		params["v"] = 0.0;
+		
 
 		KoColorTransformation* transfo = dev->colorSpace()->createColorTransformation( \
"hsv_adjustment", params);  transfo->transform( m_inkColor.data(), m_inkColor.data(), \
1);  
-		int opacity = (1.0f+result)*255;
+		/*int opacity = (1.0f+result)*255;
 		dbgPlugins << "opacity: "<< opacity << endl;
-		m_inkColor.setOpacity(opacity);
-	}
+		m_inkColor.setOpacity(opacity);*/
+	
 
 	for (int i=0;i<m_bristles.size();i++){
 		bristle = &m_bristles[i];
@@ -128,5 +152,4 @@
 }
 
 Brush::~Brush(){
-
 }
--- trunk/koffice/krita/plugins/paintops/sumie/brush.h #832354:832355
@@ -20,6 +20,7 @@
 #define _BRUSH_H_
 
 #include <QVector>
+#include <QList>
 
 #include <KoColor.h>
 
@@ -35,15 +36,16 @@
 	~Brush();
 	Brush(KoColor inkColor, BrushShape shape);
 	void paint(KisPaintDeviceSP dev, float x, float y,const KoColor &color);
+	void setInkDepletion(QList<float> *curveData);
 
 
-
 private:
 	QVector<Bristle> m_bristles;
 	BrushShape m_initialShape;
 	KoColor m_inkColor;
 	int m_counter;
 	int m_radius;
+	QList<float> m_inkDepletion; // array
 
 };
 
--- trunk/koffice/krita/plugins/paintops/sumie/kis_sumipaintop.cpp #832354:832355
@@ -20,6 +20,7 @@
 #include <cmath>
 
 #include <QRect>
+#include <QList>
 #include <QColor>
 #include <QMutexLocker>
 
@@ -45,8 +46,10 @@
 
 KisPaintOp * KisSumiPaintOpFactory::createOp(const KisPaintOpSettingsSP settings, \
KisPainter * painter, KisImageSP image)  {
-    Q_UNUSED( settings );
-    KisPaintOp * op = new KisSumiPaintOp(painter, image);
+    const KisSumiPaintOpSettings *sumiSettings = dynamic_cast<const \
KisSumiPaintOpSettings *>(settings.data()); +    Q_ASSERT(settings == 0 || \
sumiSettings != 0); +
+	KisPaintOp * op = new KisSumiPaintOp(sumiSettings, painter, image);
     Q_CHECK_PTR(op);
     return op;
 }
@@ -77,6 +80,7 @@
 
     m_optionsWidget->setPopupWidget(m_popupWidget);
 
+
 }
 
 KisPaintOpSettingsSP KisSumiPaintOpSettings::clone() const
@@ -86,6 +90,19 @@
 
 }
 
+QList<float> * KisSumiPaintOpSettings::curve() const
+{
+	int curveSamples = 256;
+	QList<float> *result = new QList<float>;
+	for (int i=0; i < curveSamples ; i++)
+	{
+		result->append( (float)m_options->inkCurve->getCurveValue( i / \
(float)(curveSamples-1.0f) ) ); +	}
+	// have to be freed!!
+	return result;
+}
+
+
 void KisSumiPaintOpSettings::fromXML(const QDomElement&)
 {
     // XXX: save to xml. See for instance the color adjustment filters
@@ -98,12 +115,14 @@
 
 
 
-KisSumiPaintOp::KisSumiPaintOp(KisPainter * painter, KisImageSP image)
+KisSumiPaintOp::KisSumiPaintOp(const KisSumiPaintOpSettings *settings,KisPainter * \
painter, KisImageSP image)  : KisPaintOp(painter)
 {
-    dbgKrita << "START OF KisSumiPaintOp" << endl;
     newStrokeFlag = true;
     m_image = image;
+	
+	m_brush.setInkDepletion( settings->curve() );
+	// delete??
 }
 
 KisSumiPaintOp::~KisSumiPaintOp()
@@ -131,7 +150,7 @@
 	x1 = info.pos().x();
 	y1 = info.pos().y();
 
-	m_mybrush.paint(dab, x1, y1, painter()->paintColor() );
+	m_brush.paint(dab, x1, y1, painter()->paintColor() );
 
 	QRect rc = dab->extent();
 	painter()->bitBlt( rc.topLeft(), dab, rc );
--- trunk/koffice/krita/plugins/paintops/sumie/kis_sumipaintop.h #832354:832355
@@ -67,11 +67,14 @@
     virtual void fromXML(const QDomElement&);
     virtual void toXML(QDomDocument&, QDomElement&) const;
 
+	QList<float> * curve() const;
+
 private:
-
     Ui::WdgSumieOptions* m_options;
     KisPopupButton * m_optionsWidget;
     QWidget * m_popupWidget;
+
+	QList<QPointF> m_curveData;
 };
 
 
@@ -79,7 +82,7 @@
 
 public:
 
-    KisSumiPaintOp(KisPainter * painter, KisImageSP image);
+    KisSumiPaintOp(const KisSumiPaintOpSettings *settings, KisPainter * painter, \
KisImageSP image);  virtual ~KisSumiPaintOp();
 
     // Do we want to spray even when no movement?
@@ -97,7 +100,7 @@
     //Stroke stroke;
     KisPaintDeviceSP dab;
     QMutex m_mutex;
-    Brush m_mybrush;
+    Brush m_brush;
 };
 
 #endif // KIS_SUMIPAINTOP_H_
--- trunk/koffice/krita/plugins/paintops/sumie/wdgsumieoptions.ui #832354:832355
@@ -12,15 +12,15 @@
   <property name="windowTitle" >
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout" >
+  <layout class="QGridLayout" >
    <item row="0" column="0" >
     <widget class="QGroupBox" name="groupBox" >
      <property name="title" >
       <string>Ink Depletion Curve</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout_2" >
+     <layout class="QGridLayout" >
       <item row="0" column="0" >
-       <widget class="KCurve" native="1" name="widget" />
+       <widget class="KCurve" native="1" name="inkCurve" />
       </item>
      </layout>
     </widget>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic