Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL support for kotlin #43

Open
ahmetcj4 opened this issue Aug 19, 2020 · 0 comments
Open

DSL support for kotlin #43

ahmetcj4 opened this issue Aug 19, 2020 · 0 comments

Comments

@ahmetcj4
Copy link

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()
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant