Skip to content

Commit

Permalink
Merge pull request #28 from alexzhirkevich/highlighting
Browse files Browse the repository at this point in the history
Added highlighting for anchor elements
  • Loading branch information
alexzhirkevich committed May 24, 2023
2 parents 8b2a97c + ed6f83b commit 0fcc86e
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 153 deletions.
6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,21 @@ enum class QrErrorCorrectionLevel(

/**
* ~7% of QR code can be damaged (or used as logo).
*
* QR code might be unreadable if logo is too big.
* If your code has logo, it's better to use [Auto].
* */
Low(ErrorCorrectionLevel.L),

/**
* ~15% of QR code can be damaged (or used as logo).
*
* QR code might be unreadable if logo is too big.
* If your code has logo, it's better to use [Auto].
* */
Medium(ErrorCorrectionLevel.M),

/**
* ~25% of QR code can be damaged (or used as logo).
*
* QR code might be unreadable if logo is too big.
* If your code has logo, it's better to use [Auto].
* */
MediumHigh(ErrorCorrectionLevel.Q),

/**
* ~30% of QR code can be damaged (or used as logo).
*
* QR code might be unreadable if logo is too big.
* If your code has logo, it's better to use [Auto].
* */
High(ErrorCorrectionLevel.H)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.github.alexzhirkevich.customqrgenerator

import androidx.annotation.FloatRange
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorColor
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorShapeModifier


interface IAnchorsHighlighting {
val cornerEyes : HighlightingType
val versionEyes : HighlightingType
val timingLines : HighlightingType
val alpha : Float
}



/**
* Highlighting of the anchor QR code elements.
* Has the most impact when using a background image or color
*
* @param cornerEyes background highlighting of the corner eyes
* @param versionEyes background and draw mode of version eyes
* @param timingLines vertical and horizontal lines of interleaved pixels
* */
data class QrHighlighting(
override val cornerEyes : HighlightingType = HighlightingType.None,
override val versionEyes : HighlightingType = HighlightingType.None,
override val timingLines : HighlightingType = HighlightingType.None,
@FloatRange(from = 0.0, to = 1.0) override val alpha: Float = .75f
) : IAnchorsHighlighting



sealed interface HighlightingType {

object None : HighlightingType

object Default : HighlightingType

class Styled(
val shape : QrVectorShapeModifier? = null,
val color : QrVectorColor? = null
) : HighlightingType
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import com.github.alexzhirkevich.customqrgenerator.style.Neighbors

class QrCodeMatrix(val size : Int){

enum class PixelType { DarkPixel, LightPixel, Background, Logo }
enum class PixelType {
DarkPixel,
LightPixel,
Background,
Logo,
VersionEye,
}

private var types = MutableList(size * size) {
PixelType.Background
Expand Down

0 comments on commit 0fcc86e

Please sign in to comment.