Skip to content

[Feature request]PptxGenJS 导出图形渐变 #331

@code565

Description

@code565

PptxGenJS 的 这个合并支持了导出图形渐变(gitbrent/PptxGenJS#1295) ,但是仓库一直没有合并,尝试了下 发现效果还不错。
这是导出的效果
pptlist
Image
wps
Image

`

       const opacity = el.opacity === undefined ? 1 : el.opacity
        const fillColor = formatColor(el.fill)

        let fill = {
          color: fillColor.color,
          transparency: (1 - fillColor.alpha * opacity) * 100,
        }

        if (el.gradient) {
          const colors = el.gradient.colors
          const stops = []
          colors.map(itemColor => {
            const currentColor = formatColor(itemColor.color)
            stops.push({
              position: itemColor.pos,
              color: currentColor.color,
              transparency: (1 - currentColor.alpha * opacity) * 100,
            })
          })
          fill = {
            type: 'linearGradient',
            stops: stops,
            angle: el.rotate,
            scaled: 1,
            rotWithShape: false,
            tileRect: { t: 0, r: 0.5, b: 0.25, l: 1 },
            flip: 'xy',
          }
        }

        const options: pptxgen.ShapeProps = {
          x: el.left / ratioPx2Inch.value,
          y: el.top / ratioPx2Inch.value,
          w: el.width / ratioPx2Inch.value,
          h: el.height / ratioPx2Inch.value,
          fill: fill,
          points,
        }`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions