Generate assets as SVG

This commit is contained in:
Pieter Vander Vennet 2020-11-05 12:28:02 +01:00
parent 3502563f92
commit ca858b7ed5
49 changed files with 3551 additions and 91 deletions

View file

@ -1,17 +1,18 @@
import {UIElement} from "./UIElement";
import {FixedUiElement} from "./Base/FixedUiElement";
export class Img {
/**
* If the source is an svg element, it is returned as is.
* If not, the source is wrapped into a 'img'-tag
* @param source
* @constructor
*/
static AsData(source:string){
return `data:image/svg+xml;base64,${(btoa(source))}`;
}
static AsImageElement(source: string): string{
if(source.startsWith("<svg")){
return `<img src="data:image/svg+xml;base64,${(btoa(source))}">`;
}else{
return `<img src="${source}">`
}
return `<img src="${Img.AsData(source)}">`;
}
static AsImage(source: string): UIElement{
return new FixedUiElement(Img.AsImageElement(source))
}
static readonly checkmark = `<svg width="26" height="18" viewBox="0 0 26 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 7.28571L10.8261 15L23 3" stroke="black" stroke-width="4" stroke-linejoin="round"/></svg>`;