Applying transparency to only a part of a stack?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Applying transparency to only a part of a stack?

Post by Zax » Wed May 26, 2021 5:21 pm

Hello,

Is there a way to apply transparency to only a part of a stack like the following demo (made with Photoshop) with LC Indy 9.04?
If the blendLevel of a stack is modified, all its controls will be transparent. On the other hand, if the blendLevel of an image is modified, the stack background is still visible.

Thank you.
demoTranspa.jpg

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Applying transparency to only a part of a stack?

Post by Klaus » Wed May 26, 2021 5:27 pm

Hi Zax,

I think this may get you started:
https://lessons.livecode.com/m/4071/l/2 ... ks-windows

Best

Klaus

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Wed May 26, 2021 9:58 pm

Yes, it is possible (and fairly easy).

I recreated the look of the stack you posted, but I prefer cars to dogs. The settings and controls are included in the picture (Lc 6.5.2, will work in any version later I suspect).

Image
Image

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Applying transparency to only a part of a stack?

Post by Zax » Thu May 27, 2021 9:02 am

Thanks for your answers.

@Klaus: I'm studying this lesson but I'm not sure it will help me.

@bogs: I don't understand because this is what I have with a default stack, only applying a 50% blendSrcIn effect of an image object :

screen.jpg
Making the image transparent only reveals stack's background (default grey).
But you're right, cars are better than dogs ;)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Thu May 27, 2021 11:19 am

Zax wrote:
Thu May 27, 2021 9:02 am
@bogs: I don't understand because this is what I have with a default stack, only applying a 50% blendSrcIn effect of an image object :
screen.jpg
Making the image transparent only reveals stack's background (default grey).
But you're right, cars are better than dogs ;)
Heh, I dunno what to tell you there, I rarely venture higher than 6.5.x, and usually am far lower in version numbers (like Mc 2.5) as far as IDEs go, but since your test flopped, I dragged some of the newer IDEs out of storage to see what was going on.

What I found out (on linux) was -
  1. I couldn't get 9.6 to even resize the image, and changing blend levels for various inks did nothing. { This is no surprise to me, LOTS of things in 9.6 don't work here worth squat }
  2. 9.5 - was at least able to assemble a copy stack for demonstration and worked as far as the topic is concerned.
    Image
  3. I guess I didn't even try to download any versions between 8.1.2 and 9.5, 8.1.2 is iffy here, even 8.0.1 is no wonder shakes.
  4. 8.0.1 and 8.1.2 *were* able to do exactly that same trick, though.
So, my guess would be that, much like 9.6 here, something is going on in that version your using, or, alternately, there is some conflict between that version ( or version range ) and your OS.

The only way to know that would be to post your OS specs ( guessing OSX, but which one? ) and see if someone else using it in combination with LC 9.04 can duplicate the problem.

Likely suspects for testing would be Klaus, Richmond, or Jacque off the top of my head.

Alternately, make the stack in an earlier (or later) version of Lc, save it setup how you like, then open it in 9.04 and see if the transparency stuck while in that IDE or after building. I don't see why it shouldn't as long as it is properly set.
Image

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Applying transparency to only a part of a stack?

Post by Zax » Thu May 27, 2021 12:03 pm

OK, I finally understand the lesson linked by Klaus. It's very helpful, though it could be a little bit more accurate.

I still have a problem about the ink: I would like to a assign a "blendMultiply" ink to the process but it doesn't seem to work as intended.
screen.jpg
(the red border is for development purpose)

@bogs: I'm using LC 9.04 on MacOS Sierra 10.12.6.
Maybe it depends on car model ;)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Thu May 27, 2021 12:08 pm

@bogs: I'm using LC 9.04 on MacOS Sierra 10.12.6.
Maybe it depends on car model
No, it is almost certainly that the ink isn't being properly applied heh, but I'm sure you already know that :D

You know, it also came to my mind that there is a (relatively) simple way to accomplish this outside of Lc, but I hesitate to mention it as some people don't care for windowShape.

WindowShape requires a bit more massaging as well, but the basic idea is, you take a picture of your stack in it's solid shape with all areas defined, make whatever area you want to be transparent more transparent in a paint program, and then set the window shape to that image after you import it as a control (or reference it, but then your dealing with file systems as well).

This would be an example of using windowShape and an image to define solid / non solid parts of the window.
Image

I'll work up an example of some different ways to accomplish what I mean and post a link to it.
Image

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Applying transparency to only a part of a stack?

Post by Zax » Thu May 27, 2021 1:17 pm

Thanks bogs for your time :)
I would like to manage transparency from inside LC because I would like to adjust it with the scroller (shown at the topleft of my screenshot).

When my user interface (and my scripts) will work, I'll try to make more accurate ink transformation, like full transparency on white or black areas.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Thu May 27, 2021 1:22 pm

This would be the brute force method, just using windowShape (and an image editor!). Mind you, for what your doing, I would just find out which vers. of Lc accomplishes what you want, and use that to make the stack initially.
  1. Here I blatantly ripped off your smug dog picture stack :P and imported it into a paint program (GIMP).
    Image
  2. I used the rectangle select tool and cut the area I want transparent.
    Image

    *Note - make sure you put some kind of fill color with the opacity desired into that area, or you will see nothing.
  3. Save the file as a .png and import it as a control to the stack you want this ultimately to wind up in.
    Image
  4. Set the windowShape of the stack to that image.
    Image
  5. Put another image control on top of that and set it's size appropriately...
    Image

    As you can see, you have your semi transparent image at this point.
  6. PROFIT !
Mind you, you will have to write a (small to medium) amount of code to handle things like dragging the window, resizing it, etc., there are a lot of examples around on how to do this. Me, I would probably stick to the inks and blendlevels for this kind of effect though.

**Edit - you posted as I was composing this ...
Zax wrote:
Thu May 27, 2021 1:17 pm
Thanks bogs for your time :)
I would like to manage transparency from inside LC because I would like to adjust it with the scroller (shown at the topleft of my screenshot).
In the case of the above method, the only thing that would change is that you would group the image on top of the windowShape image, the group would provide scrollbars for you if the image is larger than the group.

Some caveats to that would be that the region itself couldn't be resized, so the group's size would have to be locked at the size of that region.
Image

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Applying transparency to only a part of a stack?

Post by Zax » Sat May 29, 2021 9:01 am

I spent some time trying to make the picture resizable but finally it works :)
Thanks again for all your help.

screen.jpg
As you can see, it works with cars and dogs. I didn't try with cats but it should work ;)

Now ink effects remain rather mysterious for me... For example, is there a way to make transparency only for white, or only for black?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Sat May 29, 2021 11:04 am

Unfortunately, I don't have the answer to the question about black and white, we'll need someone that actually knows more about inks and blending to step up to answer for you :D
Image

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Applying transparency to only a part of a stack?

Post by jmburnod » Sat May 29, 2021 1:21 pm

Hi Zax,
For example, is there a way to make transparency only for white, or only for black?
Not sure I understand correctly

If you want apply transparency to an image I think yes but i never did it.

From dictionary
Use the alphaData property to control the transparency of the pixels in an image.
Each pixel is represented by 8 bits (1 byte) of alpha channel data, with pixels numbered from the top left corner of the image, left to right, then top to bottom.
A value of zero means the pixel is fully transparent; a value of 255 is fully opaque; and values in between indicate a level of partial translucency.
Best regards
Jean-Marc
https://alternatic.ch

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Applying transparency to only a part of a stack?

Post by Zax » Sat May 29, 2021 1:58 pm

jmburnod wrote:
Sat May 29, 2021 1:21 pm
Not sure I understand correctly
Sorry, for a given image, I would like to make the darker parts more transparent than the brighter ones, and conversely. It can be done with softwares like Photoshop.

I tried to play with alphaData but didn't understand. In fact, I was wondering if there is a preset ink mode in LC that would do what I want.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Applying transparency to only a part of a stack?

Post by jacque » Sat May 29, 2021 4:08 pm

I can never remember what each ink does. I just select the image and click my way through them all. Sometimes twice.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Applying transparency to only a part of a stack?

Post by bogs » Sat May 29, 2021 4:22 pm

That is my method usually as well, sometimes I see an effect that is more desirable than what I was shooting for to begin with :P
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”