Search code examples
luacoronasdk

How can you place a vector file inside a circle in corona sdk?


I have a display.newCircle() and I want to fill it with a vector image. I know how to do this with a 'png' file, but it doesn't work with vectors. I am using an 'svg' file and to import it I use:

  local nanosvg = require( "plugin.nanosvg" )

Solution

  • Basically this worked out to be the answer.

    local nanosvg = require( "plugin.nanosvg" )
    
    local tex = nanosvg.newTexture(
     { filename = "jelly.svg" })
    
    image = display.newImage(tex.filename, tex.baseDir, display.contentCenterX, display.contentCenterY)
    image.width = 100
    image.height = 100