Text dynamic size - Animate CC HTML5canvas - text

I need to have a dynamic text field to control by code the size of the text and the text.
I create a dynamic text field on the Stage with the "notification" instance and the following code:
function Message () {
var text1 = new createjs.Text ("Message", "15px Arial", "# ff7700");
text.textBaseline = "alphabetic";
stage.addChild (text);
}
this.notification.text = text1;
What am I doing wrong? From already thank you very much

half resolved
var text = new createjs.Text("Mensaje", "25px Times Bold", "#ff0000");
text.x = 150;
text.y = 150;
text.color = "#0000ff";
text.textAlign = "center";
text.textBaseline = "alphabetic";
stage.addChild(text);

Related

How can I add data to an existing PowerPoint presentation using Node?

I have a PowerPoint template with placeholder data. I need to swap out the placeholder text with some numbers using Node, but I'm having trouble finding a package that supports this. Has anyone seen anything along these lines?
Have you looked into the PowerPoint JavaScript API?
For example:
Call the ShapeCollection.getItem(key) method to get your Shape object
Update the text value via Shape.textFrame.textRange.text
Related example from Microsoft's docs:
// This sample creates a light blue rectangle with braces ("{}") on the left and right ends
// and adds the purple text "Shape text" to the center.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.slides.getItemAt(0).shapes;
const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair);
braces.left = 100;
braces.top = 400;
braces.height = 50;
braces.width = 150;
braces.name = "Braces";
braces.fill.setSolidColor("lightblue");
braces.textFrame.textRange.text = "Shape text";
braces.textFrame.textRange.font.color = "purple";
braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
await context.sync();
});

How do I change font sizes in Heaps?

I'm currently coding in Haxe with Heaps and was checking on how to display text. One thing I want to do is give different font sizes to different texts. Naturally, I declared two Font instances and resized one of them. However, both texts are resized and I cannot manage to have them resize independently. How should I resize font sizes in Heaps?
class Main extends hxd.App{
override function init(){
var font : h2d.Font = hxd.res.DefaultFont.get();
var font2 : h2d.Font = hxd.res.DefaultFont.get();
font2.resizeTo(23);
var tf = new h2d.Text(font);
var tf2 = new h2d.Text(font2);
tf.text = "Hello World\nHeaps is great!";
tf.textColor = 0x00FF00;
tf.x = 100;
tf.y = 100;
tf.textAlign = Center;
tf2.text = "Hello World\nHeaps is great!";
tf2.textColor = 0x00FF00;
tf2.x = 300;
tf2.y = 300;
tf2.textAlign = Center;
s2d.addChild(tf);
s2d.addChild(tf2);
static function main(){
new Main();
}
}
The approach taken does not work because DefaultFont.get() caches the result.
You could either:
Copy the second font by doing var font2 : h2d.Font = font.clone() so that it gets its own properties.
Adjust scaleX and scaleY of Text.

How do I get the shadow color value of some text in Fabric JS?

I can't seem to find any reference in the Fabric.js docs (or anywhere else) on how to get the shadow color value of some text placed on the canvas?
I'm quite new to Fabric.js.
Here's how to get the rgb values of a text shadow color:
...
var activeObject = canvas.getActiveObject();
var shadColor = activeObject.shadow.color;
var shadProps = shadColor.split(",");
var r = shadProps[0];
r = r.replace("rgb(", "");
var g = shadProps[1];
var b = shadProps[2];
b = b.replace(")", "");
console.log('Red: '+r+' Green: '+g+' Blue: '+b);
...
if you have a reference to the fabric object it's located at: fabricObject.shadow.color

Typo3: GIFBUILDER add distorted text on top of image

I want to open a blank catalog image and apply on top of it some skewed (distorted) text.
I have this typoscript snippet:
/**
* Catalog image
*/
lib.catalogImage = IMAGE
lib.catalogImage {
file = GIFBUILDER
file {
XY = 242,270
format = png
quality = 80
10 = IMAGE
10 {
file = EXT:theme/Resources/Public/Images/catalog_blank.jpg
}
15 = IMAGE
15 {
offset = 20,20
file = GIFBUILDER
file {
XY = 150,50
10 = TEXT
10 {
text = Datenblatt
fontSize = 12
offset = 28,110
fontColor = black
niceText = 1
}
20 = SCALE
20 {
params = -matte -virtual-pixel transparent -distort Perspective '0,0,0,0 0,90,0,90 90,0,90,25 90,90,90,65'
}
}
}
}
}
The problem is, I always get the text box white, with no text in it.
What am I doing wrong?
Blank catalog image:
Result image:
EDIT:
I've also tried adding:
niceText.after = -matte -virtual-pixel transparent -distort Perspective '0,0,0,0 0,90,0,90 90,0,90,25 90,90,90,65'
to the TEXT object, according to the docs (https://docs.typo3.org/typo3cms/TyposcriptReference/Gifbuilder/ObjectNames/Index.html), but it doesn't seem to be considered at all.
The result is this:
It looks like niceText doesn't get along with SCALE.
I removed niceText and the text is now displayed correctly.

iTextSharp pdf table cell height issue

I have iTextSharp 5.4.4 (nuget) and have a nice table with a barcode (ean13) and text below it.
I have specific tablecell heights (and cell widths) because I want to print the pdf to an A4 with stickers.
Here is the current layout:
as you can see, there is a rather large gap between the ean13 code and the text below.
here is my C# code:
PdfPCell c = new PdfPCell();
c.FixedHeight = 21.2f * postScriptPointsPerMilimeter; // to get to accurate milimeters
c.HorizontalAlignment = Element.ALIGN_CENTER;
Paragraph p = new Paragraph();
p.Font.Size = 6;
Chunk code = new Chunk(dr["productcode"].ToString());
p.Alignment = Element.ALIGN_CENTER;
p.Add(code);
BarcodeEAN ean13 = new BarcodeEAN();
ean13.CodeType = BarcodeEAN.EAN13;
ean13.Code = dr["ProductEan13"].ToString();
ean13.BarHeight = 4.0f * postScriptPointsPerMilimeter;
var a = ean13.CreateImageWithBarcode(cb, null, null);
a.ScalePercent(90);
c.AddElement(a);
c.AddElement(p);
t.AddCell(c);
My question is to reduce the space between the barcode and the text. I cannot see if it has something to do with the barcode's margins or the paragraph's or maybe both... hard to troubleshoot.
p.Leading = 0;
That was missing. I thought that
p.SpacingBefore = 0;
would do the trick, but it didn't. Leading did!

Resources