Thread Tools Display Modes
06-10-10, 05:15 PM   #1
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
[howto] Finding the correct pixelperfect (frame)width or spacing for .Aura

Trying to optimize how the Aura's look on my target frame, I decided to find out what the perfect spacing setting for it is, to justify icons per row the same way a word processor justifies text. I like to have my icons at a size of 32, to minimize blurriness.

So, with a frame width of 240, and an icon width of 32, I'd calculate like this:
I first calculate how many icons are possible. 7 in total it is. Then, I calculate how much room we have left: framewidth - (iconsize * totalicons) = 240 - (32 * 7) = 16.

Now obviously, you don't want extra pixels to the right, like this:

[_]_[_]_[_]_

But like this:
[_]_[_]_[_]

So the number of points where space needs to be inserted is totalicons - 1. So the spacing would be 16 / (7 - 1) = 2.66.

This brings us to the following code:
Code:
local framewidth = 240
local iconsize = 32
local totalicons = floor (framewidth / iconsize)
local spacing = ( framewidth - (iconsize * totalicons) ) / (totalicons - 1)
On the other hand, I want my icons to look clean, and with a spacing of 2.66, that will still cause my icons to be blurry.

Now we can just reverse the formula.
Code:
(totalicons * iconsize) + ( (totalicons - 1) * spacing ) = framewidth
(7 * 32) + ( (7 - 1) * 2 ) = 236
(7 * 32) + ( (7 - 1) * 3 ) = 242
So, I can either pick 236 (and set spacing to 2), or 242(and set spacing to 3) as my frame width.

Last edited by ravagernl : 06-16-10 at 04:01 AM. Reason: title adjustment
  Reply With Quote
06-14-10, 02:02 PM   #2
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
Even easier than that.

Code:
local function CalcAuras(framewidth,aurasize)
	local numauras = framewidth/aurasize
	local padding = (framewidth-(aurasize*numauras))/numauras
	
	if padding < 1 then
		while padding < 1 do
			numauras = numauras-1
			padding = (framewidth-(aurasize*(numauras-1)))/numauras
		end
	end
	return numauras,padding
end

local numauras,padding = CalcAuras(framewidth,aurasize)
This is adapted from the equation x=(a-(b*(c-1)))/c, which has a surprising amount of uses. I use a variant to resize my raidframes to fit a specific padding ( local raidsize = (width-(raidpadding*4))/5 ) as well.

Edit: I realize that this is about the same effect using almost exactly the same math - The advantage is that you simply pick an aura size and it does the rest for you based on the dimensions of the frame, and you don't have to muck with the math each time you're working with a differently-sized frame.

Excellent howto.
__________________
Former author of EventHorizon Continued and Other Releases.

Last edited by Taroven : 06-14-10 at 02:08 PM.
  Reply With Quote
06-14-10, 03:02 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I think it's even a little more about pixel perfectness instead of just icon size/aura number per row. Isn't it? Good tutorial, nonetheless.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-16-10, 04:00 AM   #4
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Dawn View Post
I think it's even a little more about pixel perfectness instead of just icon size/aura number per row. Isn't it? Good tutorial, nonetheless.
Indeed Maybe I should change the title
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » [howto] Finding the correct (frame)width or spacing for .Aura


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off