如何在 Squib 文本中正确嵌入半透明图像

How to embed semi-transparent images in Squib text properly

我正在尝试通过 Squib 文本方法使用半透明内联(嵌入)png 图像。图像的半透明部分最终渲染得比使用 'png' 方法单独放置图像时要暗得多。

我尝试了不同的混合模式,但其中 none 产生了预期的结果。

require 'squib'

Squib::Deck.new cards: 1 do
  background color: 'white'

  # This image renders as expected
  png file: 'semi-transparent.png', x: 100, y: 100

  # The semi-transparent portions of this image render much darker than expected
  text(str: ':circle:', x: 200, y: 100) do |embed|
    embed.png key: ':circle:', file: 'semi-transparent.png'
  end

  save_png
end

这是输出示例:https://imgur.com/3wrXiBz

任何关于如何让嵌入图像与独立图像相匹配的提示都会很棒。


我在此处针对此问题打开了一个错误:https://github.com/andymeneely/squib/issues/278

我目前正在使用以下函数将我的嵌入标记重新映射为单字符字符串以解决此问题:

def remapTokens(x)
 mapping = {':circle:' => '@', ':square:' => '#', ':triangle:' => '^'}
 mapping.each { |k,v| x.gsub!(k,v) }
 return x
end

这听起来像是一个错误 - 你能把它提交给我们的问题跟踪器吗? https://github.com/andymeneely/squib/issues

如果您还可以将 PNG 上传到导致此问题的那个问题,那就太好了。

Semi-transparent 图像是原生支持的,因此它们以相同的方式呈现。 Squib 对它们的处理方式没有任何不同。 embed.png 和 png 方法调用相同的东西,所以我不确定这里发生了什么。我很乐意调查。

完全披露:我是 Squib 开发者。