rnote icon indicating copy to clipboard operation
rnote copied to clipboard

A pen with a transparent color isn't homogenously transparent, but leaves less transparent circles

Open NandorKovacs opened this issue 1 year ago • 3 comments

Describe the bug
If you write with a thicker pen and a transparent color, it isn't homogenously transparent, but rather leaves little circles where its less transparent. I think it "draws twice" in those places probably. This more visible if your stroke is fast. It appears with a mouse, as well as with my drawing tablet.

To Reproduce
Steps to reproduce the behavior:

  1. Click on the color picker
  2. Select any color you like, and set it to transparent, around halfway works well
  3. Select the thick pen option, or even the marker (that is even more thick)
  4. Make a few strokes
  5. You will see your stroke, with little darker circles inside of it

Expected behavior
The pen should leave a smooth transparent stroke

Console Output
Running the app with flatpak --env=RUST_LOG=rnote=debug --env=RUST_BACKTRACE=1 run com.github.flxzt.rnote gives following output: ` 2023-11-17T17:09:17.388Z DEBUG rnote > ... env_logger initialized

(rnote:2): Gtk-CRITICAL **: 18:09:17.690: gtk_widget_class_set_accessible_role: assertion '!gtk_accessible_role_is_abstract (accessible_role)' failed 2023-11-17T17:09:17.716Z WARN rnote::workspacebrowser::workspacesbar > failed to canonicalize dir "/home/nandor/Desktop/rnote/studium/analysis" for workspacelistentry with name: default, Err: No such file or directory (os error 2) ` I don't think anything here is relevant, but why not include it Screenshots
image Well visible circles.

Desktop (please complete the following information):

  • OS: Ubuntu 23.04 x86_64
  • App Version: Rnote 0.9.0
  • Installation Source: Flatpak
  • Desktop Environment: Gnome 44.3

Additional context
It is vaguely related to #449 . I wanted to highlight on a pdf, and set the marker to be transparent. This looks not well enough for me to be able to use transparent colors anywhere. From what im guessing, the circles are perfectly circular because exactly one point overlaps, making the circle around it half as transparent.

NandorKovacs avatar Nov 17 '23 17:11 NandorKovacs

Maybe a pen with a multiply blend mode would be a quick fix (brush that only affects white colors but not black colors).

tipptop3d avatar Nov 20 '23 15:11 tipptop3d

Good idea, but unfortunately the underlying drawing API does not support blend modes, so currently this issue is a bit stuck

flxzt avatar Nov 20 '23 15:11 flxzt

As far as I understand it, this projet uses piet to render the canvas, piet is itself in this context an abstraction layer ontop of cairo.

Cairo itself supports all different types of rendering modes (https://www.cairographics.org/operators/), which in this case would be the CAIRO_OPERATOR_MULTIPLY - this is also what xournalpp uses for its highlighter (for reference: https://github.com/xournalpp/xournalpp/blob/583a4e4728c1cc0d33101c0d30f8605cd5312a00/src/core/view/ErasableStrokeView.cpp#L137).

Thus, this is blocked by piet not exposing cairo operators to its api? Because piet is using the operators itself (reference: https://github.com/linebender/piet/blob/master/piet-cairo/src/lib.rs#L97), isn't there a way to access the cairo context piet uses?

My understanding of the code is, that https://github.com/flxzt/rnote/blob/main/crates/rnote-engine/src/strokes/brushstroke.rs#L197 is place where the context is constructed, I'm not familiar with Rust, so I don't know if its possible to just access the underlaying cairo context and do something like:

ctx.set_operator(cairo::Operator::Multiply);

or if the stroke_styled() function of piet should expose a (optional?) operator field?

This is to the best of my knowledge and I'm sorry if this is all wrong, but if not I think this should also fix https://github.com/flxzt/rnote/issues/449.

Thanks for this project!

taaem avatar Jun 24 '24 17:06 taaem