Things you can improve/add in Pencil2d

I had some problems using the polyline tool but glad you fixed that in the newer version of pencil2d. Other things I wish to be improved

1.Text tool-I can’t really replicate text well with the pen tool and doing so is time consuming so if you add a text tool, it would be good.

  1. Degrading quality when rotating a selection made with the brush or ink unless you use the pencil tool (not so obvious so you may have too zoom in to see the issue) Screenshot (68).png - Google Drive
  2. Degrading quality when resizing a selection made with the brush or ink tool unless it’s the pencil tool

@wachamcaulit Hey. Thanks for taking the time to comment. Let me answer in order:

  1. Developers are aware of users asking for such tool, but until more critical issues or features are finalized, this won’t be implemented just yet so I can’t give you an ETA unfortunately.
  2. This is also a known issue, or rather a lack of capability that was never thought through by the original developers (who are no longer with us).

    Pencil2D doesn’t have image processing algorithms like photoshop or krita, so rotating a drawing is done mathematically (every program does this) however once it’s rotated the quality will never be the same because you are literally pushing the pixels to a new position, so other apps apply image processing algos to fake the image and show it as if it was new.

    Having such processing is a difficult task, so while it is important in the long run, right now no one can implement this; we’ll have to wait.
  3. Same as point number #2 Up-sizing or up-scaling will degrade the image because one is literally trying to fill an area that had more (empty) pixels than the pixels in the drawing, with the same amount of information found in your selected drawing, so it will blur and try to cope. Image processing is needed again to guess and fill these pixels so it matches the original picture as best as possible, but it will never be perfect, not even in photoshop.

So in summary getting any of these will take time. In general you should draw in the final size output for your video to avoid resizing, and for exceptional cases where you really need to up-scale a drawing, use a third party app like krita, gimp, firealpaca or photoshop to do it and then copy & paste the drawing into Pencil2D. Same with text.

Here’s a private video I did to showcase how to copy between Pencil2D and other apps easily so you don’t need to import images all the time you change a little thing.

FYI you can also copy / paste text:

Obviously this is just a workaround meanwhile Pencil2D get’s stronger :muscle:

1 Like

Let me clear something up. Rotating and scaling up a bitmap will always result in a perceived quality loss. In the case of upscaling bitmaps, by making the image larger you need to show more data than was initially captured. Consider this picture where the information in the middle of the image is missing:

Now as a human with lots of experience in seeing pictures and real world objects, you might be able to recognize that these are some red rocks and could imagine the missing area filled in with more red rocks. We are just getting to the point where computers are capable of this sort of content aware fill, but right now the best algorithms usually end up looking something like this:

Now you may be thinking, “oh but I could fill it in more correctly in my mind”, and you’d likely be wrong. Take a moment to clearly visualize what you think is in the missing area, then click this link to see what it actually is:

Real photo

Were you right? No you weren’t because not you, not the most sophisticated supercomputer in the world, not anybody, can know for certain what that missing information is unless it’s recorded somewhere. In the context of scaling a bitmap image, it is the exact same scenario, but on a much smaller scale. The black missing area of data we don’t know is the color between individual pixels (or more accurately the color distribution within a single pixel). Again we can’t just magically know this information. We can record the strokes and then redraw them to create this information, this is what vectors do, but bitmaps by there very definition don’t contain any information about how they were created, they are just a grid of pixels. How Pencil2D, and virtually any other software than has image scaling capabilities does this is through a process known as interpolation. To simplify, it’s like it blends adjacent pixels to guess at what the color is between them. If it sees a black and a white pixel next to each other, it says the value is probably gray. Yellow and red? How about orange inbetween then. Et cetera. It’s really doing this with some relatively basic mathematical formulas. Some programs (not Pencil2D) offer the option of using different formulas which will typically result in only very slight differences in the actual result. We do plan on adding this option eventually as it can be useful for certain use-cases (particularly pixel art).

As for rotating a bitmap, the underlying problem is the exact same that the distribution of colors within an individual pixel is unknown and unknowable. However it can be more helpful to think of it with a different example. Consider this enlarged version of a 3x3 pixel image: 3 by 3 grid of white and gray squares with a red square in the middle

Now imagine trying to rotate this red square by 45 degrees. Something like this: The same image but with the red square rotated 45 degrees

However, there are two problems with this:

  1. You can only change the color of the 9 pixels/squares. Those red points sticking into the adjacent squares cannot be represented like that because you can’t you can’t draw or store part of a pixel in a bitmap. You screen is made up of a very tiny grid of pixels, which are square, not triangles, not whatever shape you want it to be, just squares.
  2. Even if you could represent the square fully as you can see there is potentially content underneath it which is not known.

The second issue is handled by most programs by assuming the underlying content is transparent or that it is some predefined background color. The first issue is handled by interpolation again. So the second pixel on the top of our example is mostly white with a little bit of red poking up on the bottom, so perhaps it would be best approximated by a white pixel with a little bit of pink to it. When you do this interpolation for every pixel, you get something like this: The same image but with the pixels directly adjacent to the red square having a slightly pinkish hue.

Now does this look like it’s been rotated 45 degrees? No not really, but it’s the best that can be done when effectively trying to shove diamonds into square holes.

More importantly, consider what happens if we rotate this image 45 degrees again. In an ideal world, the result would look exactly the same as the original image because a square rotated by 45+45 degrees would be the same square. However, the information about the square’s rotation, and what parts of the white pixels have are red has already been lost, and all the computer sees is gray pixels, pink pixels, and a red pixel. Additionally most programs including Pencil2D will not allow you to make a rotated selection (you can rotate a selection, but not make a selection that is initially rotated). Nor do most programs allow you to select parts of a pixel on a bitmap. If you could make a rotated selection, you would see the red square get a little bit whiter as parts of the pink pixel is interpolated with the red pixel. If you end up just selecting the middle pixel and rotating again, the adjacent pixels will become even more pink because you’re effectively doing the exact same thing as you did the first time to the computer, rotating the unrotated red square in the middle by 45 degrees.

Vectors can be scaled and rotated without loosing significant quality only because they store the information to effectively redraw the strokes after scaling/rotating, although they are still subject to the limitations of your grid-of-pixels display and bitmap exports. We do not recommend using the vector layer in Pencil2D currently because it is very buggy, but it will be improved at some point. Technically you can store rotated bitmaps as separate objects, and some programs do this to prevent the reduction of quality when rotating an object multiple times, but there are challenges with that too, and again you’re still limited to square pixels when viewing it or rendering it. Pencil2D does actually already do this to some extent, you can see how it works by making a selection and then rotating it multiple times without applying your transformation (which happens when you press the enter key or deselect/change the selection). Once you apply the transformation it writes the object back to your frame, and you loose the information of what the object looked like before the rotation forever.

I will wrap up this dive into how bitmap scaling and rotation work by reiterating some key points. Degrading bitmap image quality is expected in these scenarios, and can never be fixed. We will likely add other interpolation algorithm options at some point, but these only change the appearance of the results, they are no more or less correct than any other method.

1 Like

I understand now that raster selections degrade in quality when rotated, scaled, etc. so my changed suggestion is to improve the quality of the brush or ink tool when rotated or scaled since the pencil tool seems to not degrade so much in quality when compared to the brush or ink tool selection is rotated or scaled.

The exact same algorithm is used to scale and rotate the brush, pen, and pencil tools. All that is stored in a frame on a bitmap layer is a bitmap: a grid of pixels. It is impossible for the program to tell the difference between a stroke from one tool or another because it’s just pixels to them. The difference you think you see is just that the pencil has more feathering than your current settings for the other tools, so the edges are not as sharp and the “degradation” is not as obvious. Try turning the feather option up on the brush tool and see how that affects the stroke and the stroke when rotated/scaled, keeping in mind that the rotation and scaling operations are doing the exact same mathematical operations regardless of your brush settings.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.