Skip to content

Commit

Permalink
[Frameit] apply rounded corners before framing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Tho虉ni committed Dec 14, 2023
1 parent 7e651ab commit 4e8c2b7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion frameit/lib/frameit/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,23 @@ def put_into_frame
end
end

@image = frame.composite(image, "png") do |c|
maskData = MiniMagick::Tool::Convert.new do |img|
img.size("#{screenshot.size[0]}x#{screenshot.size[1]}")
img.canvas('none')
img.draw("roundrectangle 0,0,#{screenshot.size[0]},#{screenshot.size[1]},100,100")
img << 'png:-'
end

# Create a mask
mask = MiniMagick::Image.read(maskData)

maskedImage = image.composite(mask, "png") do |c|
c.channel("A")
c.compose("DstIn")
c.alpha("on")
end

@image = frame.composite(maskedImage, "png") do |c|
c.compose("DstOver")
c.geometry(offset['offset'])
end
Expand Down

0 comments on commit 4e8c2b7

Please sign in to comment.