# Dithered Logo

> Renders any logo as a Floyd-Steinberg dithered particle field with cursor repulsion and click ripples.

<demo-dithered-logo>



</demo-dithered-logo>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/dithered-logo.json"
```

## Usage

```vue
<script setup lang="ts">
  import DitheredLogo from '~/components/ui/dithered-logo/DitheredLogo.vue';
</script>

<template>
  <DitheredLogo image-src="/images/logo.svg" class="size-72" />
</template>
```

The source image is downsampled to a grid, blurred, gamma/contrast
adjusted, then run through serpentine Floyd–Steinberg error-diffusion
dithering. Every resulting dot becomes a physics particle: the cursor
repels nearby particles with a cubic falloff, and every click launches an
expanding ripple band that shoves particles outward before they spring
back. With `invert` (default) the mask is flipped so the logo appears as
negative space inside a rounded plate of particles. `particleColor`
defaults to `currentColor`, so the field follows your text color in light
and dark mode.

## Props

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

<tbody>
  <tr>
    <td>
      <code>
        image-src
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Image/SVG source for the dithered particle field
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grid-size
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      Maximum sampled image dimension before dithering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        scale
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      Relative scale of the logo inside the canvas
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dot-scale
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Multiplier for each rendered particle size
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invert
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Invert the generated dithered mask
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        corner-radius
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.2
      </code>
    </td>
    
    <td>
      Rounded mask radius used when invert mode is on
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        threshold
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        180
      </code>
    </td>
    
    <td>
      Brightness threshold for error-diffusion dithering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        contrast
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Contrast adjustment applied before dithering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        gamma
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Gamma correction applied before dithering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        blur
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        3.75
      </code>
    </td>
    
    <td>
      Blur applied before sampling the grayscale grid
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        diffusion-strength
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Strength of the Floyd–Steinberg error diffusion
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        serpentine
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Alternate dither scan direction on every row
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        particle-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'currentColor'
      </code>
    </td>
    
    <td>
      Particle color
    </td>
  </tr>
</tbody>
</table>

## Credits

Ported from [componentry.fun](https://componentry.dev/docs/components/dithered-logo)
by [@harshjdhv](https://x.com/harshjdhv).
