hilitePattern not resizing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 25
- Joined: Mon Feb 25, 2013 4:00 am
hilitePattern not resizing
i've set the hilitePattern of a scrolling list field to an image ID.. however, the image is being tiled rather than filling the selectedText line.... I currently use a functional resizeStack handler but it doesn't seem to address the image ID of the hilitePattern... suggestions?.. thanks
Re: hilitePattern not resizing
Hi,
From the dictionary: "To be used as a pattern on Mac OS systems, an image must be 128x128 pixels or less, and both its height and width must be a power of 2. To be used on Windows and Unix systems, height and width must be divisible by 8. To be used as a fully cross-platform pattern, both an image's dimensions should be one of 8, 16, 32, 64, or 128.". You might want to try to reshape the picture to make its width and height divisible by 8. Also, I'm not sure you can use a hilitePattern to fill an entire line of a field, because the lineHeight of a field is probably often not divisible by 8 and if the picture is required to be a rectangle, then it probably won't work as the background for one line anyway.
You could use the formattedRect of the selectedChunk to get the rect (or at least the top and bottom) of the currently selected text. You could use with left and right of the field containing that text to calculate the exact rect of the selected text. If you make the field transparent, then you can put an image behind it and set its rect to the value calculated from the formattedRect (and the right and the left). This way, you have something similar to a hilitedPattern.
Sorry, I don´t understand the second part of your question.
Kind regards,
Mark
From the dictionary: "To be used as a pattern on Mac OS systems, an image must be 128x128 pixels or less, and both its height and width must be a power of 2. To be used on Windows and Unix systems, height and width must be divisible by 8. To be used as a fully cross-platform pattern, both an image's dimensions should be one of 8, 16, 32, 64, or 128.". You might want to try to reshape the picture to make its width and height divisible by 8. Also, I'm not sure you can use a hilitePattern to fill an entire line of a field, because the lineHeight of a field is probably often not divisible by 8 and if the picture is required to be a rectangle, then it probably won't work as the background for one line anyway.
You could use the formattedRect of the selectedChunk to get the rect (or at least the top and bottom) of the currently selected text. You could use with left and right of the field containing that text to calculate the exact rect of the selected text. If you make the field transparent, then you can put an image behind it and set its rect to the value calculated from the formattedRect (and the right and the left). This way, you have something similar to a hilitedPattern.
Sorry, I don´t understand the second part of your question.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: hilitePattern not resizing
If I remember right, the size restrictions on patterns was removed a while ago, but it looks like the dictionary was not updated.
sincipient820, does your resizestack handler resize the pattern image? Is the image's lockloc set to true? That is what used to work, but I did notice in the last release that the engine was ignoring the image size when creating the hilite pattern. I'm not sure if that's been fixed in the latest release.
The workaround I had to use was to create a temporary snapshot of the resized image and use that for the hilitepattern.
sincipient820, does your resizestack handler resize the pattern image? Is the image's lockloc set to true? That is what used to work, but I did notice in the last release that the engine was ignoring the image size when creating the hilite pattern. I'm not sure if that's been fixed in the latest release.
The workaround I had to use was to create a temporary snapshot of the resized image and use that for the hilitepattern.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: hilitePattern not resizing
Hi,
I also vaguely remember such a change, but when checking the dictionary, the limitations were still there.
Best,
Mark
I also vaguely remember such a change, but when checking the dictionary, the limitations were still there.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 25
- Joined: Mon Feb 25, 2013 4:00 am
Re: hilitePattern not resizing
Jacque,
the resizeStack handler does appear to resize the image on the image card however not on the card where the hilitePattern appears... the lockloc does not appear to be on either... I'm going to try Mark's suggest first and i'll report my results.. thanks
the resizeStack handler does appear to resize the image on the image card however not on the card where the hilitePattern appears... the lockloc does not appear to be on either... I'm going to try Mark's suggest first and i'll report my results.. thanks
Re: hilitePattern not resizing
Hi,
Why do you need a resizeable image? Can't you just use a solid colour?
Perhaps you need to set the hilitePattern to empty and then to the id of the image again, after resizing the image. This might force it to redraw. (I haven't tried this myself).
Kind regards,
Mark
Why do you need a resizeable image? Can't you just use a solid colour?
Perhaps you need to set the hilitePattern to empty and then to the id of the image again, after resizing the image. This might force it to redraw. (I haven't tried this myself).
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: hilitePattern not resizing
sincipient820 , that was my experience too. It may be fixed in version 6.0 because they did some work with icons that now resize when the source image changes. I haven't had a chance to test it yet. The trick I used works well and it's being used in a commercial app in the App Store without any problem. But I was wrong about using a snapshot, I just remembered I did it a little differently:
The source image is stored normally wherever you want, I used a hidden group. I made a copy and stored it in the same place. The reason for keeping the copy is so that you always have the original, unaltered image available. I assigned the hilitepattern of the field to the id of the copy. When I needed to resize the hilitepattern, I resized the original and then set the imagedata of the copy to the imagedata of the original. That makes the copy a non-resized image, which the hilitepattern property will use correctly.
The source image is stored normally wherever you want, I used a hidden group. I made a copy and stored it in the same place. The reason for keeping the copy is so that you always have the original, unaltered image available. I assigned the hilitepattern of the field to the id of the copy. When I needed to resize the hilitepattern, I resized the original and then set the imagedata of the copy to the imagedata of the original. That makes the copy a non-resized image, which the hilitepattern property will use correctly.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 25
- Joined: Mon Feb 25, 2013 4:00 am
Re: hilitePattern not resizing
thanks guys, i'll try to implement these suggestions this weekend and get back to the thread with results