Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-21 Thread Martin Renold
On Sun, Jan 20, 2013 at 09:28:19PM +0100, Jon Nordby wrote:
 Also, I _believe_ that the correct thing to do is to new_stroke() on
 button/tablet down to start a stroke, then reset() on button/tablet up
 to finish it.
 Martin, does that sound right? If so, perhaps we should rename reset()
 to end_stroke()?

No! Not at all. The intention is that you feed all motion events into
brushlib, and never explicitely start or end a stroke.

I made it that way for wacom tablets, of course, which can sense motion even
when you hover a bit above the surface.  Some things won't work if you
cannot get motion events between the strokes.  MyPaint doesn't like such
devices at all, see https://gna.org/bugs/?13622 (ghost lines) for details.

Of course, when you have such a device, you need such workarounds. If
anything, we should add more explicit support for the required workarounds
and clearly document what problems that they introduce, and why you should
try hard to avoid them if you can.

When you call reset(), then you reset the state of the motion and direction
filters (and probably others, too).  This will cause the brush to forget in
what direction you were moving and how fast.  The next motion event will
completely surprise you.

This is quite bad, especially at the start of a stroke, when you e.g. have a
flat brush that follows your motion direction - it will not know what
direction to start with.  You can only hope that the user doesn't increase
pressure too fast, so you have a chance to initialize the direction filter
before the brush dabs start becoming opaque.  (Or you start with a round
brush dab instead of an elliptical ones. I think most brushes react to an
uncertain direction that way.)

Also, there are (were?) some brushes that make heavy use of the gross speed
filter with a very large time constant, to change the radius when you
linger in the same area (e.g to work on details), but slow enough that you
have time to notice the change as it happens.

For example, such a brush allows you to change the radius temporariliy, for
couple of seconds, just by hovering forth and back with the stylus and then
painting.  If you call reset() before every stroke, well, you have a
completely different brush, because every stroke starts by assuming that you
were holding the pen completely still during the last 5 minutes.

-- 
Martin Renold

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-21 Thread Sebastien Leon
Hi Martin,

Thanks for the technical clarifications.
That's welcome as I have to fully understand the internal process if I
want to correctly optimize it in my graphic pipeline.
I also have to check that Qt is compatible with such pressureless
events. (we already know that the event has no date)

Thanks for the clarifications about the files too.

Best Regards

Sebastien

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-20 Thread Jon Nordby
On 19 January 2013 20:50, Sebastien Leon sl...@pointcarre.com wrote:
 For now, I had to include these 4 GPL files : brushmodes.cpp/.h and
 mypaint-tiled-surface.cpp/.h.
 Note for anyone who would like to include this code into a proprietary
 project : these 2 files are GPL and as long as you keep them in this
 mini-project, the whole project is GPL and can not be include into a
 proprietary project. (I should write some replacement for these files as
 a next step - unless their license is modified)

You are absolutely right. It was my intent that this code also would
become ISC as the rest when I moved it to brushlib/ (from lib/). 90%+
of the copyright belongs to Martin and me, smaller contributions have
come from 4 others. I have now sent an email to all the
copyright-holders of these files to check whether such relicensing is
OK.

-- 
Jon Nordby - www.jonnor.com

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-20 Thread Sebastien Leon
Hi Jon,

 However, the links both return The website you were trying to reach
 is temporarily unavailable. right now :(

Argh ! One of my TikiWiki site had a security breach and had been hacked
and Hostmonster simply disabled the whole websites without even
informing me !
You can temporarely download the zip file here :

http://download.pointcarre.com/mypaint/LibMyPaintDemo.zip

Note that this is a very first attempt and I really need a lot of help
to provide something useful for anyone who may use libmypaint ! And your
advises are very welcome :-)

 It was my intent that this code also would become ISC [...]
 I have now sent an email to all the copyright-holders of these
 files to check whether such relicensing is OK.

This is good news because the 15 bpp format seems quite required to
render correctly the dab (8 bits format shows a lot of posterization).
So it make sense to provide a basic 15 bpp surface + the draw dab
algorithm with the library.
I'm quite sure I will rewrite it for my own purpose, but for the demo
project it is cool !

We'll meet in FOSDEM. As Boudewijn said, a libre graphics meeting would
be the place to go (more details later).

Regards

Seb

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-20 Thread Jon Nordby
On 20 January 2013 19:52, Sebastien Leon sl...@pointcarre.com wrote:
 You can temporarely download the zip file here :

 http://download.pointcarre.com/mypaint/LibMyPaintDemo.zip

 Note that this is a very first attempt and I really need a lot of help
 to provide something useful for anyone who may use libmypaint ! And your
 advises are very welcome :-)

Thanks. Looking though it, it seems that you based this code on an
older version of libmypaint, before MyPaint 1.1? The API for
fetch/update tile is a bit different now, in order to allow
multithreading without locking.
Also, you seem to have renamed every .c file to .cpp? Why?

Some hints for the issues you have listed in the README and in the code.

In order for caching and deferred processing to work correctly, you
must call mypaint_surface_begin_atomic() before doing
mypaint_brush_stroke_to(), and mypaint_surface_end_atomic() when done.
With libmypaint 1.1 and git, nothing will happen if you don't as
everything is done on end_atomic()

To set color, convert RGB to HSV and do (values are float):
mypaint_brush_set_base_value(brush, MYPAINT_BRUSH_SETTING_COLOR_H, h);
mypaint_brush_set_base_value(brush, MYPAINT_BRUSH_SETTING_COLOR_S, s);
mypaint_brush_set_base_value(brush, MYPAINT_BRUSH_SETTING_COLOR_V, v);

All other brush settings, from dab size, hardness, opacity to speed
filters and alpha-locking are manipulated the same way.

Another thing is that the delta-time calculation should normally be
done from the input events you get from your windowing system, to not
be dependent on CPU load. But it seems Qt does not expose that!?

Also, I _believe_ that the correct thing to do is to new_stroke() on
button/tablet down to start a stroke, then reset() on button/tablet up
to finish it.
Martin, does that sound right? If so, perhaps we should rename reset()
to end_stroke()?

 It was my intent that this code also would become ISC [...]
 I have now sent an email to all the copyright-holders of these
 files to check whether such relicensing is OK.

 This is good news because the 15 bpp format seems quite required to
 render correctly the dab (8 bits format shows a lot of posterization).
 So it make sense to provide a basic 15 bpp surface + the draw dab
 algorithm with the library.
 I'm quite sure I will rewrite it for my own purpose, but for the demo
 project it is cool !
Yes, at least one needs more than 8bpc. Floating point would also do
fine of course. All in all, the renderer we have in MyPaint is pretty
good and I think it would be great if others could just use that
instead of having to implement their own.

-- 
Jon Nordby - www.jonnor.com

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-20 Thread Sebastien Leon
Hi Jon,

 Looking though it, it seems that you based this code on an older
 version of libmypaint, before MyPaint 1.1?

Checked the tar.gz from which I extracted the files and it seems it is
Version 1.0.0. I remember I started to look at this code some time
ago, unfortunately I had no time work on it seriously... And I forget to
update to the latest version when I started again to work on it...

 Also, you seem to have renamed every .c file to .cpp? Why?

Oops... I did that month ago as a turn around against some no-brain MSVC
issue and forget to remove this file extension modification...

As you suggest, I'll get the latest version (keeping the correct
extensions) and will use the correct API (begin/end atomic).

Thanks for the info about the brush color and other settings ! Looks
obvious now that you say it...

 Another thing is that the delta-time calculation should normally be
done from the
 input events you get from your windowing system, to not be dependent
on CPU
 load. But it seems Qt does not expose that!?

Digging into QInputEvent and QEvent and did not find any time information.
However, I think I can find some turn-around (no fully efficient but
should be ok)
From the mouse/tablet events, I do not raise any synchronous repaint
event. Update() send an asynchronous event which is processed when idle
(it could be an issue too as the user could have some step by step
renderer. I'll make some tests and let you know)
So, it may not be as bad as it looks... draw_dab could even being done
by another thread/CPU.
In the demo app, I will not try any advanced technics but in my
application, I already have a drawing mode which is fast (and dirty)
and a mouse released event which is drawing everything very accurately
(in a second time).

I could eventually hack Qt or ask for such feature in main tree. (but I
doubt that Digia or qt-project will want to modifiy QEvent prototype)

 Also, I _believe_ that the correct thing to do is to new_stroke() on
button/tablet down
 to start a stroke, then reset() on button/tablet up to finish it.

Ok. Sounds logical as I had some weird behavior with my code. Something
was missing...

I should update to the latest version and fix all these issues and come
back to you in few hours...

Thanks again for your feed-back  your help.

Seb


___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-19 Thread Boudewijn Rempt
On Friday 18 January 2013 Jan, Sebastien Leon wrote:
 Hi,
 
 I wrote this basic demo of libMyPaint as a small mini project (using Qt
 4.8).
 It is far from being complete but I think it is a good start...
 I obviously need some help to improve it and make it useful for other
 guys like me who would like to use libMyPaint in their application...
 (Qt code is very simple, so it could be easily ported to other toolkits)
 
 No need to say that any feed-back and advise are very welcome ! (for an
 example, TabletPen is coded but I do not have one for now...)
 
 You can download the mini-project here :
 http://sebastienleon.com/info/libmypaint/Demo.zip
 
 Here is a screenshot of it :
 http://sebastienleon.com/info/libmypaint/Demo.png
 
 Have a look to the README file for details...

Looks interesting -- I'm looking into libmypaint for inclusion in Krita as well 
(as a hobby project) so I got your zipfile. I've got a compile error in the 
c-jason library ,though, which I didn't look into yet:


gcc -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG 
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. 
-I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -IminiQtProject 
-Ilibmypaint -Ic-json -IminiQtProject/temp/moc -o 
miniQtProject/temp/obj/json_object.o c-json/json_object.c
c-json/json_object.c: In function ‘json_object_boolean_to_json_string’:
c-json/json_object.c:338:16: warning: unused parameter ‘level’ 
[-Wunused-parameter]
c-json/json_object.c:339:13: warning: unused parameter ‘flags’ 
[-Wunused-parameter]
c-json/json_object.c: In function ‘json_object_int_to_json_string’:
c-json/json_object.c:379:27: error: expected ‘)’ before ‘PRId64’
c-json/json_object.c:374:63: warning: unused parameter ‘jso’ 
[-Wunused-parameter]
c-json/json_object.c:376:12: warning: unused parameter ‘level’ 
[-Wunused-parameter]
c-json/json_object.c:377:12: warning: unused parameter ‘flags’ 
[-Wunused-parameter]
c-json/json_object.c: In function ‘json_object_get_int’:
c-json/json_object.c:415:16: error: ‘INT32_MIN’ undeclared (first use in this 
function)
c-json/json_object.c:415:16: note: each undeclared identifier is reported only 
once for each function it appears in
c-json/json_object.c:417:21: error: ‘INT32_MAX’ undeclared (first use in this 
function)
c-json/json_object.c: In function ‘json_object_double_to_json_string’:
c-json/json_object.c:463:15: warning: unused parameter ‘level’ 
[-Wunused-parameter]
c-json/json_object.c:464:12: warning: unused parameter ‘flags’ 
[-Wunused-parameter]
c-json/json_object.c: In function ‘json_object_string_to_json_string’:
c-json/json_object.c:502:15: warning: unused parameter ‘level’ 
[-Wunused-parameter]
c-json/json_object.c:503:12: warning: unused parameter ‘flags’ 
[-Wunused-parameter]
make: *** [miniQtProject/temp/obj/json_object.o] Error 1

 
 Best regards !
 
 PS : Any  unofficial MyPaint dev meeting at FOSDEM :-) ? Some of you
 guys are coming ?
 

