Skip to content

DSL support for kotlin #43

@ahmetcj4

Description

@ahmetcj4

With current options we can create sample content with the following code:

        val renderOption = RenderOption().apply {
            content = "Sample content"
            size = 400
            borderWidth = 0
            patternScale = 1f
            clearBorder = true
            color = Color().apply {
                light = 0xFFFFFFFF.toInt()
                dark = 0xFF000000.toInt()
                background = 0xFFFFFFFF.toInt()
            }
        }
        val result = AwesomeQrRenderer.render(renderOption)

However, with a DSL this code can possibly be written in a much more clear way:

        val result = awesomeQrRenderer {
            content = "Sample content"
            size = 400
            borderWidth = 0
            patternScale = 1f
            clearBorder = true
            color {
                light = 0xFFFFFFFF.toInt()
                dark = 0xFF000000.toInt()
                background = 0xFFFFFFFF.toInt()
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions