SDK PLugin development - painting tool

A forum dedicated to George scripting questions
Post Reply
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

OK, so instead of calling TVExecute I call a single function of my own. I also changed the flags.
The undo problem is still there. When I press undo several times it changes the order of the layers. It doesn't know the user has made a brush stroke, because it the layer is updated by my code.
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

Would it be possible that you post again your last version of your code and the dll to test it please, as you do some modification.
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Sure, I think I fixed the flags problem. Im pretty busy these days so Im not working on it too much.

https://www.dropbox.com/s/umeauwo59ml02 ... plugin.rar
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Hi, a quick question. I want to duplicate a layer like the Layer:Duplicate Instances button do. Is there a script command or SDK function to do that?

Thanks.
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: SDK PLugin development - painting tool

Post by ZigOtto »

tv_LayerDuplicate name ...?
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

But it will duplicate the layer including its contents, no? I want the one the creates a layer with empty images. Maybe tv_layrDuplicate does that, Ill try
User avatar
Fabrice
Posts: 10077
Joined: 17 Jul 2007, 15:00
Contact:

Re: SDK PLugin development - painting tool

Post by Fabrice »

here is the detail of the tool :
Attachments
screenshot.jpg
Fabrice Debarge
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

I know that, but there is no george function in there only "key: ...." how do I do that in my plugin?
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: SDK PLugin development - painting tool

Post by ZigOtto »

oferk wrote:But it will duplicate the layer including its contents, no? I want the one the creates a layer with empty images. Maybe tv_layrDuplicate does that, Ill try
oh sorry, I missed the "empty images" part of your question ...
well, you can firstly duplicate the layer, then "Clear Heads" with this command :

Code: Select all

tv_cmd Layerheads tv_clear 0
User avatar
Fabrice
Posts: 10077
Joined: 17 Jul 2007, 15:00
Contact:

Re: SDK PLugin development - painting tool

Post by Fabrice »

Yes, this should do the job. thanks zig.
Fabrice Debarge
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

oferk wrote:Sure, I think I fixed the flags problem. Im pretty busy these days so Im not working on it too much.

https://www.dropbox.com/s/umeauwo59ml02 ... plugin.rar
So, I took a look at your code.
Could you try that:
_ when you want draw your brush in the PI_Msg function with

Code: Select all

for (int i = -brushSize; i < brushSize; ++i)
{
	for (int j = -brushSize; j < brushSize; ++j) 
	{
		int tmpX = MAX(x + i, 0);
		tmpX = MIN(tmpX, iFilter->ImageWidth);
		int tmpY = MAX(y + j, 0);
		tmpY = MIN(tmpY, iFilter->ImageHeight);
                    
		int index = tmpX + iFilter->ImageWidth*tmpY;
		iFilter->Current->Data[index].l = Data.mParams.color;
	}
}
TVWriteLayerData(iFilter, NULL, 0, 0, iFilter->ImageWidth, iFilter->ImageHeight, 0, CB_WRITE_UPDATE);
try to not use iFilter->Current and replace this stuff with something like this:

Code: Select all

PIPixel b[10*10];  //the brush of size 10*10
PIPixel c;
c.l = Data.mParams.color;

for( int i = 0; i < 10*10; i++ )
	b[i] = c;

TVWriteLayerData(iFilter, b, x-5, y-5, 10, 10, 0, CB_WRITE_UPDATE);
Does it solve the undo problem ?
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

yes! it works better! Great, thanks a lot. But it is not yet perfect. what happens now is the when I draw the first scribble I can undo it (because the plugin hasn't done anything). But after the second one the plugin does all his stuff, and then undoing causes weird things happen. I guess it is all because Im changing the current layer, and maybe writing to iFilter->Current in the end and this is wrong. I will continue to work on it.

What I would like to happen is that after the plugin paints and the user undos, only the last drawn scribble will be deleted, and the plugin will re-paint the image, but undoing the paint process doesn't make much sense.
I guess Im not clear enough but I need to think about this some more.

Here is a windows 32-bit binary:
https://www.dropbox.com/s/8hefp2hlrfpi7 ... ushTVP.dll" onclick="window.open(this.href);return false;
Thanks a lot!
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: SDK PLugin development - painting tool

Post by Mads Juul »

I just tried it out. But It dont seem to work at all.(Besides it of course makes TVPaint crash all the time and the undo is wrong). Is the purpose of this plugin to make a fill? And if it is possible for me to make it fill somehow how can I do this?
-Mads
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Ok, I will give you some instructions, but if it crashes and you can tell me what exactly you are doing it will be great and I will fix the issue.
Usage:
This plug-in is a fill tool, but it works differently then a paint bucket. It will always fill the whole image with at least two colors. you use it like this:
1. draw your image on a layer, lets assume you draw a circle.
2. create two new layers below the drawing layer (you can do so quickly with the create layers button i have added to the plugin, it will also color and name the layers, and select the middle layer for you)
3. select the middle layer, if it is not already selected.
4. Now you need to start drawing scribbles to mark regions of different colors in your drawing. You paint a scribble using the "Add Scribble" button, and then painting a stroke. Paint a red stroke inside the circle.
5. Nothing should happen, because the algorithm needs at least two scribbles to work, so choose a second color and paint another scribble outside of the circle. Now the algorithm should work and paint the whole image. The colors are written to the third, lowest layer.
6. Now, depending on your drawing, you can add more scribble in more regions and the plug in will re-calculate the result and write it to the third layer.

Basically you must have three layers, the top one with the drawing (alpha based, so if you scanned a drawing, clean it with Basic Scan Cleaner), the second one for drawing scribbles and the third one for the result.
The algorithm takes into account the amount of "paint" in a region relative to other colors in the region, so if you a small shape you want to color you need not worry to paint a little outside the lines as other bigger scribbles will over come it.

I tested this usage on 4 computers, so it should work. of course there are still bugs and crashes that I need to find and fix.
Thanks a lot.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: SDK PLugin development - painting tool

Post by Mads Juul »

Ok it works as you described. Is this the work flow for the final plugin?
It seems a little strange to me.
3 layers?
2 colors?
why not do a scribble on the outline layer and then the plugin would make a laxybrush fill on the layer below? with the current acolor?
or that is maybe the plan when this alpha version of the plugin is developed?
-Mads
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
Post Reply