forked from MapComplete/MapComplete
Generate assets as SVG
This commit is contained in:
parent
3502563f92
commit
ca858b7ed5
49 changed files with 3551 additions and 91 deletions
23
UI/Img.ts
23
UI/Img.ts
|
@ -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>`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue