Diameter of a circle

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

Post Reply
kevin007
Posts: 40
Joined: Mon Sep 21, 2015 7:46 am

Diameter of a circle

Post by kevin007 » Thu Apr 21, 2016 10:13 am

Hi ALL

How to find the diameter of a circle when I click a button, which was created by the below code.

Code: Select all

set the style of templategraphic to "oval"
choose graphic tool

Actually, i need the value in cm if i know width and height of circle

Thanks
Kevin
--
Thanks
Kevin

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

Re: Diameter of a circle

Post by Klaus » Thu Apr 21, 2016 11:21 am

I ususally create a little function for these kind of tasks, simply pass the name of your graphic to that function:

Code: Select all

function diameter_of_circle name_of_graphic
   return the height of grc name_of_graphic
end diameter_of_circle
This will work, too:

Code: Select all

function diameter_of_circle name_of_graphic
   return the width of grc name_of_graphic
end diameter_of_circle
8)

The PIXEL to CM conversion depends on the dimensions of your pixels = pixel density of your monitor.

kevin007
Posts: 40
Joined: Mon Sep 21, 2015 7:46 am

Re: Diameter of a circle

Post by kevin007 » Thu Apr 21, 2016 11:50 am

Hi,

if the 200 is the height of circle,

Is there any formula to convert it into cm,

How can i know the pixel density of my monitor by lc.

Thanks
kevin
--
Thanks
Kevin

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

Re: Diameter of a circle

Post by Klaus » Thu Apr 21, 2016 11:56 am

kevin007 wrote:How can i know the pixel density of my monitor by lc.
You can't!

Maybe it is in the manual of your monitor model, but this will be different for any other montior.
Mostly the density is measured in ppi = pixel per inch, where inch = 2.54 cm.

P.S.
Please take a look at your other postings from time to time, most of them have been answered! 8)

kevin007
Posts: 40
Joined: Mon Sep 21, 2015 7:46 am

Re: Diameter of a circle

Post by kevin007 » Thu Apr 21, 2016 12:54 pm

Hi,

How draw a perfect circle by graphically instead of oval ?

Thanks
Kevin
--
Thanks
Kevin

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

Re: Diameter of a circle

Post by Klaus » Thu Apr 21, 2016 1:34 pm

Hold the SHIFT-key when dragging the oval bigger or smaller!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Diameter of a circle

Post by dunbarx » Thu Apr 21, 2016 3:32 pm

@Klaus.

Option key, no?

@Kevin.

You can create an oval graphic, and then just set the height equal to the width, no?

Craig Newman

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

Re: Diameter of a circle

Post by Klaus » Thu Apr 21, 2016 3:57 pm

Hi Craig,
dunbarx wrote:@Klaus.
Option key, no?
Ah, yes, sorry! SHIFT-key will keep the initial aspect ratio of an object while resizing.
However this will be the same for a newly crreated oval graphic, which is in fact a circle. :D


Best

Klaus

Post Reply