Jump to content
Search

The new Ubuntu Wiki is live. Legacy content may be unavailable and page links may have changed. Read the announcement on Discourse.

Module:Sandbox/Shanecrowley/Circle

From Ubuntu Wiki

Description

Renders an SVG circle.

Takes a colour and a radius.

Usage

{{#invoke:Sandbox/Shanecrowley/Circle|main|colour=orange|radius=35}}

Parameters

colour
The fill colour of the circle. Defaults to red.
radius
The radius of the circle. Defaults to 40.

Example


local p = {}

function p.main(frame)
    local colour = frame.args.colour or 'red'
    local radius = tonumber(frame.args.radius) or 40

    local svg = mw.svg.new()
    svg:setAttribute('viewBox', '0 0 100 100')

    svg:setContent(string.format(
        '<circle cx="50" cy="50" r="%d" fill="%s"/>',
        radius,
        colour
    ))

    svg:setImgAttribute('width', '100')
    svg:setImgAttribute('height', '100')

    return svg:toImage()
end

return p