What is the equivalent of border-radius in roblox studio? - roblox

I have been previously working with css and there is a property in that i.e., border-radius with which i can change the radiuses of all the four sides independently. Now i have started making roblox games and i want to round my GUI elements but i found only one plugin that is roundify which rounds all the four corners equally but i want to round them independently (seperate rounding values for different corners). I searched the property panel also but did not find that. Please can anyone tell me how to change the border-radiuses differently.

Take a look at the docs for UICorner.
To use the UICorner UIComponent:
Create a Frame / ImageLabel / ImageButton /TextLabel / TextButton / ViewpointFrame / etc.
Insert a UICorner component as its child
Adjust the round corner radius by changing the CornerRadius property
There are also notes about when to consider using 9-Slice image assets as well.

I think I have used the plugin that you use to roundify the corners, and I looked into how it worked.
What I think is happening here is that the plugin, rather than adding a script, just changed the button to a rounded image.
You would have to find a way to make an image where all corners can be rounded separately, probably with an outside program. From what I see there isn’t really a way to do this with scripts.
Hope this helped.

Related

2D sprite problem when setting up an instant messaging UI

I'm new to Unity and to game development in general.
I would like to make a text-based game.
I'm looking to reproduce the behavior of an instant messenger like messenger or whatapp.
I made the choice to use the Unity UI system for the pre-made components like the rect scroll.
But this choice led me to the following problem:
I have "bubbles" of dialogs, which must be able to grow in width as well as in height with the size of the text. Fig.1
I immediately tried to use VectorGraphics to import .svg with the idea to move runtime the points of my curves of Beziers.
But I did not find how to access these points and edit them runtime.
I then found the "Sprite shapes" but they are not part of the "UI",
so if I went with such a solution, I would have to reimplement
scroll, buttons etc...
I thought of cutting my speech bubble in 7 parts Fig.2 and scaling it according to the text size. But I have the feeling that this is very heavy for not much.
Finally I wonder if a hybrid solution would not be the best, use the
UI for scrolling, get transforms and inject them into Shape sprites
(outside the Canvas).
If it is possible to do 1. and then I would be very grateful for an example.
If not 2. 3. 4. seem feasible, I would like to have your opinion on the most relevant of the 3.
Thanks in advance.
There is a simpler and quite elegant solution to your problem that uses nothing but the sprite itself (or rather the design of the sprite).
Take a look at 9-slicing Sprites from the official unity documentation.
With the Sprite Editor you can create borders around the "core" of your speech bubble. Since these speech bubbles are usually colored in a single color and contain nothing else, the ImageType: Sliced would be the perfect solution for what you have in mind. I've created a small Example Sprite to explain in more detail how to approach this:
The sprite itself is 512 pixels wide and 512 pixels high. Each of the cubes missing from the edges is 8x8 pixels, so the top, bottom, and left borders are 3x8=24 pixels deep. The right side has an extra 16 pixels of space to represent a small "tail" on the bubble (bottom right corner). So, we have 4 borders: top=24, bottom=24, left=24 and right=40 pixels. After importing such a sprite, we just have to set its MeshType to FullRect, click Apply and set the 4 borders using the Sprite Editor (don't forget to Apply them too). The last thing to do is to use the sprite in an Image Component on the Canvas and set the ImageType of this Component to Sliced. Now you can scale/warp the Image as much as you like - the border will always keep its original size without deforming. And since your bubble has a solid "core", the Sliced option will stretch this core unnoticed.
Edit: When scaling the Image you must use its Width and Height instead of the (1,1,1)-based Scale, because the Scale might still distort your Image. Also, here is another screenshot showing the results in different sizes.

How to bend / crook a Flutter widget? (non-affine widget render transform)

Let's say you have some flutter widget, for example, a TabBar. It is rendered in a rectangular box. I need it to be rendered in an arc so that the text and the underline follow part of a circle (or better still, a bezier curve).
How can that be achieved?
This illustrates what I am trying to achieve - bent TabBar widget:
Please note that in this case, the TabBar bends following and an arc (edge of a circle). This is what I need immediately. However, in the future, I might need bending that follows the edge of an eclipse so a solution that allows it would be preferable.
Also, a solution that works for different widgets is preferred.
IMPORTANT: I do NOT want to clip a curved shape of the widget. The entire area of the widget should stay visible. Instead, I need to bend the content of the widget (=bend its render image).
Apologies for the bold font but without it, people will keep posting answers about how to clip a widget which is trivial in comparison and useless for my problem.
An answer "this is currently not supported by Flutter" from authority (e.g. high reputation in Flutter tag or Flutter a team member) will also be accepted.
One approach: Use a CustomPaint to draw lines/areas/etc freely
You can use a CustomPaint to draw whatever curved lines, areas, etc freely. Therefore, you can definitely achieve your goal - since they are nothing but curved lines, areas with curved edges, rotated texts, etc.
That will take a bit of work, but if you encapsulate it well enough, it is not that hard to implement. For example, draw a Path with filled red area, then draw a white arc, then draw several texts with calculated rotations, etc. Sounds like you can do that within maybe hundreds of lines. If you find difficulty implementing this please comment and I will explain.
Another approach: Hack Canvas such that the call to drawLine becomes indeed calls to drawPath, etc.
You may do the following to allow bend/crook for any widget (and their combination, of course), but this may need a bit of engineering. You can make your own Canvas, say, class BendCanvas implements Canvas {}. The BendCanvas.drawLine, for example, has an implementation of Canvas.drawPath with a curved path cooresponding to the input "line". Similar things hold for drawing rectangles, etc. Then you need to hack Flutter's painting logic, such that it takes in your own BendCanvas instead of the original canvas. This is a universal solution, and it is much more efficient (less code) if you plan to have a lot of bend UI; but if only on bend TabBar, maybe use the first approach.
As for the bend text
In the two approaches above, we have mainly described how you draw the bended rectangle (i.e. draw an arbitrary shaped widget). As for bending text, see: https://github.com/flutter/flutter/issues/16477 , which is still an open issue.
Remarks
It is not possible using transformations. As explained in the comments, you already see Transform does not work - it is affine or perspective, which, by definition, will not bend. Then what about other transforms? After some research there seems to be none. Then, what about looking under the scene. We know Flutter uses Skia under it to draw the UI with high performance, then let us search through Skia. However, it does not provide any transformations like bending. So there seems no use.
P.S. I am not that high reputation in Flutter tag, but I did answer >100 Flutter questions (including some dig-into-source-code style ones), and have developed >100k lines of Flutter code in the production app.

How to create a slider without an outline?

I want to create a slider without an outline.
Like this one:
Note rounded edges.
I assume I need to create a sprite for that. Unfortunately, I can't find any good tutorials on sprites for sliders. I think the easiest way would be to edit the built-in one but I don't know how to get it for editing.
This is how the original slider from my Unity looks like:
Note the outline.
So, surprising solution that should be available to all of us.
Put the default slider in and go to the Source Image for both the Background and Handle. Instead of using what is there, change it to another Unity Standard sprite called TouchpadSprite. This should do the trick. Not sure if the fact that this is called 'touchpad'sprite will cause a problem when make a PC game, but I doubt it. FYI the TouchpadSprite is from the "Standard Assets (for Unity 2017.3)" that is available for free in the Unity Asset Store. Feel free to only import the sprite itself. The Asset Pack itself is pretty large, but there is a lot of good/useful stuff in there.
Also, you will have to increase the Pixels Per Unit Multiplier value. My picture shows what I had to increase it to. This will allow you to choose the rounding of your edges as well. Play with it and let me know if it works.
Hope this helps!

Unity3D - Flexible border with changeable line color

I need to create random-shaped (could be rectangular or circular) border for my UI, which can change its size, thickness and color of line. What approach to choose?
9-slice scaling texture is not an option since I need to change colors of line and background dynamically.
Write my own shader - I tried to dive into it and I think I'm not up to it right now. Also I was unable to find shader like this made by someone else.
Create border as a mesh, which is probably expensive in GPU resources.
This must be very common task, I really need advice from experienced unitist. How would you do this?
Thanks.

Dragging images from a scrollable region in Raphael?

I'm investigating the feasibility of using Raphael for a user-research project. One of the features allows for users to drag images onto a canvas and we record where they placed it. The pool of images is potentially quite large and we'll have them in a scrollable box in the tool.
I put together a quick wireframe of the issue I'm looking into since it'll probably be clearer than my explanation.
Please see the wireframe:
I'd stick with straight HTML/CSS and use jQueryUI draggables, as you mention in your comment.
You don't appear to need any of the drawing/display features SVG offers, yet if you went that route, you'd have to build your own custom scrolling behavior (instead of setting a CSS overflow-y rule) and picture layout algorithms (again instead of using CSS floats or something).
You can create a scrollable region using Raphael.
Create the viewport with fixed
dimensions (say 800x600)
Draw the images with increasing y value. After few images, the y value will go beyond 600. It will be drawn but will not be visible in the viewport.
Create a scrollbar using raphael rects. Attach drag events to the scrollbar handle rect.
When the handle is moved, translate all the images accordingly.
For e.g. lets assume in step 2, you had drawn all the images and the bottom most point of the end image is having y value 2000. Assuming the scrollbar has length 500, each dx movement of the handle will have to translate 2000/500 = 4dx. You can calculate the handle length similarly using ratios.
Since everything inside a single Raphael paper the dragging of images will work seamlessly. You will have to maintain the positions of each images.
You might find this demo similar
Remember you can always use getBBox when you drop. In this case it's rects but images would be the same..
http://irunmywebsite.com/raphael/additionalhelp.php?q=bearbones