I'll be at fosdem on Saturday, not sure where exactly, except that it won't be 
at the presentations. I've got a couple of meetings. The people from the libre 
graphics meeting should be at fosdem as well.

-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-19 Thread Martin Renold
On Fri, Jan 18, 2013 at 10:49:28PM +0100, Sebastien Leon wrote:
 I wrote this basic demo of libMyPaint as a small mini project (using Qt
 4.8).

Nice work! This reminds me of MyPaint version 0.1.
To save the image, press PrintScr ;-)

 Here is a screenshot of it :
 http://sebastienleon.com/info/libmypaint/Demo.png

Just a comment on brush quality. You can clearly see banding (posterization)
on this screenshot.  This will happen on a surface with only 8 bits per
channel with some MyPaint brushes.  Usually those with very narrow spacing
(many of the watercolor and smudge style brushes).

To avoid this, you can decrease the dabs per basic radius setting of those
brushes a bit, or stick to brushes that don't have a high value there, or
you could hide the problem with dithering (as MyPaint 0.5 did, see
http://mypaint.intilinux.com/?p=19) or simply switch to a higher bit depth.

-- 
Martin Renold

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-19 Thread Martin Renold
On Sat, Jan 19, 2013 at 09:44:11AM +0100, Martin Renold wrote:
 On Fri, Jan 18, 2013 at 10:49:28PM +0100, Sebastien Leon wrote:
 
  Here is a screenshot of it :
  http://sebastienleon.com/info/libmypaint/Demo.png
 
 Just a comment on brush quality. You can clearly see banding (posterization)
 on this screenshot.

Oh well, I just realized you saved this as indexed PNG, so maybe it looked a
lot better on your screen :-)

-- 
Martin Renold

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-19 Thread Sebastien Leon
Hi Martin,

 Oh well, I just realized you saved this as indexed PNG, so maybe it
looked a lot
 better on your screen :-)

Yes ;-) Actually I'm a sort of file size freak and I usually reduce
images depth to make them as small as possible...

But thanks for your link ! Actually last week, I read it when I was
looking for some information about your uint16_t format.
Considering the way the dabs are rendered, I also choosed to use a 15
bits render too in my little demo program.

The other reason is I did not rewrite the draw_dab function you wrote
and use it in the small demo.
My README.txt points it out :
--
For now, I had to include these 4 GPL files : brushmodes.cpp/.h and
mypaint-tiled-surface.cpp/.h.
Note for anyone who would like to include this code into a proprietary
project : these 2 files are GPL and as long as you keep them in this
mini-project, the whole project is GPL and can not be include into a
proprietary project. (I should write some replacement for these files as
a next step - unless their license is modified)
--

This 15 bits format seems interesting. I'm considering it for my own
internal surface. Is it the same than Krita uses ?

Best regards !

Seb


___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


Re: [Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-19 Thread Boudewijn Rempt
On Saturday 19 January 2013 Jan, Sebastien Leon wrote:
 This 15 bits format seems interesting. I'm considering it for my own
 internal surface. Is it the same than Krita uses ?

No -- krita's internal format is whatever the user chooses, 8 or 16 bit 
integer, 16 or 32 bit floating point.

-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss


[Mypaint-discuss] First attempt of a libMyPaint demo app...

2013-01-18 Thread Sebastien Leon
Hi,

I wrote this basic demo of libMyPaint as a small mini project (using Qt
4.8).
It is far from being complete but I think it is a good start...
I obviously need some help to improve it and make it useful for other
guys like me who would like to use libMyPaint in their application...
(Qt code is very simple, so it could be easily ported to other toolkits)

No need to say that any feed-back and advise are very welcome ! (for an
example, TabletPen is coded but I do not have one for now...)

You can download the mini-project here :
http://sebastienleon.com/info/libmypaint/Demo.zip

Here is a screenshot of it :
http://sebastienleon.com/info/libmypaint/Demo.png

Have a look to the README file for details...

Best regards !

PS : Any  unofficial MyPaint dev meeting at FOSDEM :-) ? Some of you
guys are coming ?

Sébastien

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss