Just display content, not card

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Just display content, not card

Post by Andycal » Wed Sep 23, 2009 10:15 am

I'm having a brain freeze again.

Is is possible to display just text, kinda floating somewhere on the screen without showing the card behind it? I tried the blends but the whole lot dissapears...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Sep 23, 2009 11:36 am

Andy,
you could do a stack (substack) with a custom windowshape. Than place a text field on that stack. This is not all transparent but the closest to what you want that I can think of.
Go to Scott Rossi's site with his superb examples
http://www.tactilemedia.com/
go to: software
go to: see all tutorials

all the way down there is a stack WindowLab
It shows how to make custom shaped stacks.
regards
Bernd

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Sep 23, 2009 12:21 pm

Hi Andy,

or import a snapshot of the text (text only!) and use this new image as a windowshape. Should look OK if you use a not too small text size.


Best

Klaus

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Wed Sep 23, 2009 1:23 pm

Thanks for these ideas guys, I'll check 'em out.

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Sep 23, 2009 1:55 pm

This is "interesting"

Code: Select all

   import snapshot from field "fldBGtext"

   ################################
   ## uncomment the export/import to/from file below to make it work
   ##
   ## export the last image to file "imgBGtext.png" as png
   ## delete the last image
   ## import paint from file "imgBGtext.png"
   ##
   ## uncomment above to make it work
   #################################

   set the visible of the last image to false
   set the windowShape of this stack to the id of the last image
   set the backgroundPattern of this stack to the id of the last image
If I try and use the imported snapshot as the windowShape and backgroundPattern, then I get a badly rendered blob the size of the stack. If I export that imported snapshot to a file and then reimport it and use the newly imported image as the windowShape and backgroundPattern, then it works perfectly.
This is on Windows (XP Pro) here.

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Sep 23, 2009 2:50 pm

Hi all,

no need to import/export/import the snapshot image!

Do this:
1. Create an EMPTY image "tText"
2. The field with your text MUST be NOT opaque and have NO border and can be invisible
3. Add this script to your stack:
...
export snapshot from rect(the rect of fld 1) of fld 1 to img "tText" as PNG
set the topleft of img "tText" to 0,0
set the windowshape of this stack to the id of img "tText"
...

Works fine here, but the rendered text is not too cute :-/


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Sep 23, 2009 7:21 pm

Klaus,
thank you, that works perfectly. Except maybe for the rendering. But Rev uses the Masking Data, so no antialiasing. Too bad.

As the old indian chief said: listening to the masters makes you wiser :)

regards
Bernd

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Sep 24, 2009 8:48 pm

That's great Klaus, vielen Dank! I wonder what the issue with importing a snapshot and using the id of the last image is though? Quite peculiar.
Nice to see a neater way of doing it anyway though, thanks again.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Sep 24, 2009 9:37 pm

Sparkout,

Wilhelm Sanke, who does a lot with images in Rev refers repeatedly to PNG's that have not been saved to a file and then reimported as pre-PNG. They behave differently then after saving and reimporting. He event gives a recipe for crashing Rev with these.
from this thread:
http://www.mail-archive.com/use-revolut ... 23359.html
First of all, the one image used in the test stack needs to be of the "Pre-PNG" type, an image type I have named as such and described in detail in my stack "More about Masks"

<http://www.sanke.org/Software/MoreAboutMasksRev3.zip> in the text brought up on the menu card from the topright introduction button.

"Pre-PNG" images are basically those that are created or modified (as to their imagedata) in Revolution and have not yet been saved as external files and then been re-imported. Even if you export a snapshot using "to image x as PNG" (image x being an image already existing on the card), the resulting image will remain a Pre-PNG, also copying and pasting the Pre-PNG to another card or stack preserves the quality of the Pre-PNGs which behave differently in some respects. For details see my comments in "More about Masks".
and here maybe more pertinent to the problem you saw:
http://www.mail-archive.com/use-revolut ... 15956.html

I did not have the problem with your script on a Mac, it showed the text as backgroundpattern without exporting the PNG first.
But there seem to be peculiarities with unsaved PNG's.

If you can come up with a demo stack you might want to bugzilla this.

regards
Bernd

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Sun Sep 27, 2009 6:25 am

Klaus wrote:Hi all,

no need to import/export/import the snapshot image!

Do this:
1. Create an EMPTY image "tText"
2. The field with your text MUST be NOT opaque and have NO border and can be invisible
3. Add this script to your stack:
...
export snapshot from rect(the rect of fld 1) of fld 1 to img "tText" as PNG
set the topleft of img "tText" to 0,0
set the windowshape of this stack to the id of img "tText"
...

Works fine here, but the rendered text is not too cute :-/


Best

Klaus
That's actually perfect for my needs! Thanks, Klaus.

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sun Sep 27, 2009 11:26 pm

And thanks Bernd too. That's food for thought. If I get around to making a recipe stack I'll submit it on QCC.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Sep 28, 2009 5:21 am

Using the export command with the "from rect" option is limited to objects that are visible on screen, and won't render with transparent regions such as the blank spaces between words and lines in a field.

Instead you might consider the newer "from object" syntax added with the rendering engine overhaul in v2.7:

http://revjournal.com/blog.irv?pid=1253632044.696527
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply