Skip to content

pantoken / packages/core/src / toVectorDrawable

फंक्शन: toVectorDrawable()

toVectorDrawable(svg, options?): string

बीटा

इनलाइन SVG को Android VectorDrawable XML स्ट्रिंग में कन्वर्ट करें। स्ट्रोक-आधारित आइकन (Lucide) जारी करते हैं strokeColor/strokeWidth; फ़िल-आधारित आइकन (Custom) जारी करते हैं fillColor.

पैरामीटर

svg

string

इनलाइन SVG मार्कअप।

options?

VectorDrawableOptions = {}

VectorDrawableOptions.

वापसी

string

VectorDrawable XML।

उदाहरण

एक स्ट्रोक-आधारित (Lucide) आइकन strokeColor जारी करता है

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"

टिंट रंग वाला एक फ़िल-आधारित (Custom) आइकन fillColor जारी करता है

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"