"Not so basic" drawing application
-
^^ And how exactly is your post helpful? From the many images I posted you should have concluded I already have a commercial image editor. And how exactly will GIMP help me to draw lines with stencils in my application? And thanks for your suggestion but I have plenty more questions on this topic, but those will have to wait till tomorrow. Geez... hunt rank much?
Anyway, I was able to do it with interpolation, the following is an actual screenshot, but it is a primitive, quick and dirty way to interpolate, and it shows - the lines are quite jagged, nowhere nearly as smooth as those in the images above, which I made in photoshop, will have to do some optimization tomorrow.
!http://i39.tinypic.com/2ntabgm.png(final)! -
Perhaps you can study how Krita works? From wat I read in the past, it is quite advanced in terms of brush handling.
-
Reinventing the wheel is usually a bad idea, but looking at the source code for Krita all I find is method calls within method calls within method calls, never really reaching the actual drawing logic. The project is so vast it will probably take me less time to reinvent the wheel in that particular case...
Perhaps if someone here is familiar with the project can give me a few pointers on where to look...
As for reinventing the wheel, I do realize I am stepping out of Qt land into generic algorithms so I will take it elsewhere.
-
BTW, here is my interpolation logic, it is fairly primitive, but I ain't no programmer yet, and I do realize Qt might have a better API for this, so any recommendations are welcome!
@void Widget::drawLine()
{
QPointF point, drawPoint;
point = newPos - lastPos;
int length = point.manhattanLength();
double xInc, yInc;xInc = point.x() / length; yInc = point.y() / length; drawPoint = lastPos; for (int x=0; x < length; ++x) { drawPoint.setX(drawPoint.x()+xInc); drawPoint.setY(drawPoint.y()+yInc); drawToCanvas(drawPoint); }
}@
Edit: One optimization that comes to mind looking at the code now is use the rx and ry methods of QPoint that return references to use the += on and save the extra function call...