Looking for Help on a Project

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: Klaus, FourthWorld, heatherlaine, kevinmiller

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Thu May 25, 2017 7:41 am

Well....I actually figured this out finally myself :)
By setting the printer code to print to PDF instead of the printer it spits out a high quality pdf image :) works great!
Sorry to have bothered you all but it's good to know you are there.

Cheers
David

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Fri May 26, 2017 5:13 am

Hi,
EDIT: SOLVED.
I have managed to write the file to a selected folder but it does not write with the "pdf" file extension.
Added :

Code: Select all

put it & ".pdf" into SavePdf 

Code: Select all

on mouseUp

   if the result is "Cancel" then exit mouseUp
   set the printPaperOrientation to "portrait"
   set the printMargins to 0,0,0,0
   set the printPaperSize to "595,842"
   ask file "Choose a file for the PDF:"
   if it is not empty then
      
      put it into SavePdf
 open printing to pdf SavePdf

      print this card from 0,0 to 595,842 into 0,0,900,1240     
   end if
   close printing
  
end mouseUp 


Thanks.
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sat May 27, 2017 4:32 am

Ok...this one has me stumped. Is it a bug?

I am trying to move an image with "grab me". When I load the image I set the image locklocation to true
so it doesn't resize the image area. Works fine but when I reset the image locklocation to false the image will
not move with the grab me function.

Can anyone help with this problem please?
I am using the code below:

Code: Select all

on mouseUp
set the lockLocation of image "i1" to true
   answer file "Choose a picture"
   if it is not empty then
      set the filename of image "i1" to it
   end if
set the lockLocation of image "i1" to false
end mouseUp
Then this on the image area":

Code: Select all

on mouseUp
   grab me
end mouseUp

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

Re: Looking for Help on a Project

Post by jmburnod » Sat May 27, 2017 8:08 am

Hi bidge,

Grab on mouseUp doesn't work, you have to use mousedown like that:

Code: Select all

on mouseDown
   grab me
end mouseDown
Best regards
Jean-Marc

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sat May 27, 2017 8:33 am

Oh thank you so much Jean-marc.
I am learning slowly :)

Bidge

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

Re: Looking for Help on a Project

Post by jmburnod » Sat May 27, 2017 9:09 am

Grab is one way to do what you want but you can't do any thing while grab
Mousemove is an other way
You may have a look at this thread
http://forums.livecode.com/viewtopic.php?f=7&t=29242
Jean-Marc

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sat May 27, 2017 10:06 am

Thanks Jean-marc.
I have just struck another problem I don't know how to solve or what is going wrong.
Importing an image so it stays at it's set aspect ratio but small enough to manipulate:

I have an image import button and two sliders that control the rotation and image size.
The image imports nicely and the rotation slider works fine but when I try to use the resize
slider to resize the image it loses its imported aspect ratio and pops back to the set size of
he image area which is square. How can I stop this?

Image Import code:

Code: Select all

on mouseUp
   answer file "Choose a picture"
   if it is not empty then
      set the filename of image "i1" to it
   end if
      put the formattedWidth of image "i1" into nativeWdth
      put the formattedHeight of image "i1" into nativeHgt
      put the width of graphic "maxD" into maxWdth
      put the height of graphic "maxD" into maxHgt
      put constrainedDimensions(nativeWdth,nativeHgt,maxWdth,maxHgt) into newDimensions
      set the width of image "i1" to item 1 of newDimensions
      set the height of image "i1" to item 2 of newDimensions
      set the loc of image "i1" to the loc of graphic "maxD"
end mouseUp
Rotation slider code:

Code: Select all

on scrollbarDrag pScrollValue
   set the angle of image "i1" to pScrollValue
end scrollbarDrag
Image resize (the problem)

Code: Select all

on scrollbarDrag pScrollValue
   set the height of image "i1" to pScrollValue
   set the width of image "i1" to pScrollValue
end scrollbarDrag

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

Re: Looking for Help on a Project

Post by jmburnod » Sat May 27, 2017 10:54 am

Paul Hibbert made a stack « Angle and Resize test » you can download
Click on « sample stack » button and choose « image »

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sat May 27, 2017 11:03 am

Yes...I tried to implement that stack but I couldn't get it to work correctly. The temp image kept popping up full size then it would go crazy.
The code I have works well I just need to find out why the image size is changing it's aspect ratio when scaled up?

Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sun May 28, 2017 5:54 am

Hi again I have struck another issue I am struggling to deal with.
When I scale up my image area my text area is being thrown off center, it's actually
not scaling up perfectly with the rest of the grouped objects. Is there a way to
somehow center a text field in a group of objects?

Thanks for any help.
Bidge

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

Re: Looking for Help on a Project

Post by SparkOut » Sun May 28, 2017 8:44 am

Hi Bidge
You can of course set the loc[ation] of an object or group, and it refers to the centre point of the object. In the handler script you are using to scale and position the image you can add

Code: Select all

set the loc of field "theText" to the loc of me
where necessary you can change "me" to "the target" or other reference to the object you want to use as the centre point for the field.

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sun May 28, 2017 8:47 am

Hi SparkOut.
Brilliant. Thank you so much.
Unfortunately it worked but the problem cannot be fixed this way :(
For some reason the text is not scaling up correctly with the group.
The scaling up to pdf :
print this card from 0,0 to 595,842 into 0,0,900,1267
is causing the text to increase in size so that
words start running off and out of the text area???

I have no idea how to compensate for this???

Bidge

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

Re: Looking for Help on a Project

Post by SparkOut » Sun May 28, 2017 8:58 pm

You have fallen foul of the different screen and printing font metrics on Windows. The formatForPrinting property will need to be set to true for accurate print rendition. And false for making the screen view look acceptable. The dictionary says this has to be done while the stack is closed but I think it can be done on the fly OK.

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Looking for Help on a Project

Post by bidgeeman » Sun May 28, 2017 11:55 pm

Thank you SparkOut.
When this issue is addressed would it still work ok on a Mac?

Thanks
Bidge

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

Re: Looking for Help on a Project

Post by SparkOut » Mon May 29, 2017 1:37 am

That's something I can't say for sure. I expect it would work without change and just be ignored on a Mac. At worst it would only need a one-liner check for the platform to decide whether to set or not.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”