Thread Tools Display Modes
04-18-10, 10:03 PM   #1
seanw
A Murloc Raider
Join Date: Nov 2005
Posts: 5
Problem with tiling texture

Hey all... I'm pretty new to WoW development, but not new to development in general (c#, php, etc... mostly web based langs). Hopefully this is a stupid question and someone will set me straight.

I've got some real simple Lua going on, but I can't seem to figure out my problem. I have an 8x8 tga that I can get to tile horizontally, but it won't tile vertically. It takes the last pixel and stretches it down to my height... I have an example pic here:



Here's the relevant code:

Code:
local framebackdrop = {
  bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
  edgeFile = [[Interface\AddOns\TestAddon\images\new-border]],
  tile = true,
  tileSize = 8,
  edgeSize = 16,
  insets = {
    left = 7,
    right = 7,
    top = 7,
    bottom = 7
  }
}

local titleframebackdrop = {
  bgFile = [[Interface\AddOns\TestAddon\images\diag-tile]],
  tile = true,
  tileSize = 8
}

-- setup the main frame
local frame = self.frame
frame:EnableMouse(true)
frame:SetMovable(true)
frame:SetClampedToScreen(true)
frame:SetSize(400, 300)
frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 100, -100)
frame:SetBackdrop(framebackdrop)
frame:SetBackdropColor(0.22, 0.25, 0.3, 1)


local titleframe = CreateFrame("Frame", nil, TestAddonTitleFrame)
titleframe:SetSize(frame:GetWidth()-16, 32)
titleframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -8)
titleframe:SetBackdrop(titleframebackdrop)
That's all pretty simple stuff I think... shouldn't that 8x8 image be tiling down as well as across?

Thanks in advance!
  Reply With Quote
04-19-10, 03:01 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Play around with the two new commands (SetHorizTile(false),SetVertTile(false) ) perhaps this helps ...
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
04-19-10, 03:11 AM   #3
drdead
A Murloc Raider
Join Date: Oct 2008
Posts: 6
Instead of creating frame for a single texture, create texture itself then assign it with a frame using <your_texture>:SetAllPoints(<frame_to_assign>)

Creating texture will allow you to use
<texture>:SetHorizTile(true or false);
and
<texture>:SetVertTile(true or false);

Here you are the link with all methods for textures
http://wowprogramming.com/docs/widgets/Texture
  Reply With Quote
04-20-10, 09:57 PM   #4
seanw
A Murloc Raider
Join Date: Nov 2005
Posts: 5
Sorry to take so long to reply - that worked like a champ! Thanks!

Code:
local txLines = frame:CreateTexture(nil, "ARTWORK")
--txLines:SetSize(8, 8)
txLines:SetTexture[[Interface\AddOns\TestAddon\images\diag]]
txLines:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -8)
txLines:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -8, -50)
txLines:SetHorizTile(true)
txLines:SetVertTile(true)
It doesn't look like I need to bother with setting a size... It doesn't seem to make a difference when I have it tiled...
  Reply With Quote
04-20-10, 10:05 PM   #5
seanw
A Murloc Raider
Join Date: Nov 2005
Posts: 5
Hmm... actually I do see something goofy. You can see from my code snippet that I'm using <texture>:SetPoint() to specify a region to fill with the tiled image... my tiled image seems to scale with those dimensions rather than just fill it using it's 8x8 texture. Does that make sense? I would expect that regardless of the region created, the texture would maintain that 8x8 aspect.
  Reply With Quote
04-21-10, 01:04 AM   #6
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Originally Posted by seanw View Post
Code:
txLines:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -8)
txLines:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -8, -50)
I'm not good with this but I think it does what you say

You set the one point to topleft and the other to bottomright ... guess
thats why it stretches.

http://www.wowwiki.com/API_Frame_SetBackdrop

I'd play around with tileSize and insets (I've no clue if this is what you want)
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
04-25-10, 12:24 PM   #7
seanw
A Murloc Raider
Join Date: Nov 2005
Posts: 5
Well, it turns out that texture:SetHorizTile() texture:SetVertTile() are bugged and scale the texture out of whack. So I'm back to square one on this tiling thing... if I find a good solution I'll drop it in here. It may be that I create a wide image, and just clip it... I just hate to be wasteful like that.
  Reply With Quote
04-25-10, 12:40 PM   #8
seanw
A Murloc Raider
Join Date: Nov 2005
Posts: 5
I ended up figuring it out faster than I thought I would... here's how I got it working:

Code:
local txLines = frame:CreateTexture(nil, "ARTWORK")

-- Note the last argument, true -- I couldn't find this documented, but
-- it's needed. Without the true argument, the tiling doesn't work
txLines:SetTexture([[Interface\AddOns\MyAddon\images\diag-tile]], true)

-- Set to the top/center of my frame, inset by 8 pixels
txLines:SetPoint("TOP", frame, "TOP", 0, -8)
txLines:SetHeight(32)

-- Set the width to the width of my frame, inset by 8 pixels on each side
txLines:SetWidth(frame:GetWidth() - 16)
    
-- This is the tricky part. See my note below
txLines:SetTexCoord(0,(frame:GetWidth() / 8), 0,4)
in the SetTexCoord command, I originally thought I was limited between 0 and 1. What I didn't realize is that you can go beyond one. For example:

Code:
txLines:SetTexCoord(0,2,0,1)
This tells it to tile twice along X. So in my code above, I'm getting the frame width and dividing by the width of the tile image.

Voila. Maybe that will help another noob like myself one day... hahah! Or better yet, hopefully Blizzard will fix the SetVertTile and SetHorizTile functions.
  Reply With Quote
06-07-10, 09:14 PM   #9
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
Thumbs up

Originally Posted by seanw View Post
I ended up figuring it out faster than I thought I would... here's how I got it working:

Code:
local txLines = frame:CreateTexture(nil, "ARTWORK")

-- Note the last argument, true -- I couldn't find this documented, but
-- it's needed. Without the true argument, the tiling doesn't work
txLines:SetTexture([[Interface\AddOns\MyAddon\images\diag-tile]], true)

-- Set to the top/center of my frame, inset by 8 pixels
txLines:SetPoint("TOP", frame, "TOP", 0, -8)
txLines:SetHeight(32)

-- Set the width to the width of my frame, inset by 8 pixels on each side
txLines:SetWidth(frame:GetWidth() - 16)
    
-- This is the tricky part. See my note below
txLines:SetTexCoord(0,(frame:GetWidth() / 8), 0,4)
in the SetTexCoord command, I originally thought I was limited between 0 and 1. What I didn't realize is that you can go beyond one. For example:

Code:
txLines:SetTexCoord(0,2,0,1)
This tells it to tile twice along X. So in my code above, I'm getting the frame width and dividing by the width of the tile image.

Voila. Maybe that will help another noob like myself one day... hahah! Or better yet, hopefully Blizzard will fix the SetVertTile and SetHorizTile functions.
I'm not a noob, but yes it did help
I had exactly the same problem with the backdrop not tiling in the vertical direction.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Problem with tiling texture


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