F0rce/signature-widget

RGBA of setBackgroundColor not working

Closed this issue · 4 comments

Koboo commented

Describe the bug
Since the CSS property rgba in the alpha channel works with decimal places, a double or float should be used instead of an int in Java.

To Reproduce
Steps to reproduce the behavior:

  1. Call signaturePad.setBackgroundColor(0,0,0,10);
  2. Open the View
  3. See the black background.

Expected behavior
The specified alpha channel should either be converted to percent and passed or another data type should be used in the Java part, otherwise the correct value will not be used.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Brave (Chromium)
  • Vaadin Platform 21.0.7
  • Vaadin Flow 8.0.4

Thanks for this widget and your work on it so far!

F0rce commented

public void setBackgroundColor(int red, int green, int blue, int alpha) {
String rgba = "rgb(" + red + ", " + green + ", " + blue + ", " + alpha + ")";
getElement().setProperty("backgroundColor", rgba);
backgroundColor = rgba;
}

@Koboo as you can see here I forgot to add a "a" after the "rgb". I am currently updating the whole Add-On as there is a whole new version of the frontend code. I already fixed this issue locally and will upload it as soon as I'm done with rebaseing.

Thanks for showing me,
David

Koboo commented
    public void setBackgroundColor(int r, int g, int b, double alpha) {
      String rgba = "rgb(" + r + ", " + g + ", " + b + ", " + alpha + ")";
      this.getElement().setProperty("backgroundColor", rgba);
    }

If anyone is wondering how to set a background with alpha channel anyway, here is a code snippet that should help. I inherited the SignaturePad in a new class SignatureField and wrote this method there. Until an update is available, this will solve the problem centrally.

And a huge thanks to you @F0rce for supporting the Vaadin open source community! I use several of the components you created/maintained and must say, good job, keep it up!

F0rce commented

@Koboo thank you very much for the kind words. I do my best to actively maintain / update the components I created.

I fixed the RGBA issue and added some good cleanup to the frontend. The Java Backend didnt change, so everything should work when updating to 2.0.1

Will upload the new version now.

Have a great day and thanks for showing me the issue,
David

F0rce commented

2.0.1 has been published to the directory

https://vaadin.com/directory/component/signature-widget/2.0.1