Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
code565 opened this issue Mar 19, 2025 · 1 comment
Open

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

code565 opened this issue Mar 19, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@code565
Copy link

code565 commented Mar 19, 2025

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,
        }`
@code565 code565 added the enhancement New feature or request label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
@code565 and others