From 521b882798bd6ac1ef6bec1936be7092854d4669 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Wed, 16 Mar 2022 14:20:08 +0100 Subject: [PATCH] Add gradient service --- .../src/fm/services/gradient.service.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 projects/common/src/fm/services/gradient.service.ts diff --git a/projects/common/src/fm/services/gradient.service.ts b/projects/common/src/fm/services/gradient.service.ts new file mode 100644 index 0000000..f283b4f --- /dev/null +++ b/projects/common/src/fm/services/gradient.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import {IGradientstop } from '../models/gradient' + +@Injectable({ + providedIn: 'root', +}) +export class GradientService { + constructor() { + } + + getGradientStyle(gradient:IGradientstop[],portrait:boolean = false ):any { + let gd = '{ "background": "linear-gradient(to ' + (portrait?'bottom':'right') +','; + for(var i=0;i0) gd+=","; + gd += `rgba(${gs.color.red},${gs.color.green},${gs.color.blue},${gs.color.alpha/255})`; + gd +=` ${gs.relativestop*100}%` + } + gradient.forEach((gs) => { + }); + gd+=')"}'; + + return JSON.parse(gd); + } +}