EFQRCode Style Parameters: Complete Guide to Customizing QR Code Appearance

EFQRCode uses a hierarchical parameter system where EFStyleParams provides common icon and backdrop settings, while each visual style (basic, bubble, 2.5D, line, etc.) defines its own specialized parameter struct for granular control over colors, shapes, and effects.

The EFQRCode library offers extensive customization through structured parameter objects. By configuring style-specific parameter classes that inherit from the base EFStyleParams, developers can control everything from module shapes and colors to center icons and background images. All parameter definitions reside in the Source/Styles/ directory of the efprefix/efqrcode repository.

Common Parameters: EFStyleParams Base Class

Every EFQRCode style parameter set extends EFStyleParams, which provides two shared configuration objects: icon and backdrop. These are defined in [EFQRCodeStyle.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle.swift) (lines 55-74).

Icon Configuration (EFStyleParamIcon)

The icon property accepts an EFStyleParamIcon struct to embed a center logo:

  • image: EFStyleParamImage – Static or animated CGImage source
  • mode: EFImageMode – Scaling behavior (.scaleAspectFit, .scaleAspectFill, etc.)
  • alpha: CGFloat – Opacity from 0 to 1
  • borderColor: CGColor – Border color surrounding the icon
  • percentage: CGFloat – Icon size relative to QR code dimensions (default 0.2)

