Pen transparency example

Does someone have a shared example of using a transparent pen? Thanks in advance.

https://snap.berkeley.edu/snap/snap.html#present:Username=cymplecy&ProjectName=transparentPen&editMode

What's the real question? :slight_smile:

Exactly the one you answered. I had created a script identical (almost) to yours and the pen wasn't transparent at all. Even trying fantasy values for transparency until 10000 :slightly_smiling_face:

Thanks to your example I discovered that the transparency must be set after I have choosen the pen color. Is that correct? It is not clear to me why it should be this way, but moving my trasparency block after the set pen color block worked well, as in your example. Any idea why this is the correct sequence? Do we assign transparency to colors instead to the "pen" object?

The colour picker sets the pen colour to a solid, non-transparent colour e.g if you pick pure red you'll end up with and RGBA value of 255,0,0,255

I see. In my mind instead the trasparency was a feature of the pen applied to whatever color you select (before or after setting the transparency value). I guess my "view" could be more natural (at least to me :wink:) as the block says "set pen transparency", but, if you know how it works, even the current mechanism is fine.

How difficult would it be to modify the source code of the color picker (specifically the block, not the interactive picker) so that it doesn't reset the pen transparency value to zero after it has been set to a non-zero value?

I don't quite understand what you mean here

Not too hard I'd thought :slight_smile:

But you don't need to modify source code to get what I think you want

untitled script pic - 2023-05-27T105707.709

I just don't want to keep reminding Snap! every time, after I change the pen color, to remember the transparency I set at the start of the script. Basically, what I am saying is that my mind works the same way as Stefano's mind does.

I'll make you a custom block that keeps transparency :slight_smile:

Great, Simon. Thank you.

Here it is

untitled script pic - 2023-05-28T072743.544

Thank you again.

Now you will need to teach me how to download the block's code because I only see the image of the block.

There's zillions of post on the forum on how to extract the script (with all the issues that can arise) if you want to go down that rabbit hole :slight_smile:

But here is a project with it in :slight_smile:
https://snap.berkeley.edu/snap/snap.html#present:Username=cymplecy&ProjectName=setPenKeepTransparency&editMode

I'm an old-school; I do prefer linking to the project.

It's one of those new fangled things that need to be learnt as it's so much easier for the person publishing a single block or script without having to expose all their scribbles in the margin :slight_smile:

And it saves you having to re-export the block to your own local library :slight_smile:

Really? I didn't suspect that. How does it work? Can you please link a post that does explain it?

Brian recently mentioned that in Snap!, it is now possible to drag an image block that contains its own script code into the Script area. I'm not sure when Snap! acquired this magical ability to export images with code or which version introduced it...

It was introduced in 8.0 (pretty sure), but a snap user created it much much earlier as a mod.

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