ExtendScript – Adobe Illustrator set corner radius for each corner - adobe

Illustrator CC offers individual radii for all corners of a rectangle.
Either use the "hollow" cursor to select a corner, then drag the radius-handle, or set the four values in the "Properties > More Options…" dialog.
But how does one read/change these values by JavaScript?
As always the documentation seems outdated or non-existant…
I haven't found any clues in the debugger either, looking at the object properties of a rounded rectangle [PathItem] using a breakpoint with var test = app.activeDocument.selection[0].

Related

How to make a round WKInterfaceButton in watchkit?

iOS can use layer.cornerRadius to make a round UIButton.
Does WKInterfaceButton have this property?
If not, how can I make a round WKInterfaceButton in WatchKit.
If you put an image inside a group, you can then set the radius of the group. This crops the image into a circle. In the picture below, I have:
Group (radius 56)
Group (radius 52)
Image (a square image)
While this example is with an image, you can use the same technique for a button. Previously the dog was clickable as a button so this is doable.
WKInterfaceButton does not have a corner radius property. You can make a circular button by setting a circular image as the button's background image. You can generate the image in code doing something like this: Draw a simple circle uiimage
You don't need an image to make WKInterfaceButton rounded. Instead:
Go to Attributes inspector for the button, and select content type: Group
Inside the button find the group and set its corner radius to whatever you need.
Scroll down the inspector and set both fixed Width and Height to the value equal to the radius doubled. Here you go
You can put whatever you want inside the button, for example a text label. This way you also can make oval buttons.

Rounded buttons in cocos2d-x

With the normal Button class in cocos2d-x, we can create round buttons by using images having the edges rounded off. However the hit testing still "works" on the invisible edges because there is likely just no such feature to ignore the touches that occur on the invisible parts and/or the edges. Does anyone know a fix/workaround for this?
The purpose is to not have the button be tapped if the tap is on an area within the rectangle and on a 0 opacity point.
You should definitely check this IrregularButton class made by Shuai Yuan.

Creating a border container with border sides and separate corner radius

In the Spark BorderContainer component the border sides and corner radius styles were not copied over from the halo component set (see here).
Specifically:
borderSides (left, top, bottom, right)
cornerRadius(TL/TR/BL/BR)
borderThickness(Left/Right/Top/Bottom) * optional
backgroundAttachment (fixed, scroll) * optional
I've been trying to add them manually but I'm having some difficulty.
I've brought over some code from the HaloBorder.as skin and it is sortof working except it is appearing behind the background fill.
It's a lot of code so I pasted it here.
BTW That code was my first approach. But it looks like I could use the insetPath that is already there to draw border. That would be better since it allows me to set all the stroke properties but I don't know how to write path data so I'd have to learn that as well. But at this point I'd be happy to get anything working.
Update:
I found a class that has some methods for generating curved border path data. Look in spark/skins/spark/TabBarButtonSkin.mxml. You can see the code here, in the createPathData() method.

Resizing main window: how do I know which side is used for resizing?

When I resize a window, I can do so using the top,bottom,left or right sides or top-right,top-left,bottom-right or bottom-left corners.
Is there a way to know which one is used when I'm resizing?
I don't know if there is an elegant solution because different operating systems handle borders differently.
My suggestion is
to compute the difference between the current and previous window size each time it is drawn
Get the mouse cursor's position.
If the window X changes, the border used is probably the left or right -- whichever the mouse cursor is closest to. If the Y changes, probably the top or bottom border the cursor is closest to.
If both change, the corner the mouse cursor is closest to is probably it.
A few corner cases may come up. For example, a window can be resized on some systems using the keyboard. It can potentially also be resized programatically, like when the user changes to a resolution too low to contain your window. These things can be handled in most cases by detecting of the mouse button is clicked while the resize is taking place.
Also, it is possible to resize just the width or height from the corner. In these cases, you may have to choose a threshold for mouse distance from corner that would decide whether it is actually at a corner.

how can move the child only inside the parent?

Recently I worked in a project using Flex. Its a Photo editing project. I have took a Canvas and take a image in that canvas using the code canvas.addChild(image) . Now i can move the image freely by using moving code. The image move inside the canvas and outside the canvas. I want to move the image/child only inside the canvas not outside. How can i do this?
There are two ways to do this:
Bounding Rectangle
Scroll Rectangle (or Mask)
Assuming your "moving code" is something like an Event.ENTER_FRAME handler initialized onClick, you want to make it so the image can't leave the bounds of the parent Canvas.
The first case (bounding rectangle) will allow you to drag the image within the retangle but you will always be able to see the whole image. This is how Image croppers work.
To create a bounding rectangle, you'll have to write a fairly detailed method, but the idea behind it is simple. Just get the bounding rectangle from the canvas, and don't let the image.x go below 0 and don't let image.x + image.width go beyond canvas.width. Same with height. Here's a sample Image Cropper in Flex (and the source). Check out how they did it for details.
The second case (scroll rectangle) would allow you to create more of a pan/zoom like container like you see on this Flex Pan/Zoom Map (here's the source). Also, the large image in the Flex Image Cropper on the right is an example of this second case, but they don't have the dragging. That requires that you manipulate the position of the scrollRect property on the canvas. The scrollRect property is a flash.geom.Rectangle defining the Canvas' "viewport". You then change/update the verticalScrollPosition and horizontalScrollPosition properties, so it's backwards (compared to the Bounding Rectangle).
I think if you set clipAndEnableScrolling to true on the canvas, and you drag a child image around inside of it (and image.includeInLayout = true), it should clip the image to only show up inside the canvas. But I'm guessing you want case 1. Just search those properties and you'll find some good examples on google.
Good luck, should be a fun project.
Lance

Resources