I Have hexagon sprites over Image and in back my screenshot image but Here, problem is my image shape square but i want try to fix in hexagon shape
So what i do ? please give me any suggestions
frame without image:
frame with image:
You can have a look at the following blog post:
https://subscription.packtpub.com/book/game_development/9781785885822/1/ch01lvl1sec13/adding-a-circular-mask-to-an-image
Basically, you create your hexagon shape in, for example, Gimp, fill it with white color and leave the rest transparent. Be sure to add the alpha channel to your layer. Export as a PNG and apply it to your sprite with the correct unlit transparent shader.
Create UI Panel And ADD COMPONENT
Image
Mask
In Image Component You set Your Any Shape's Image
And Also Add One Image Into Panel That you mask in this Shape
Check it out for more information https://youtu.be/g3gpXmo8zRo
Related
I'm using a prefab for a box shape, which has a front and back plane.
My images are PNG and have transparent areas around the edge. I dragged the image onto my front plane, which now has a drop-down box for "Shader".
First I chose Shader: "Standard" but the transparent areas of my PNG image weren't transparent, so in order to fix that I changed it to "Sprites / Diffuse"... now the image looks fine (from the front).
However, when I rotate the shape, the image is also visible from the back. I want a way to not see the image / texture from the back.
How can I make the images only visible from the front side of a plane, whilst also preserving the transparency areas of the image / texture?
If you are using the standard built-in shader, you need to set the rendering mode to transparent in order for the texture's alpha channel to be transparent. The sprite shader, by default, forces the rendering of otherwise invisible back-faces, whereas the standard shader does not.
I've created an image in Photoshop to be used as a sprite in Unity and everything works fine while the sprite is scaled at X: 1; Y: 1.
The problem starts when I scale the image up as the border of the image stretches out with the rest of the image. Is there any way to scale an image from its centre or to ignore the image's border when it's scaled?
Here's the example now that I am able to show it:
The rectangle on top is the original image without being scaled up or down and the rectangle on the bottom is scaled at X:5, Y:0.5 but the borders are stretched.
I think that the borders are stretched because it's part of the image and when it's being scaled, the image (including the borders) is just being stretched.
Is there any way to stretch the sprite image but by ignoring the borders?
Are you trying to scale the image and keep the original ratio?
If so, here are the steps:
Hope this helps. Please let me know if you were trying to do something else.
You can use a sliced sprite. The center of the image is scaled to fit the control rectangle but the borders maintain their sizes regardless of the scaling. Check out the Unity doc here: Unity - Manual: Image
I am using http://imageresizing.net/ tools to create an editor.
The user can crop and rotate, but when they crop first and then rotate they lose the correct crop coords because the image coords have changed
for example, given a 100x100 image with a crop of the top left 50x50 pixels would then get rotated clockwise and now shows the crop as the original bottom left 50x50 pixels of the source image.
another example with images:
step one crop:
step two rotate:
coords haven't changed, but now it is no longer the proper crop area
does anyone know of a way to have the crop be relative to the original instead of the origin point?
Are you building something like StudioJS?
StudioJS uses ImageResizer.js to manage the command string and translate co-ordinates.
Consider a workflow where your user crops, rotates, and then re-crops the image. To preserve the original crop you will need to translate the coordinates in javascript. ImageResizer.js can do this.
I have a picture in a PictureBox. I want to rotate it by any angle.
And auto resize the PictureBox according to the rotated picture dimension.
Is there any sample code/project?
You can rotate images inside of pictureboxes and I believe auto resizing is a property you can easily select on pictureboxes. A sample project that shows rotating images can be found here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=25764&lngWId=1
If have an image which is 1024x1250 and a canvas element that is 600x800, I can draw the image to the canvas centered such that the canvas is essentially a smaller view port of the larger image. I then want to allow that center point to move, thus creating the illusion that the viewport is viewing a different portion of the image.
Right now I've done this in sort of a hokey way where I redraw the portion of the image I want to see to the canvas, but I get this feeling that this isnt optimal. Is there a way to render the whole image to the canvas and then somehow "transform" my current center point so this view shift happens behind the scenes hopefully in some native layer?
You can add transformations to the context before drawing any image (rotation, scaling, translation...). What you need is the function context.translate(x,y).
Then, you only need to draw your image at (0,0)
For example, to display the bottom right portion of your image:
ctx.translate (-424, -450);
ctx.drawImage (image, 0, 0);
You can check this link https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Transformations to see a lot of examples on context transformation.