Results 1 to 5 of 5
  1. #1
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    98

    Default scale texture from center

    I want to canvas draw and scale texture from the texture center.
    Code:
     
    scaleSize = 1;
    ......
    Canvas.DrawTile(Images[Idx], width* scaleSize, height* scaleSize,ImagesUVs[Idx].U, ImagesUVs[Idx].V, ImagesUVs[Idx].UL, ImagesUVs[Idx].VL, DrawColor,true);
    		 scaleSize += 0.01;
    
    		 if(scaleSize >2)
    		 {
    			scaleSize = 1;
    		 }
    the code above ,always make texture extend to right and down.Is there a good way scale the texture from the texture center?

  2. #2
    Technical Writer - UDN
    Join Date
    Aug 2006
    Posts
    3,814
    Gamer IDs

    Gamertag: ffejnosliw

    Default

    You would have to do it manually by offsetting the drawing position left and up half the width and height of the tile (respectively) from the point you want it centered on.

  3. #3

    Default

    What does your Canvas.SetPos call look like for that? That's where you'd be doing the movement. Basically, instead of thinking about it being from the center think about it as moving the top left corner by half of the scale.

    [edit] Ninja'd by Jeff!

  4. #4
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    98

    Default

    Code:
    	 Canvas.SetPos(OwnerScene.Left + Left - Canvas.OrgX, OwnerScene.Top + Top - Canvas.OrgY);
    above is my origin setpos,when I scale the texture ,I change to
    Code:
    	 Canvas.SetPos(OwnerScene.Left + Left - Canvas.OrgX-(width* (scaleSize-1)), OwnerScene.Top + Top - Canvas.OrgY-(height* (scaleSize-1)));
    but still have no effect,only change the sacle direction.The lower right corner of the texture become the origin

  5. #5
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    98

    Default

    Quote Originally Posted by Angel_Mapper View Post
    What does your Canvas.SetPos call look like for that? That's where you'd be doing the movement. Basically, instead of thinking about it being from the center think about it as moving the top left corner by half of the scale.

    [edit] Ninja'd by Jeff!
    thanks,the pos change should is half of the scale.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.