Text Field Rotation
Moderator: Klaus
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Text Field Rotation
Not that I am aware of, unless there is some way to apply something like the GIMP unsharp filter to the resulting
snapshot.
https://docs.gimp.org/2.10/en/gimp-filt ... -mask.html
Re: Text Field Rotation
Setting the metadata["density"] has no effect on the quality of the exported/printed image.
Try to add the "... at size" parameter:
Not tested, but may give better printing results.
Best
Klaus
Try to add the "... at size" parameter:
Code: Select all
on mouseup
lock screen
local tImage, tMetadata
set the resizeQuality of the templateImage to "best"
## put 2400 into tMetadata["density"]
create image "rotatedText"
## Use 4 times the original dimensions:
put the width of fld "captionfield" into tWidth
put the height of fld "captionfield" into tHeight
put (tWidth * 4) & "," & (the height of fld "captionfield" * 4) into tSize
export snapshot from field "captionfield" AT SIZE tSize to tImage as png
## export snapshot from field "captionfield" with metadata tMetadata to tImage as png
set the text of image "rotatedText" to tImage
## Resize image
set the width of img "captionfield" to tWidth
set the height of img "captionfield" to tHeight
set the lockloc of img "captionfield" to TRUE
set the loc of image "rotatedText" to the loc of this card
set the angle of image "rotatedText" to 45
## !!! :-)
reset the templatimage
unlock screen
end mouseup
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Text Field Rotation
Let's Go Rockabilly!
- -
- -
Code: Select all
on mouseUp
import snapshot from fld "ff"
set the loc of fld "ff" to -200, -200
set the name of the last img to "SHOT"
set the angle of img "SHOT" to 45
clone img "SHOT"
set the name of the last img to "SHOT2"
set the loc of img "SHOT2" to the loc of img "SHOT"
put the loc of img "SHOT" into WHERE
delete img "SHOT"
set the resizeQuality of img "SHOT2" to "best"
put the width of img "SHOT2" into WIDD
put the height of img "SHOT2" into HITE
set the width of img "SHOT2" to (WIDD/4)
set the height of img "SHOT2" to (HITE/4)
import snapshot from img "SHOT2"
set the name of the last img to "SHOT3"
delete img "SHOT2"
set the resizeQuality of img "SHOT3" to "best"
set the width of img "SHOT3" to WIDD
set the height of img "SHOT3" to HITE
set the loc of img "SHOT3" to WHERE
--delete img "SHOT"
set the name of img "SHOT3" to "SHOT"
end mouseUp
- Attachments
-
- text rotate.livecode.zip
- Stack.
- (1.25 KiB) Downloaded 89 times
Re: Text Field Rotation
I tried Klaus' suggestion to set the "at size" parameter at 4 times the original dimensions and that produced the cleanest snapshots for printing yet at angle 90,180,270,-90 (That was what Jon, the original poster was after)
Code: Select all
on mouseup
lock screen
local tImage, tMetadata, tWidth, tHeight, tSize, tQuality
put "good" into tQuality
reset the templateImage
set the resizeQuality of the templateImage to tQuality -- "good" works well for angles 90,180,270,-90 in print
set the lockloc of the templateImage to TRUE
if there is an image "rotatedText" then
delete image "rotatedText"
end if
create image "rotatedText"
# Use 4 times the original dimensions:
put the width of fld "captionfield" into tWidth
put the height of fld "captionfield" into tHeight
put (tWidth * 4) & "," & (the height of fld "captionfield" * 4) into tSize
export snapshot from field "captionfield" AT SIZE tSize to tImage as png
set the text of image "rotatedText" to tImage
## Resize image
set the angle of image "rotatedText" to -90
if the angle of image "rotatedText" is among the items of "90,270,-90" then
set the width of img "rotatedText" to tHeight
set the height of img "rotatedText" to tWidth
else
set the width of img "rotatedText" to tWidth
set the height of img "rotatedText" to tHeight
end if
set the loc of image "rotatedText" to the loc of this card
reset the templateimage
unlock screen
end mouseup
Kind regards
Bernd
Re: Text Field Rotation
A huge thank you to everyone who have responded but at the risk of seeming ungrateful for everyones help (which couldn't be further from the truth!), can't the engineers at LC just make it possible to rotate a text field control natively in LC or am I asking for the impossible?
Best regards,
Jon
Best regards,
Jon
Last edited by cmhjon on Fri Jan 06, 2023 4:16 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Text Field Rotation
I would suggest you direct that last question to the LiveCode people directly.
Re: Text Field Rotation
Add a comment to this enhancement request from 2004, yes, this one is 19 years old!
https://quality.livecode.com/show_bug.cgi?id=1264
https://quality.livecode.com/show_bug.cgi?id=1264
Re: Text Field Rotation
Done and done 
Best regards,
Jon

Best regards,
Jon
-
- VIP Livecode Opensource Backer
- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Text Field Rotation
A good idea.

https://forums.livecode.com/viewtopic.p ... 03#p220793
Case #427 of why duplicate threads are problematic.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Text Field Rotation
Here is a version of getting a snapshot at size x*4,y*4 from the formattedRect of char 1 to -1 of the captionField. Also known as the Klaus technique.
The advantage is that it is easier to capture arbitrary text without adjusting the field dimensions to accomodate the text.
I think this is as good as it gets for angles 90,180,270,-90. At resizeQuality "good" native text and the reduced snapshot image are indistinguishable on screen and in print to pdf.
Kind regards
Bernd
The advantage is that it is easier to capture arbitrary text without adjusting the field dimensions to accomodate the text.
I think this is as good as it gets for angles 90,180,270,-90. At resizeQuality "good" native text and the reduced snapshot image are indistinguishable on screen and in print to pdf.
Kind regards
Bernd
- Attachments
-
- KlausSnapshotEnlargedFromField_2.livecode.zip
- (7.04 KiB) Downloaded 80 times
Re: Text Field Rotation
Out of curiosity, given the modern hardware, is there a downside to using resizeQuality "best"? Why use "good"?
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Text Field Rotation
"Smoothes too much" . . .
Not with my method.
Disclaimer: I have never been a smoothie.
Not with my method.
Disclaimer: I have never been a smoothie.

Re: Text Field Rotation
I uploaded an improved stack to "Sample Stacks" that allows for any angle of the rotated snapshot.
Either access it from within LC via "Sample Stacks" or via
https://livecodeshare.runrev.com/stack/ ... extField_2
Kind regards
Bernd
Either access it from within LC via "Sample Stacks" or via
https://livecodeshare.runrev.com/stack/ ... extField_2
Kind regards
Bernd