JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"
http://juliagraphics.github.io/Luxor.jl/
Other
588 stars 71 forks source link

How can I recolor a graphic? #262

Closed guo-yong-zhi closed 1 year ago

guo-yong-zhi commented 1 year ago

I can change the size of an image with translate or scale. Is there any function like colortranslateor colorremap that can change the color of an image?

For example:

function resizesvg(svgdrawing; ratio=1)
    svgnew = Drawing(size(svgdrawing) .* ratio..., :svg)
    scale(ratio...)
    placeimage(svgdrawing)
    finish()
    svgnew 
end

function recolorsvg(svgdrawing, args...; kwargs...)
    svgnew = Drawing(size(svgdrawing)..., :svg)
    I_want_some_magic_here(args...; kwargs...)  # <---
    placeimage(svgdrawing)
    finish()
    svgnew
end

Any workflow suggestions?

cormullion commented 1 year ago

Interesting question. If you're creating the SVG in Luxor, you might be able to gain access to the text source, and - assuming that Cairo's SVG output is reasonably consistent - make text edits to the color definitions. It sounds like a hack, of course, but a fun one... 😂

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.