Visual Effects

Pixelated Canvas

Interactive pixelated image rendering with distortion effects and customizable cell sizes.

The PixelatedCanvas component creates an interactive pixelated rendering of images with distortion effects that respond to mouse movement. It features customizable cell sizes, shapes, colors, and interactive behaviors.

Usage

Pixelated Canvas

<template>
  <div class="p-4 bg-elevated rounded-lg">
    <h3 class="text-lg font-bold mb-4 text-highlighted">
      Pixelated Canvas
    </h3>
    <MPixelatedCanvas
      src="https://picsum.photos/400/300"
      :width="400"
      :height="300"
      :cell-size="8"
      class="rounded-lg"
    />
  </div>
</template>

Examples

Basic Pixelated Canvas

Pixelated Canvas

Retro-style pixelated images with customizable pixel sizes for nostalgic effects

<template>
  <div class="p-6 bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-gray-800 dark:to-gray-900 rounded-xl max-w-2xl mx-auto">
    <div class="text-center mb-6">
      <h3 class="text-2xl font-bold mb-3 text-highlighted">
        Pixelated Canvas
      </h3>
      <p class="text-muted">
        Retro-style pixelated images with customizable pixel sizes for nostalgic effects
      </p>
    </div>

    <div class="bg-default rounded-lg p-4 shadow flex justify-center">
      <MPixelatedCanvas
        src="https://picsum.photos/400/300"
        :width="400"
        :height="300"
        :cell-size="6"
        class="rounded-lg"
      />
    </div>

    <div class="mt-6 grid grid-cols-3 gap-3">
      <UButton
        v-for="size in [2, 4, 6]"
        :key="size"
        :color="size === 6 ? 'primary' : 'gray'"
        variant="solid"
        size="sm"
        @click="updatePixelSize(size)"
      >
        {{ size }}px Pixels
      </UButton>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const pixelSize = ref(6)

const updatePixelSize = (size) => {
  pixelSize.value = size
}
</script>

Customize

Customize

Srchttps://picsum.photos/seed/pixelated/400/500
Width400
Height500
Cell Size3
Dot Scale0.9
Shapesquare
Background Color
Grayscale
Responsive
Dropout Strength0.4
Interactive
Distortion Strength3
Distortion Radius80
Distortion Modeswirl
Follow Speed0.2
Sample Average
Tint Color
Tint Strength0.2
Max Fps60
Object Fitcover
Jitter Strength4
Jitter Speed4
Fade On Leave
Fade Speed0.1

Props

Prop Type Default Description
srcrequiredstring-Source URL of the image to pixelate.
widthnumber400Width of the canvas in pixels.
heightnumber500Height of the canvas in pixels.
cellSizenumber3Size of each pixelated cell in pixels.
dotScalenumber0.9Scale factor for the dots within cells (0-1).
shapestring'square'Shape of the pixels: 'circle' or 'square'.
backgroundColorstring'#000000'Background color of the canvas. Accepts a Nuxt UI color token (e.g. primary) or any CSS color.
grayscalebooleanfalseWhether to render the image in grayscale.
classstring''CSS classes to apply to the canvas element.
responsivebooleanfalseWhether the canvas should resize with its container.
dropoutStrengthnumber0.4Strength of edge dropout effect (0-1).
interactivebooleantrueWhether the canvas should respond to mouse interactions.
distortionStrengthnumber3Strength of the distortion effect.
distortionRadiusnumber80Radius of the distortion effect in pixels.
distortionModestring'swirl'Type of distortion: 'repel', 'attract', or 'swirl'.
followSpeednumber0.2Speed at which the effect follows the cursor (0-1).
sampleAveragebooleantrueWhether to average neighboring pixels for smoother results.
tintColorstring'#FFFFFF'Color to tint the image with. Accepts a Nuxt UI color token (e.g. primary) or any CSS color.
tintStrengthnumber0.2Strength of the tint effect (0-1).
maxFpsnumber60Maximum frames per second for animation.
objectFitstring'cover'How the image should fit within the canvas: 'cover', 'contain', 'fill', or 'none'.
jitterStrengthnumber4Strength of the jitter effect.
jitterSpeednumber4Speed of the jitter effect.
fadeOnLeavebooleantrueWhether the effect should fade out when the cursor leaves.
fadeSpeednumber0.1Speed of the fade effect (0-1).

UI

This component's theme exposes the slots below. Override any of them per instance with the ui prop, or app-wide under ui.pixelatedCanvas in app.config.ts.

Prop Type Default Description
uiobject-Per-slot classes merged over the theme defaults.
Slot Props Description
root-
Copyright © 2026