Source: [EFQRCodeStyle.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle.swift#L38-L48)

Backdrop Configuration (EFStyleParamBackdrop)

The backdrop property controls the background rectangle via EFStyleParamBackdrop:

  • cornerRadius: CGFloat – Rounded corner radius
  • color: CGColor – Background fill color (default white)
  • image: EFStyleParamBackdropImage? – Optional full-size background image
  • quietzone: EFEdgeInsets? – Extra margin insets around the QR code

Source: [EFQRCodeStyle.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle.swift#L105-L118)

Style-Specific Parameter Sets

Each visual style in the EFQRCodeStyle enum defines its own parameter struct extending EFStyleParams. The enum cases and their associated parameter types are:

  • .basicEFStyleBasicParams
  • .bubbleEFStyleBubbleParams
  • .d25EFStyle25DParams
  • .lineEFStyleLineParams
  • .randomRectangleEFStyleRandomRectangleParams
  • .imageFillEFStyleImageFillParams

Basic Style Parameters (EFStyleBasicParams)

Defined in [EFQRCodeStyleBasic.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyleBasic.swift#L63-L73), this style offers granular control over QR code components:

  • data: EFStyleBasicParamsData – Module style (rectangle, round, roundedRectangle, randomRound), scale, and color
  • position: EFStyleBasicParamsPosition – Finder pattern style, size factor, and color
  • align: EFStyleBasicParamsAlign – Alignment pattern configuration
  • timing: EFStyleBasicParamsTiming – Timing pattern configuration

Bubble Style Parameters (EFStyleBubbleParams)

Defined in [EFQRCodeStyleBubble.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyleBubble.swift#L69-L78):

  • dataColor: CGColor – Outer bubble color (default light blue)
  • dataCenterColor: CGColor – Inner circle color (default white)
  • position: EFStyleBubbleParamsPosition – Finder pattern style and color

2.5D Style Parameters (EFStyle25DParams)

Defined in [EFQRCodeStyle25D.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle25D.swift#L71-L99), this creates extruded 3D effects:

  • dataHeight: CGFloat – Extrusion height for data modules
  • positionHeight: CGFloat – Extrusion height for finder patterns
  • topColor: CGColor – Color of top faces (default black)
  • leftColor: CGColor – Color of left faces (default semi-transparent black)
  • rightColor: CGColor – Color of right faces (default semi-transparent black)

Line Style Parameters (EFStyleLineParams)

Defined in [EFQRCodeStyleLine.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyleLine.swift#L73-L81):

  • position: EFStyleLineParamsPosition – Finder pattern styling
  • line: EFStyleLineParamsLine – Line configuration including:
    • direction: EFStyleLineParamsLineDirection – horizontal, vertical, cross, loopback, diagonal, or x
    • thickness: CGFloat – Line thickness from 0 to 1
    • color: CGColor – Line color

Random Rectangle Style Parameters (EFStyleRandomRectangleParams)

Defined in [EFQRCodeStyleRandomRectangle.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyleRandomRectangle.swift#L66-L71):

  • color: CGColor – Base color; each module receives a random color offset derived from this base

Image Fill Style Parameters (EFStyleImageFillParams)

Defined in [EFQRCodeStyleImageFill.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyleImageFill.swift#L73-L85):

  • image: EFStyleImageFillParamsImage? – Background image with scaling mode and alpha
  • backgroundColor: CGColor – Fill color for empty space behind the image
  • maskColor: CGColor – Overlay mask color that creates the QR pattern (default semi-transparent black)

Implementation Examples

Basic Style with Custom Colors and Center Icon

import EFQRCode

let icon = EFStyleParamIcon(
    image: .static(myLogoCGImage),
    mode: .scaleAspectFill,
    alpha: 0.9,
    borderColor: CGColor.createWith(rgb: 0x000000)!,
    percentage: 0.25
)

let data = EFStyleBasicParamsData(
    style: .roundedRectangle,
    scale: 1.0,
    color: CGColor.createWith(rgb: 0x1E90FF)!
)

let position = EFStyleBasicParamsPosition(
    style: .round,
    size: 1.2,
    color: CGColor.createWith(rgb: 0xFF4500)!
)

let params = EFStyleBasicParams(
    icon: icon,
    backdrop: .init(cornerRadius: 8, color: .white),
    position: position,
    data: data,
    align: .init(style: .round, size: 0.8, color: .black),
    timing: .init(style: .rectangle, size: 1, color: .darkGray)
)

let style = EFQRCodeStyle.basic(params: params)
let qr = try EFQRCode.generate(
    content: "https://example.com",
    size: CGSize(width: 500, height: 500),
    style: style
)

Bubble Style Configuration

let bubbleParams = EFStyleBubbleParams(
    icon: nil,
    backdrop: .init(),
    dataColor: CGColor.createWith(rgb: 0x8ED1FC)!,
    dataCenterColor: .white,
    position: EFStyleBubbleParamsPosition(
        style: .round,
        size: 1.0,
        color: CGColor.createWith(rgb: 0x0693E3)!
    )
)

let style = EFQRCodeStyle.bubble(params: bubbleParams)

2.5D Style with Extrusion Heights

let d25Params = EFStyle25DParams(
    dataHeight: 1.5,
    positionHeight: 2.0,
    topColor: CGColor.createWith(rgb: 0x000000)!,
    leftColor: CGColor.createWith(rgb: 0x000000, alpha: 0.2)!,
    rightColor: CGColor.createWith(rgb: 0x000000, alpha: 0.6)!
)

let style = EFQRCodeStyle.d25(params: d25Params)

Line Style with X Pattern

let lineParams = EFStyleLineParams(
    icon: nil,
    backdrop: .init(),
    position: EFStyleLineParamsPosition(
        style: .rectangle,
        size: 1,
        color: CGColor.createWith(rgb: 0x000000)!
    ),
    line: EFStyleLineParamsLine(
        direction: .x,
        thickness: 0.4,
        color: CGColor.createWith(rgb: 0x2E8B57)!
    )
)

let style = EFQRCodeStyle.line(params: lineParams)

Summary

  • EFStyleParams serves as the foundation for all EFQRCode styles, providing standardized icon and backdrop configuration options across every visual variant.
  • Each enum case in EFQRCodeStyle (.basic, .bubble, .d25, .line, .randomRectangle, .imageFill) accepts a dedicated parameter struct that controls style-specific visual properties like extrusion heights, line directions, or color randomization.
  • All parameter structs are defined in the Source/Styles/ directory, with file names following the pattern EFQRCodeStyle[Name].swift, making it straightforward to locate implementation details for specific customization needs.

Frequently Asked Questions

What is the base class for all EFQRCode style parameters?

EFStyleParams is the abstract base class that provides the common icon and backdrop properties used across every EFQRCode style. It is defined in [EFQRCodeStyle.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle.swift) and extended by concrete parameter structs like EFStyleBasicParams and EFStyleBubbleParams.

How do I add a center logo to any EFQRCode style?

Create an EFStyleParamIcon instance with your image source, scaling mode, and size percentage, then pass it to any style parameter struct via the icon property inherited from EFStyleParams. For example, EFStyleBasicParams(icon: myIcon, backdrop: defaultBackdrop, position: posConfig, data: dataConfig, align: alignConfig, timing: timingConfig) embeds the icon in a basic style QR code.

Which parameters control the 3D extrusion effect in 2.5D style?

The EFStyle25DParams struct in [EFQRCodeStyle25D.swift](https://github.com/efprefix/efqrcode/blob/main/Source/Styles/EFQRCodeStyle25D.swift) uses dataHeight and positionHeight to set extrusion depths for data modules and finder patterns respectively. The face colors are controlled by topColor, leftColor, and rightColor properties.

Can I use a background image with any EFQRCode style?

Yes, the backdrop property available in all parameter sets accepts an EFStyleParamBackdrop which includes an optional image: EFStyleParamBackdropImage? field. Additionally, the Image Fill style (EFStyleImageFillParams) provides advanced image integration through the image property, which masks the QR pattern over a background photo using maskColor and backgroundColor for blending.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →