Skip to content

pantoken / packages/core/src / toVectorDrawable

Fonksiyon: toVectorDrawable()

toVectorDrawable(svg, options?): string

Beta

Satır içi bir SVG'yi Android VectorDrawable XML dizesine dönüştürün. Çizgi tabanlı simgeler (Lucide) strokeColor/strokeWidth; dolgu tabanlı simgeler (Custom) fillColor üretir.

Parametreler

svg

string

Satır içi SVG işaretlemesi.

options?

VectorDrawableOptions = {}

VectorDrawableOptions.

Döndürür

string

VectorDrawable XML'si.

Örnekler

Çizgi tabanlı (Lucide) bir simge strokeColor üretir

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"

Bir tonlama rengine sahip dolgu tabanlı (Custom) bir simge fillColor üretir

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"