pantoken / packages/core/src / toVectorDrawable
Függvény: toVectorDrawable()
toVectorDrawable(
svg,options?):string
Béta
Konvertáljon egy beágyazott SVG-t Android VectorDrawable XML-karakterlánccá. A vonallapok alapú (Lucide) ikonok strokeColor/strokeWidth-t bocsátanak ki; a kitöltés alapú (Custom) ikonok a fillColor-t bocsátják ki.
Paraméterek
svg
string
Beágyazott SVG jelölés.
options?
Visszatérés
string
A VectorDrawable XML.
Példák
A vonallapok alapú (Lucide) ikon strokeColor-t bocsát ki
ts
import { toVectorDrawable } from "@pantoken/core";
const xml = toVectorDrawable(
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">' +
'<path d="M5 12h14"/></svg>',
);
// → <vector …> with android:strokeColor and android:pathData="M5 12h14"A kitöltés alapú (Custom) ikon árnyalat szín fillColor-t bocsát ki
ts
import { toVectorDrawable } from "@pantoken/core";
toVectorDrawable('<svg viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>', {
color: "#FF0374B5",
});
// → <vector …> with android:fillColor="#FF0374B5"