fabricjs group itext and rectangle within rectangle boundaries - fabricjs

Hi Is there some way that Itext and rectangle could be grouped and on clicking on the text, itext is editable with in the rectangle width. In case text is beyond the rectangle, it should wrap to the next line or font size is decreased.

Related

Why four different font size values for one single SVG text element?

I created a SVG file using InkScape 1.0.1. My SVG contains one text element. In InkScape, I have the "Text and Font" dialogue open.
I select my text element, the Text and Font dialogue then shows the font size as 38.1. I double-click on my text (as if I was to edit the text), the Text and Font dialogue now shows the font size as 36, which is the value I choose when I created that text element.
When I open the SVG file in Notepad it contains the following:
...
<text xml:space="preserve" style="font-size:50.8px; ... <tspan style="font-size:48px; ... </tspan></text>
...
(I've replaced irrelevant code with "...")
So, what is my font-size really -- is it 38.1(px?), 36(px?), 50.8px or 48px, and why are there more than one value?
Notes:
I've assumed that the Text and Font dialogue displays the font size in pixels, but no unit is actually displayed in that dialogue.
I notice that the ratio 50.8/48 is the same as the ratio 38.1/36.
I also noticed that the ratio 48/36 is 4/3.
The width and height of my viewBox is the same as the width and height of the SVG view port (as specified in the SVG root element).
I have no nested SVG elements.
Thanks!
The Text+Font editor uses pt as a unit (see tooltip).
There is an outer style and an inner style on your text, and they differ, for whatever reason. The inner style is what counts for the selected part of the text.

How does ios get the color gradient of the UITextView cursor

I want to get the color gradient of the UITextView cursor from top to bottom in iOS,thanks.

How to get the size of sprite in a sprite "Sheet"?

my problem is getting the Sprite in a Sprite "Sheet".
public class Blocks extends Sprite{
public Blocks() throws IOException
{
super(Image.createImage("/blockSprite.png"),20,30);
}
}
"the blockSprite.png contains images of Sprites, many sprites in 1 image"
The problem here is using this line of code, how I am supposed to get the Sprite size/dimension in the image?
Sprite Sheet:
Width - 162
Height - 280
I want to know the width/height of the sprites in the sheet? and how to determine the width/height of the sprites in a Sprite Sheet?
You do know how many sprites are there in each row and column right? then just divide the width with how many sprites are there in a column and divide the height with how many sprites are there in a row.
(I may get the column and row wrong, I'm not native English, but you should just switch the row/column if the first try didn't work out)
One way is to use an image editing software (say GIMP, its free).
What you have to do is,
Open the image in GIMP
Click on the Rectangle selection tool (or press r), your mouse will turn into a cross hair
Now when you click on the image, in the tool box, under tool options you will see the X-Y position of the point you clicked
Cool, now draw a rectangle around the sprite that you want. Zoom in before you do this, so that you are actually selecting the whole
sprite.
Now you will get both the X-Y coordinates of the top-left corner of the rectangle that you drew and the height and width of the image.
After that, just use https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing.
Have fun!!

How to set alignment in a JavaFX TextField?

I need to set allignment of the text in a TextField to right. There is no such under TextField.
Anybody knows how to set alignment in a textfield in javaFX 2.0 ?
Thanks
In JavaFX 2.0, it may not have been possible, but it is in JavaFX 2.1 and ownward using the alignment property.
Programmatically
textField.setAlignment(Pos.CENTER_RIGHT);
or
via FXML
<TextField ... alignment="CENTER_RIGHT"/>
or
via CSS
.text-field {
-fx-alignment: center-right;
}
Possible values
Programmatic/FXML
CSS
Description
BASELINE_CENTER
baseline-center
Represents positioning on the baseline vertically and on the center horizontally.
BASELINE_LEFT
baseline-left
Represents positioning on the baseline vertically and on the left horizontally.
BASELINE_RIGHT
baseline-right
Represents positioning on the baseline vertically and on the right horizontally.
BOTTOM_CENTER
bottom-center
Represents positioning on the bottom vertically and on the center horizontally.
BOTTOM_LEFT
bottom-left
Represents positioning on the bottom vertically and on the left horizontally.
BOTTOM_RIGHT
bottom-right
Represents positioning on the bottom vertically and on the right horizontally.
CENTER
center
Represents positioning on the center both vertically and horizontally.
CENTER_LEFT
center-left
Represents positioning on the center vertically and on the left horizontally.
CENTER_RIGHT
center-right
Represents positioning on the center vertically and on the right horizontally.
TOP_CENTER
top-center
Represents positioning on the top vertically and on the center horizontally.
TOP_LEFT
top-left
Represents positioning on the top vertically and on the left horizontally.
TOP_RIGHT
top-right
Represents positioning on the top vertically and on the right horizontally.
Currently It does not have a support on text field alignment.
I reported this issue to javafx jira team and this feature will be added in version 2.1.
Here is the link.
http://javafx-jira.kenai.com/browse/RT-18410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

How to make Label's text centered vertically?

I tried one by one each of these methods : setting the BgAlign property to CENTER in the Resource Editor , myLabel.getStyle().setBackgroundAlignment(Style.BACKGROUND_IMAGE_ALIGN_CENTER); but the text of the Label is not centered vertically.
So how to make Label's text centered vertically ?
The following image shows the actual alignement of the Label's text :
Label vertical alignment is unsupported only its positioning in relation to an icon.
As far as I recall you are using FlowLayout for every entry which does support vertical alignment see FlowLayout.setValign(Component.CENTER).

Resources