# EFQRCode Style Parameters: Complete Guide to Customizing QR Code Appearance

> Master EFQRCode style parameters and customize QR code appearance. Explore common icon/backdrop settings and specialized structs for bubble, 2.5D, line styles, and more.

- Repository: [EFPrefix/efqrcode](https://github.com/efprefix/efqrcode)
- Tags: deep-dive
- Published: 2026-03-01

---

**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](https://github.com/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/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/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/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:

- `.basic` → `EFStyleBasicParams`
- `.bubble` → `EFStyleBubbleParams`
- `.d25` → `EFStyle25DParams`
- `.line` → `EFStyleLineParams`
- `.randomRectangle` → `EFStyleRandomRectangleParams`
- `.imageFill` → `EFStyleImageFillParams`

### Basic Style Parameters (EFStyleBasicParams)

Defined in [[`EFQRCodeStyleBasic.swift`](https://github.com/efprefix/efqrcode/blob/main/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/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/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/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/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/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

```swift
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

```swift
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

```swift
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

```swift
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/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/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.