Open mikhailkuts opened 9 years ago
Hi.
I've been looking at this for a little bit, but I dont see anything at all within the drawn square here. I cant get the renderTexture to work at all?
Could you provide a screen shot of what you see?
I can absolutely agree that "nothing" doesn't seem right :)
The feature works as can be expected with a regular texture for me, but not with a RenderTexture
Edit: Well, maybe not. When I do beginTextureFill and then draw a circle, things get weird. So ok, this is broken.I'm wondering how the fill stuff is supposed to work, and I really don't understand the "scale(1/256, 1/256)" call mentioned in the other thread, in the Fill class constructor
Hi! Thanks for quick respond )
When I used texture from bitmap data (Texture.fromBitmapData) - I have same result: circle dimensions are less than they should be.
Example code above drawing fill of a circle texture with 100 radius, but I see next:
Circle should have radius 100.
The problem here is that your texture is "officially" 200x200, but in "reality" it is 256x256, and the texture coordinates gets mapped out between 0.0-1.0 , ie , all the way to 256 of the rect.
So, unfortunately, the scaling has to be done by a UV-matrix. Basically this:
var rectWidth:Number = 200;
var rectHeight:Number = 200;
var uvMatrix:Matrix = new Matrix();
uvMatrix.scale(getNextPowerOfTwo(texture.width) / texture.width , getNextPowerOfTwo(texture.height) / texture.height );
uvMatrix.scale(rectWidth / texture.width , rectHeight / texture.height );
shape.graphics.beginTextureFill(texture, uvMatrix);
shape.graphics.drawRect(0, 0, rectWidth, rectHeight);
I am most likely doing the math wrong, I have no real time to devote to this at the moment. But the uvMatrix has to be scaled to compensate for the ratio of the power of two width and height of the texture.
And, yes, this is a severe limitation on the usability of the graphics API.
Thanks a lot for your help, I'll try this solution :)
Hi @IonSwitz ,
I am using latest Starling 2 and beginTextureFill does not work at all. When I am drawing with line to nothing is visible.
Do you maybe know to reason?
Normal color fill with beginFill(0xFF0000, 1) is working great?
Hi, I reopening issue https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/82#issuecomment-29246907 . Problem still exist. Example for reproduce:
var renderTxt:RenderTexture = new RenderTexture(200, 200);
var shape:Shape = new Shape();
shape.graphics.beginFill(0xFF02F1); shape.graphics.drawCircle(100, 100, 100); shape.graphics.endFill();
renderTxt.draw(shape);
shape.graphics.clear();
view.addChild(shape);
shape.graphics.beginTextureFill(renderTxt);
shape.graphics.moveTo(0, 0); shape.graphics.lineTo(200, 0); shape.graphics.lineTo(200, 200); shape.graphics.lineTo(0, 200);
shape.graphics.endFill();
Filled circle is smaller than it should be.