# Image Dithering

> A dithering image filter with support for 4 dithering modes and multiple color palettes — 2-color, 3-color, and multicolor options, using either predefined colors or colors sampled from the original image. Ported from Paper Shaders (Apache-2.0).

<demo-paper-image-dithering>



</demo-paper-image-dithering>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/paper-image-dithering.json"
```

## Usage

```vue
<script setup lang="ts">
  import PaperImageDithering from '~/components/ui/paper-image-dithering/PaperImageDithering.vue';
</script>

<template>
  <div class="relative h-100 w-full overflow-hidden rounded-lg">
    <PaperImageDithering image="/flowers.webp" type="8x8" :color-steps="2" />
  </div>
</template>
```

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        image
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Source image URL — required, the dithering filter is applied to this image
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        color-front
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#94ffaf'
      </code>
    </td>
    
    <td>
      Foreground color in RGBA
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        color-back
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#000c38'
      </code>
    </td>
    
    <td>
      Background color in RGBA
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        color-highlight
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#eaff94'
      </code>
    </td>
    
    <td>
      Secondary foreground color in RGBA (set same as colorFront for classic 2-color dithering)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        type
      </code>
    </td>
    
    <td>
      <code>
        'random' | '2x2' | '4x4' | '8x8'
      </code>
    </td>
    
    <td>
      <code>
        '8x8'
      </code>
    </td>
    
    <td>
      Dithering type
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        size
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        2
      </code>
    </td>
    
    <td>
      Pixel size of dithering grid (0.5 to 20)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        color-steps
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        2
      </code>
    </td>
    
    <td>
      Number of colors to use, applies to both color modes (1 to 7)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        original-colors
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Use the original colors of the image instead of the color palette
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        inverted
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Inverts the image luminance, doesn't affect the color scheme; not effective at zero contrast
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Animation speed multiplier (0 freezes)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        frame
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Initial/seek frame for deterministic rendering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fit
      </code>
    </td>
    
    <td>
      <code>
        'none' | 'contain' | 'cover'
      </code>
    </td>
    
    <td>
      <code>
        'cover'
      </code>
    </td>
    
    <td>
      How the graphic fits the canvas
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        scale
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Overall zoom level (0.01 to 4)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rotation
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Overall rotation in degrees (0 to 360)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        origin-x
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      Horizontal origin for world positioning (0 to 1)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        origin-y
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      Vertical origin for world positioning (0 to 1)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        offset-x
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Horizontal offset of the graphics center (-1 to 1)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        offset-y
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Vertical offset of the graphics center (-1 to 1)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        world-width
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Virtual world width before canvas fitting
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        world-height
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Virtual world height before canvas fitting
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Additional CSS classes
    </td>
  </tr>
</tbody>
</table>

## Attribution

Powered by [Paper Shaders](https://github.com/paper-design/shaders)
(© Lost Coast Labs, Inc., Apache-2.0) via the framework-agnostic
`@paper-design/shaders` package driven by a Vue 3 mount. This is an
unofficial community port; it is not maintained by Paper.
