Starling Quad Retangle Round Corners - starling-framework

How can draw a rectangle with round corners in starling using Quad? I'm not trying to add texture buttons to my sprite sheets.

There is no way to make round corners in Quads. Make texture (draw bitmap or load it and make texture from it) and use sprite or image for that.

Related

How to get what percentage of screen Is covered by sprite mask in unity?

I'm making a scratch effect using line renderer and sprite masks. I want to calculate what percentage is scratched on the screen. How can I do it?
Or else any alternative solution?

How can you get the 3D space coordinates of the 4 corners of an ImageTarget in Vuforia Unity?

I am able to detect images in Vuforia images and overlay 3d objects on them. But I want to draw borders around the ImageTarget.
The problem is that I can only get the center of it such as,
productTarget.transform.position
How can I get the corners of the image ? It is simply a 2D image but Vuforia doesn't have anything to help with this.
There is no way to detect coordinates of the corners, but you can manually calculate it.
This will help you to get the height and width of the image
for example: coordinates of upper left corner will be center - (width/2) - (height/2)
I recommend you just make flat border which you want, and then just resize it on tracking image, because its scale is always the same and vuforia only moves the camera.
image
border
after tracking just child border to image
after parenting

ios game make a mask layer effect

I need a 'mask' layer that covers the whole screen, with the center part (a circle) to be transparent. Then I can move the mask layer around using touch. User are only able to see the transparent part in the middle.
I don't think a png file can help because the file need to be very large to cover the whole screen.
So is it possible to do it by coding?
i found this online, but don't know much about openGL. http://www.cocos2d-iphone.org/forum/topic/7921.
it would be great if i can use a CCMaskLayer and input with the radius. i can handle the touch event by my self.
the attached png file is expected result, the center part is transparent. i need this to cover my screen, and only show the middle part. the red part is covered.
I write a CCMaskLayer to do the exactly same thing.
https://github.com/smilingpoplar/CCMaskLayer
You may solve this task with cropped circle texture in two ways:
1) Draw sprite with circle texture in screen center and draw another 4 sprites around (on top, bottom, left and right sides) with small red texture but scaled to cover all screen.
2) (more elegant but harder to implement) Make your mask layer fullscreen but adjust texture coordinates. In details:
set wrap mode to GL_CLAMP_TO_EDGE to your circle texture
adjust texture coordinates of your layer vertices (to do this you need to subclass base CCLayer):
Here v means vertex position and t - texture coordinates. You need to set correct texture coordinates for four corner vertices of layer. For future if you will want to drag circle you will need to add some offset values to texture coordinates.

i want to change rect UIImage to polygon image with different shape

I want to draw a rectangular UIImage to a polygon UIImage.
Like below example.
to
you will have to look into OpenGL ES, this will definately be able to draw textures onto a plain surface which is tilted, and most likely its your only option
. plus, the advantage being, you can actually animate the tilt in motion, like on coverflow
im not sure quartz can do it, but you will have to check that.

iPhone cocos2d CCTMXTiledMap tile transitions

I am using cocos2d on the iPhone and am wondering if it is possible to use a texture mask in order to create tile transitions / fringe layer. For example, a grass tile and a dirt tile, I would want a tile that had both grass and dirt in it... Has anyone done this, or is the only way to create one tile for every possible transition?
For those who are curious, you can use masks with the following setup:
First draw the mask which should use a black brush on a transparent background. Draw this with src alpha and one-minus src alpha.
Second, draw on top of the mask the texture that you only want to appear over the mask part (the black brush). Draw this texture with dst alpha and gl_zero.
Third, draw the texture that you want to appear over the transparent part of the mask. Draw this texture with one-minus dst alpha and gl_one.
Using this technique, you don't have to make transition / fringe tiles for all of the possible terrains.