Grid + Assistant = Awesome Perspective Assistant

Been quiet some time since my last blog about Krita, well, I had been a bit busy with college work. Nonetheless, with whatever time I had, and all the help from Boud, I have been able to import a particular feature from the Perspective Grid to the Perspective Assistant.

A little background

Perspective Grid

The Perspective Grid(here on referred to as Grid, sounds very formal :-P ) is a grid for which all “parallel” lines intersect on a vanishing point. This helps the artist to create 3D effect on a 2D canvas, for example buildings or roads going upto the horizon.

Images are taken from Cyrille Berger’s blog about Perspective Grid

Perspective Grid in Krita

The grid acts as a guide for the artist to draw parallel lines on the canvas, using line tool or similar straight line tool.

Demo of the Perspective Grid

Demo of the Perspective Grid

 

Perspective Assistant

The Perspective Assistant(here on referred to as Assistant, still feels the same :-) ) is similar in looks to the Grid but unlike the Grid, with Assistant an artist can draw straight lines using the freehand tool too. This is achieved by checking the assistant checkbox after selecting the freehand tool.

A structure made using the assistants

A structure made using the assistants

On checking the “assistant” checkbox, the user can just draw on the grid and the assistant will itself draw the straight line with respect to the grid created.

I understood the working of both the Grid and the Assistant, but, what is the feature that is being talked about?

Well, that is easy to describe, the second figure above shows the side handles, in the middle of each side of the grid, these side handles can be dragged in the same way as the side handles to create new grids which extend the existing grid.

Why add a feature that already exists on one tool to another?

That is something one might ask, when he/she sees the grid and the assistant for the first time. But, on using them, one comes to know few points of important differences.

First of all, the Grids cannot be moved. Once created a Grid stays where it is till it is deleted. Secondly, new Grids cannot be created by themselves. A new grid can only be extended from an existing grid and stays that way till the end. Third and the last one that comes to my mind is that the handles in a Grid are fixed in reference, i.e. the handle which is on the top left corner can never be taken to a different location.

But in the Assistant all of this can be done, an Assistant can be moved, new assistants can be created out of the blue, the handles can change their locations, creating new shape of the grid with that change.

I am not saying that the Grid is a drawback. It was created with a different purpose and been here since a long time. But, the Assistant is just the upgrade on the base idea of the Grid.

What now?

What else? The Assistant now has these side handles and works really fine :D .

Perspective assistant showing the side handles at work

Perspective assistant showing the side handles at work

Although, now that I think of I should include technical details! I guess I will, but not now. Soon? definitely.

To all the artists, please use the new feature and give us your feedbacks wherever you want. My IRC nick is sraman on #krita, email id is sra392@gmail.com or even  here. Awaiting eagerly :-) .


Saving and Loading of Assistants

My first work in Krita was to add the feature of saving and loading of the Assistant tools. Krita has four Assistant tools – Ellipse, Spline, Perspective and Ruler. As their name suggest each Assistant is used to make an Assistant having shape of an ellipse, curve, quadrilateral grid and a line respectively. The purpose of these Assistants is to make a complex 3D mesh which can be painted on. Now, suppose someone has created a very complex structure of these assistants, but, has to shutdown his/her computer, (s)he would loose all the created assistants as there was no implementation of saving the Assistants. Here, is where my work came in.

THE NEED

A structure made using the assistants

As it can be seen in the above image, the structure is a half completed scene illustrating the use of the assistants in showing of depth in a 2D canvas. And this structure is also very time consuming and also something that can be reused. Thus, the saving of one’s work at such a stage is very vital requiring for the need to implement the saving of the same.

THE WORK

Even if all the assistants have a very different structure compared to each other, they all have common attributes. All the assistants have handles(the circles on each assistant in the image above)which give the individual assistants their shape and have only x-coordinates and y-coordinates as their attributes and type, which tells the program which type of assistant is being created.

Saving

Saving of assistants their important attributes had to be saved. Each assistant has the Type and Handles as its attribute. So, in order to save the assistants these attributes had to be saved. “How to save the assistants so that it is easy to load them back?” One big question which made me change my implementation of saving around three times. Well, now the assistants are saved in the following manner:

File structure

Following are the modifications which are done in the end of file/folder structure for saving of the assistants.

  1.  There is a list of assistants in the maindoc.xml  file which tells the program the type of the assistants and the filenames  in which the assistants are saved. The list has a n xml style formatting.
  2. Whenever there is at least an assistant to be saved, the program creates a new folder called “assistants” inside the folder having the name same as the name of the created document. Inside this folder are the files with the filenames as given in the list in maindoc.xml. These files individually contain the information of an assistant of the type as described in the list. The name of these files are of the form ‘typecount.assistant’ where count is between 0 and n-1(n = total number of that type of assistant), for e.g. ellipse0.assistant, ellipse1.assistant, perspective0.assistant, etc.
  3. Now, these files store data of an assistant each. These files also have xml format. they store the type and handles, where each handle then stores attributes like handle id(for using in shared pointer), x-coordinate and y-coordinate.

Process

Now, the whole process of saving of the assistants is done in a systematic manner.

First, the list of assistants is stored in the maindoc.xml and then the assistants are saved in their respecitve files.

Loading

Because of the way assistants are saved, the loading part was rather simpler to implement.

First, the list of assistants is fetched from the maindoc.xml and stored in a QMap of filename -> type.

Second, The blank assistants are created on basis of the type using the Factory and once created the assistant is given its handles and inserted into a Qlist.

Finally, the Assistants are added to the Manager which is at last set to visible, making it possible to see the saved assistants.

Well, that is how the current implementation of the saving and loading of assistants is done and I have a request the wonderful artists who use Krita to use the assistants and help in making them better by the day.

CHEERS!


The start with Krita

Krita is a painting and sketching program by KDE. It is a part of the Calligra Suite, and offers an end–to–end solution for creating digital painting files from scratch by masters. 

Well my journey with Krita began when I first heard about it from my friends, who had done SoK last year. And, I was mesmerized by the sketches of david revoy. It was then that I wanted to contribute to Krita and help in its being a great digital painting tool, although it still is great!! :)

Google Summer of Code and Krita


This year for GSoC, I had selected a project in Krita from the KDE ideas pagePerspective Drawing.  Following are a few details of the same:

Brief description:

Krita is a 2D painting tool, but artists often need to give the illusion of depth. Krita has two tools to help the user draw perspective correctly: the perspective grid and the perspective assistant. The latter is more advanced, but needs improvements to become a real star feature. It needs to be expanded by allowing real 3D objects to be important and put into perspective. This means rotation, setting the vanishing point, scaling, and then integration with the paint tools. At the same time, to get into the codebase, the student should implement other missing features in the perspective assistant.[1]

Details of the work:

In this project the perspective assistant has to get all the functionality in the perspective grid. That is just a part of the project, the majority of the time is to be devoted to creating an import function, such that a blender mesh can be imported. Now, this mesh should also be modifiable, that is, it can be rotated, scaled etc and then the mesh can be used in a similar way as the perspective assistant. The proper details of the timeline of the work have been provided in my proposal.


Follow

Get every new post delivered to your Inbox.

Join 816 other followers

%d bloggers like this: