Recent

Author Topic: [Solved-Lazpaint] Possible to draw a thin and sharp line, at the first attempt?  (Read 2094 times)

devEric69

  • Hero Member
  • *****
  • Posts: 648
Hello,

I would like to draw lines - as thin and sharp as possible, without anti-aliasing - on their own layer, at the first attempt.

In the attached screenshot, when drawing a line with the polylines tool, I get the result on the left. Is it possible to get a line like the one on the right in the attached screenshot, i.e. without anti-aliasing, sharp, at the first try?

ps1: I've seen, that the tool Pen is associated with a tool-button "Disable antialiasing". But I have the impression that this option is not kept when drawing the line.
ps2: the pen colour of the line (result on the left, in the attached screenshot) is black, "solid=255", opacity=255".
« Last Edit: December 17, 2020, 11:30:10 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Thaddy

  • Hero Member
  • *****
  • Posts: 18695
  • To Europe: simply sell USA bonds: dollar collapses
property TCanvas.AntiAliasingMode := amOn.

Note this will slow down painting a bit, but it should improve the drawing considerably.

Drawing "sharp" lines - it tricks the eyes - without ant-aliasing is not possible, except pure horizontal and vertical.

What you see in your example is called "aliasing" and can only be solved by applying an anti-aliasing filter.

Note that on very high resolution monitors (4K+) you might get away with it without applying anti-aliasing filters.
On my full HD montors I still need to apply it.

Also note that not every anti-aliasing filter is the same, there are many different filter algorithms and I don't know which one TCanvas uses.
Have to look that up. I expect one of the simpler ones, for speed reasons.
« Last Edit: December 16, 2020, 11:19:54 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

devEric69

  • Hero Member
  • *****
  • Posts: 648
Also note that not every anti-aliasing filter is the same, there are many different filter algorithms and I don't know which one TCanvas uses.
Have to look that up. I expect one of the simpler ones, for speed reasons.

I would like to clarify that I am drawing with the compiled Lazpaint tool (end-user), i.e. I am not programming. So, I must probably use a filter to set \ emulate TCanvas.AntiAliasingMode := amOn in Lazpaint, when drawing with the poly-lines tool, if it's necessary. I don't know much about filters. Any advice on the best way to do this (after having drawn the line), would suit me.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

devEric69

  • Hero Member
  • *****
  • Posts: 648
I've found the menu Filter \ Sharpen.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Handoko

  • Hero Member
  • *****
  • Posts: 5513
  • My goal: build my own game engine using Lazarus
Not sure about LazPaint but usually you can make semitransparent pixels to (nearly) full opaque on most graphics editing software by duplicating that layer several times. Maybe 6 times or more. Then you may want to merge all the duplicated layers for easy handling.

devEric69

  • Hero Member
  • *****
  • Posts: 648
No problem: in fact, AFAIK, the simplest would be that I should code and propose - via a Github query - the option to record the presence or not of an anti-aliasing, associated with the pen used to draw with the poly-lines or curves tool (question of free time, like everyone else).
« Last Edit: December 17, 2020, 10:19:22 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

circular

  • Hero Member
  • *****
  • Posts: 4462
    • Personal webpage
Hello @devEric69

It is correct that there is no aliasing mode for shapes, at least for now.

"Filter > Sharpen" will make it closer to that, yet not exactly. Duplicating the layer will work but tend to make things bolder.

You can emulate alpha aliasing by using "Filter > Apply function" and define alpha as "if(alpha>0.5,1,0)".

If you're interested in contributing to LazPaint you are welcome. The simpler is indeed to fork dev-lazpaint and do a pull request on GitHub.
Conscience is the debugger of the mind

devEric69

  • Hero Member
  • *****
  • Posts: 648
define alpha as "if(alpha>0.5,1,0)".
I've tested the tip `alpha(0..1) = "if(alpha>0.5,1,0)"` ==> it works.
Thank you for your help.
« Last Edit: December 17, 2020, 12:33:23 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

circular

  • Hero Member
  • *****
  • Posts: 4462
    • Personal webpage
My pleasure  :)
Conscience is the debugger of the mind

devEric69

  • Hero Member
  • *****
  • Posts: 648
I am a happy user who discovered an ultra-functional drawing and painting project :) .
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

circular

  • Hero Member
  • *****
  • Posts: 4462
    • Personal webpage
So happy to hear that  :)
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018