Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

scale texture from center

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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!

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X