LCharacter Reference Manual & Mixer Integration Guide
The LCharacter class is a high-performance vector graphics and Character Generator (CG) overlay engine based on the Cairo 2D graphics API. It provides broadcasting overlay features (lower-thirds, scoreboards, scrolling tickers, and logos) drawn directly on transparent video frames using CPU or GPU rasterization.
It supports static and dynamic text wrapping, shape rendering with borders, gradients, alpha-transparency, scrolling crawls, vertical tickers, custom images, loopable transparent video items, grouping, and XML template serialization.
1. API Reference & Key Methods
📌 Ingestion & Element Addition
LCGTextItem* addItem(std::string id, int x, int y, int w, int h, LCGTextProps props)
Adds a text field element with background, outline, and shadow configurations.LCGCrawlItem* addItem(std::string id, int x, int y, int w, int h, LCGCrawlProps props)
Adds a scrolling crawl ticker bar (e.g. news crawl).LCGTickerItem* addItem(std::string id, int x, int y, int w, int h, LCGTickerProps props)
Adds a multi-page vertical ticker rolling item.LCGImageItem* addItem(std::string id, int x, int y, int w, int h, LCGImageProps props)
Adds a raster image overlay (.png,.jpg).LCGVideoItem* addItem(std::string id, int x, int y, int w, int h, LCGVideoProps props)
Adds a looping video element supporting transparency (ProRes 4444 / WebM alpha).LCGRectItem* addItem(std::string id, int x, int y, int w, int h, LCGRectProps props)
Adds a background rectangle shape (solid or gradient, rounded corners).
📌 Modification & Lifecycle
void updateItem(std::string id, int x, int y, int w, int h, float alpha, bool show, [PropsStruct] props)
Updates coordinates, transparency (alpha0.0fto1.0f), visibility, and visual properties. (Overloads exist for all 6 element type properties).LCGItem* getItem(std::string id)
Retrieves a generic element pointer by ID. Must be cast to the appropriate subclass to access type-specific properties.void showItem(std::string id_or_group, bool show)
Shows or hides an item or a group.void remove(const std::string& id)
Deletes an element from the canvas.void forceUpdate()
Triggers a redraw of the Cairo canvas.void setFPS(double fps)
Sets the compositing frame rate (e.g.,50.0).
📌 XML Configuration Save & Load
void saveToXMLFile(const std::string& filePath)
Saves the current canvas state, groups, and elements into an XML file.void loadFromXMLFile(const std::string& filePath)
Clears the current canvas and loads the state from an XML template.void insertFromXMLFile(const std::string& filePath)
Merges elements from an XML template into the current canvas.
📌 Grouping Operations
std::string group(const std::vector<std::string>& itemIDs)
Groups multiple elements under a single generated group ID for bulk translation or hiding.void unGroup(const std::string& groupID)
Dissolves a group.LCGGroup* getGroupObject(const std::string& groupID)
Retrieves a group handle to modify offset position (x,y), scale, and visibility.
2. Base Element Properties: LCGItem & Group Class: LCGGroup
LCGItem Base Class
All items added to LCharacter (LCGTextItem, LCGCrawlItem, etc.) inherit the base properties of LCGItem. These parameters can be read or modified directly on the item pointer:
| Field | Type | Default Value | Description |
|---|---|---|---|
id |
std::string |
"" |
Unique identifier for the element. |
x |
float |
0.0f |
Current horizontal coordinate in pixels. |
y |
float |
0.0f |
Current vertical coordinate in pixels. |
startX |
float |
0.0f |
Default starting horizontal coordinate (reference position). |
startY |
float |
0.0f |
Default starting vertical coordinate (reference position). |
w |
int |
0 |
Width of the bounding box in pixels. |
h |
int |
0 |
Height of the bounding box in pixels. |
show |
bool |
true |
Visibility switch (true to render, false to hide). |
alpha |
float |
1.0f |
Opacity scale factor (0.0f to 1.0f). |
pGroup |
LCGGroup* |
nullptr |
Pointer to the parent group object (or nullptr if independent). |
move |
std::string |
"None" |
Motion style key (e.g. "None", "Horizontal", "Vertical"). |
speed |
float |
0.0f |
Animation/motion velocity factor. |
loop |
bool |
true |
If "true", loops internal item animations (e.g. video overlays). |
LCGGroup Class
Defines a collection of elements that can be moved or toggled as a single unit:
| Field | Type | Default Value | Description |
|---|---|---|---|
id |
std::string |
"" |
Unique group identifier. |
show |
bool |
true |
Group visibility switch. |
x |
float |
0.0f |
Group horizontal offset in pixels. |
y |
float |
0.0f |
Group vertical offset in pixels. |
w |
float |
0.0f |
Group bounding box width in pixels. |
h |
float |
0.0f |
Group bounding box height in pixels. |
items |
std::vector<LCGItem*> |
{} |
Vector of items inside the group. |
3. Subclass Items & Property Structs
To modify properties directly on the item pointers returned by addItem or getItem, you must access the specific member properties belonging to these subclasses:
📌 LCGTextItem (Static/Dynamic Text)
Defines a text block layout:
class NOW2SDK_EXPORT LCGTextItem : public LCGItem {
public:
LCGTextProps props; // Text properties struct
};
LCGTextProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
text |
std::string |
"" |
Text contents. Supports dynamic tags: %SystemTime%, %Date%, %Timer%. |
font |
std::string |
"Arial" |
Font family name. |
fontSize |
int |
40 |
Font size in pixels. |
color |
LCGColor |
"#FFFFFF" |
Font hex color. |
textAlpha |
int |
255 |
Font opacity (0 to 255). |
letterSpacing |
float |
0.0f |
Spacing between characters. |
autoShrink |
bool |
false |
Shrinks font size automatically if the text exceeds bounding width. |
padding |
int |
0 |
Inner padding in pixels. |
outlineSize |
int |
0 |
Text outline stroke size in pixels. |
outlineColor |
LCGColor |
"#000000" |
Text outline stroke color. |
hAlign |
std::string |
"Left" |
Horizontal alignment: "Left", "Center", "Right". |
vAlign |
std::string |
"Center" |
Vertical alignment: "Top", "Center", "Bottom". |
bgType |
std::string |
"None" |
Background type: "None", "Solid", "Gradient". |
bgColor |
LCGColor |
"#000000" |
Solid background fill color. |
bgGradientStartColor |
LCGColor |
"#FF0000" |
Gradient starting color. |
bgGradientEndColor |
LCGColor |
"#000000" |
Gradient ending color. |
bgAlpha |
int |
255 |
Background block opacity (0 to 255). |
bgRadius |
int |
0 |
Corner rounding radius for background box in pixels. |
bgShadowOffsetX |
float |
0.0f |
Horizontal drop shadow offset. |
bgShadowOffsetY |
float |
0.0f |
Vertical drop shadow offset. |
bgShadowAlpha |
int |
0 |
Background shadow opacity (0 to 255). |
bgShadowColor |
LCGColor |
"#000000" |
Background shadow color. |
borderColor |
LCGColor |
"#FFFFFF" |
Background box border outline color. |
borderSize |
int |
0 |
Background box border outline thickness. |
borderAlpha |
int |
255 |
Background box border outline opacity. |
textShadowOffsetX |
float |
0.0f |
Text character drop shadow horizontal offset. |
textShadowOffsetY |
float |
0.0f |
Text character drop shadow vertical offset. |
textShadowAlpha |
int |
0 |
Text character shadow opacity. |
textShadowColor |
LCGColor |
"#000000" |
Text character shadow color. |
📌 LCGCrawlItem (Scrolling News Tickers)
Defines a continuous text crawl marquee:
class NOW2SDK_EXPORT LCGCrawlItem : public LCGItem {
public:
LCGCrawlProps crawlProps; // Crawl ticker properties
};
LCGCrawlProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
text |
std::string |
"" |
Text contents. Supports dynamic tags: %SystemTime%, %Date%, %Timer%. |
font |
std::string |
"Arial" |
Font family name. |
fontSize |
int |
40 |
Font size in pixels. |
color |
LCGColor |
"#FFFFFF" |
Font hex color. |
textAlpha |
int |
255 |
Font opacity (0 to 255). |
letterSpacing |
float |
0.0f |
Spacing between characters. |
autoShrink |
bool |
false |
Shrinks font size automatically if the text exceeds bounding width. |
padding |
int |
0 |
Inner padding in pixels. |
outlineSize |
int |
0 |
Text outline stroke size in pixels. |
outlineColor |
LCGColor |
"#000000" |
Text outline stroke color. |
hAlign |
std::string |
"Left" |
Horizontal alignment: "Left", "Center", "Right". |
vAlign |
std::string |
"Center" |
Vertical alignment: "Top", "Center", "Bottom". |
bgType |
std::string |
"None" |
Background type: "None", "Solid", "Gradient". |
bgColor |
LCGColor |
"#000000" |
Solid background fill color. |
bgGradientStartColor |
LCGColor |
"#FF0000" |
Gradient starting color. |
bgGradientEndColor |
LCGColor |
"#000000" |
Gradient ending color. |
bgAlpha |
int |
255 |
Background block opacity (0 to 255). |
bgRadius |
int |
0 |
Corner rounding radius for background box in pixels. |
bgShadowOffsetX |
float |
0.0f |
Horizontal drop shadow offset. |
bgShadowOffsetY |
float |
0.0f |
Vertical drop shadow offset. |
bgShadowAlpha |
int |
0 |
Background shadow opacity (0 to 255). |
bgShadowColor |
LCGColor |
"#000000" |
Background shadow color. |
textShadowOffsetX |
float |
0.0f |
Text character drop shadow horizontal offset. |
textShadowOffsetY |
float |
0.0f |
Text character drop shadow vertical offset. |
textShadowAlpha |
int |
0 |
Text character shadow opacity. |
textShadowColor |
LCGColor |
"#000000" |
Text character shadow color. |
textMove |
std::string |
"Horizontal" |
Scroll direction (e.g. "Horizontal" or "Vertical"). |
textSpeed |
float |
-5.0f |
Pixels per frame offset. Negative scrolls left. |
separatorImage |
std::string |
"" |
Path to image file used as separator between text repetitions. |
textSeparator |
std::string |
" - " |
Text used as separator if no image is defined. |
separatorPadding |
int |
20 |
Padding spaces around separator. |
borderColor |
LCGColor |
"#FFFFFF" |
Background box border outline color. |
borderSize |
int |
0 |
Background box border outline thickness. |
borderAlpha |
int |
255 |
Background box border outline opacity. |
📌 LCGTickerItem (Vertical Rolling Page Tickers)
Defines a vertical slide roll ticker:
class NOW2SDK_EXPORT LCGTickerItem : public LCGItem {
public:
LCGTickerProps tickerProps; // Rolling ticker properties
};
LCGTickerProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
text |
std::string |
"" |
Text contents. Supports dynamic tags: %SystemTime%, %Date%, %Timer%. |
font |
std::string |
"Arial" |
Font family name. |
fontSize |
int |
40 |
Font size in pixels. |
color |
LCGColor |
"#FFFFFF" |
Font hex color. |
textAlpha |
int |
255 |
Font opacity (0 to 255). |
letterSpacing |
float |
0.0f |
Spacing between characters. |
autoShrink |
bool |
false |
Shrinks font size automatically if the text exceeds bounding width. |
padding |
int |
0 |
Inner padding in pixels. |
outlineSize |
int |
0 |
Text outline stroke size in pixels. |
outlineColor |
LCGColor |
"#000000" |
Text outline stroke color. |
hAlign |
std::string |
"Left" |
Horizontal alignment: "Left", "Center", "Right". |
vAlign |
std::string |
"Center" |
Vertical alignment: "Top", "Center", "Bottom". |
bgType |
std::string |
"None" |
Background type: "None", "Solid", "Gradient". |
bgColor |
LCGColor |
"#000000" |
Solid background fill color. |
bgGradientStartColor |
LCGColor |
"#FF0000" |
Gradient starting color. |
bgGradientEndColor |
LCGColor |
"#000000" |
Gradient ending color. |
bgAlpha |
int |
255 |
Background block opacity (0 to 255). |
bgRadius |
int |
0 |
Corner rounding radius for background box in pixels. |
bgShadowOffsetX |
float |
0.0f |
Horizontal drop shadow offset. |
bgShadowOffsetY |
float |
0.0f |
Vertical drop shadow offset. |
bgShadowAlpha |
int |
0 |
Background shadow opacity (0 to 255). |
bgShadowColor |
LCGColor |
"#000000" |
Background shadow color. |
textShadowOffsetX |
float |
0.0f |
Text character drop shadow horizontal offset. |
textShadowOffsetY |
float |
0.0f |
Text character drop shadow vertical offset. |
textShadowAlpha |
int |
0 |
Text character shadow opacity. |
textShadowColor |
LCGColor |
"#000000" |
Text character shadow color. |
textMove |
std::string |
"Up" |
Rolling direction: "Up" or "Down". |
textMoveDuration |
float |
5.0f |
Frame dwell delay time in seconds before switching pages. |
borderColor |
LCGColor |
"#FFFFFF" |
Background box border outline color. |
borderSize |
int |
0 |
Background box border outline thickness. |
borderAlpha |
int |
255 |
Background box border outline opacity. |
📌 LCGImageItem (Image Overlay)
Defines a static raster image overlay:
class NOW2SDK_EXPORT LCGImageItem : public LCGItem {
public:
LCGImageProps imageProps; // Image path struct
};
LCGImageProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
path |
std::string |
"" |
Path to local image file (.png, .jpg, etc.) that will be loaded and scaled into the item bounds. |
📌 LCGVideoItem (Video Loop Overlay)
Defines a loopable transparent video overlay:
class NOW2SDK_EXPORT LCGVideoItem : public LCGItem {
public:
LCGVideoProps videoProps; // Video path struct
};
LCGVideoProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
path |
std::string |
"" |
Path to local transparent video file (.mov with alpha or .webm) that will loop inside the item bounds. |
📌 LCGRectItem (Vector Rectangle Shape)
Defines a vector rectangle block:
class NOW2SDK_EXPORT LCGRectItem : public LCGItem {
public:
LCGRectProps rectProps; // Rectangle styling properties
};
LCGRectProps Struct
| Field | Type | Default Value | Description |
|---|---|---|---|
bgType |
std::string |
"Solid" |
Fill type: "Solid", "Gradient". |
bgColor |
LCGColor |
"#FFFFFF" |
Solid color fill. |
bgGradientStartColor |
LCGColor |
"#FFFFFF" |
Gradient starting color. |
bgGradientEndColor |
LCGColor |
"#000000" |
Gradient ending color. |
bgAlpha |
int |
255 |
Opacity (0 to 255). |
bgRadius |
int |
0 |
Corner rounding radius in pixels. |
borderColor |
LCGColor |
"#FFFFFF" |
Border outline color. |
borderSize |
int |
0 |
Border outline thickness. |
borderAlpha |
int |
255 |
Border outline opacity. |
bgShadowOffsetX |
float |
0.0f |
Background drop shadow horizontal offset. |
bgShadowOffsetY |
float |
0.0f |
Background drop shadow vertical offset. |
bgShadowAlpha |
int |
0 |
Background drop shadow opacity. |
bgShadowColor |
LCGColor |
"#000000" |
Background drop shadow color. |
4. Mixer Integration Example
The following C++ example demonstrates how to integrate LCharacter inside LMixer to overlay branding elements (logo, scrolling crawl, and styled lower-third) over video playback.
mainwindow.cpp
#include "mainwindow.h"
#include "now2sdk.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
m_lFile(new LFile()),
m_lMixer(new LMixer()),
m_lCG(new LCharacter()),
m_lPreview(new LPreview())
{
// 1. Configure Mixer Resolution (1080p50)
videoFormatProps format;
format.setVideoFormat = vF::HD1080_50p;
m_lMixer->setVideoFormat(format);
// 2. Add Background Video Layer (z-index: 0)
m_lMixer->addLayer("video_bg", m_lFile, 0, 0, 0, 255, 1920, 1080);
// 3. Add CG Character Generator Overlay Layer (z-index: 1)
m_lMixer->addLayer("cg_overlay", m_lCG, 1, 0, 0, 255, 1920, 1080);
// 4. Configure Preview Widget
m_lPreview->setProps("ui_framework", "qt");
m_lPreview->previewEnable(ui->programView, true, true);
m_lPreview->previewObject(m_lMixer);
// Load file and play
m_lFile->fileNameSet("/media/background.mp4");
m_lFile->play();
}
MainWindow::~MainWindow() {
m_lFile->stop();
delete m_lPreview;
delete m_lFile;
delete m_lMixer;
delete m_lCG;
}
// ─── 1. Lower Third Overlay (Background block with gradient + two text rows) ───
void MainWindow::showLowerThird() {
m_lCG->remove("lt_bg");
m_lCG->remove("lt_title");
m_lCG->remove("lt_desc");
// Background block
LCGRectProps bg;
bg.bgType = "Gradient";
bg.bgGradientStartColor = "#0055ff";
bg.bgGradientEndColor = "#020215";
bg.bgAlpha = 240;
bg.bgRadius = 8;
m_lCG->addItem("lt_bg", 150, 800, 700, 120, bg);
// Header Text (Courier New, Outline)
LCGTextProps title;
title.text = "ALİ SABER";
title.font = "Courier New";
title.fontSize = 36;
title.color = "#FFFFFF";
title.outlineSize = 1;
title.outlineColor = "#000000";
title.hAlign = "Left";
title.padding = 20;
m_lCG->addItem("lt_title", 150, 800, 700, 70, title);
// Subtitle Text
LCGTextProps desc;
desc.text = "Lead Broadcast Engineer";
desc.font = "Courier New";
desc.fontSize = 22;
desc.color = "#55AAFF";
desc.hAlign = "Left";
desc.padding = 20;
m_lCG->addItem("lt_desc", 150, 860, 700, 50, desc);
m_lCG->forceUpdate();
}
// ─── 2. Scrolling Crawl Ticker (News Crawl at bottom) ───
void MainWindow::showNewsTicker() {
m_lCG->remove("ticker");
LCGCrawlProps crawl;
crawl.text = "::: NOW2SDK CAIRO GRAPHICS ENGINE DEMO ::: EXTREMELY LOW LATENCY RASTERIZATION :::";
crawl.font = "Arial";
crawl.fontSize = 30;
crawl.color = "#FFFF00";
crawl.bgType = "Solid";
crawl.bgColor = "#111111";
crawl.bgAlpha = 220;
crawl.textMove = "Horizontal";
crawl.textSpeed = -4.0f; // Scroll speed to the left (4 pixels per frame)
m_lCG->addItem("ticker", 0, 980, 1920, 80, crawl);
m_lCG->forceUpdate();
}
// ─── 3. Clear CG overlays ───
void MainWindow::clearOverlays() {
m_lCG->remove("lt_bg");
m_lCG->remove("lt_title");
m_lCG->remove("lt_desc");
m_lCG->remove("ticker");
m_lCG->forceUpdate();
}