My Math Forum Relative sizes

 Computer Science Computer Science Forum

 June 17th, 2012, 07:40 AM #1 Newbie   Joined: Jun 2012 Posts: 2 Thanks: 0 Relative sizes I'm drawing a scene with, trying to size my font correctly. I have both a big and small version of the layer on the screen at the same time. I want to set the font in a label on this layer (both the thumbnail and the full size version) to, for example, size 30. This works fine for the full size layer (call it ratio 1), but if I make the thumbnail 1/3 as big, how do I calculate that the font should be 1/3 as big? I can't get the logic right despite multiplying these numbers all ways. The properties which the user can change are: - Font size (pts) - Thumbnail size (px wide) To position the label correctly I'm using this (which works): // 'element' is the customizable element. element.location is the percentage across the layer where it's located. Eg: 50 is half way CGPoint relativeCoords = ccp (self.contentSize.width/(100/element.location.x), self.contentSize.height/(100/element.location.y)); layer.position = relativeCoords; To determine the right font size, I've tried, among other variants, this (to no avail): -(void)sizeToRelative(CGSize)parentSize { // self.lbl is the layer within my element CGFloat ratioWidth = (parentSize.width/100); CGFloat ratioFontSize = (textEle.textProperties.fontSize/100)*(1/3)*(parentSize.width/100); [self.lbl setFontSize:ratioFontSize*element.textProperties.f ontSize]; The idea is that if I pass in a parentSize, to calculate the relative font size. The 'default' size should be as big as 30px in a 100px wide layer. If I have a layer 200px wide, it should return 60 if the user sets the font at size 30.
 June 19th, 2012, 08:51 AM #2 Newbie   Joined: Jun 2012 Posts: 2 Thanks: 0 Re: Relative sizes In pseudo code this would be: Code:  // 'element' is the customizable element. element.location is the percentage across the layer where it's located. Eg: 50 is half way xFromOrigin = width/(100/location.x) yFromOrigin = height/(100/location.y)); To determine the right font size, I've tried, among other variants, this (to no avail): Code: Given a parentSize with a width and height: ratioWidth = (parentSize.width/100); ratioFontSize = (fontSize/100)*(1/3)*(parentSize.width/100); adjustedFontSize = ratioFontSize*fontSize];

 Tags relative, sizes

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post tedpark1212 Advanced Statistics 0 January 9th, 2014 04:20 AM BenFRayfield Complex Analysis 1 August 1st, 2013 04:27 PM atlas227 Trigonometry 2 July 5th, 2011 10:39 AM Singularity Number Theory 1 November 30th, 2009 01:25 PM echilon Algebra 0 December 31st, 1969 04:00 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top