Skip to documentation

Components

Duotone Halftone

A center-sampled halftone screen whose antialiased dot area follows image luminance.

  • pixi.js@^8.20.1

Preparing preview…

Installation

Choose your framework. The registry installs one component file and its PixiJS dependency.

Installation unavailable

This preview is not assigned to the free or paid catalog. Installation is unavailable.

The registry command writes the component to src/lib/components/ui/DuotoneHalftone.svelte and installs its dependencies.

The registry command writes the component to src/components/ui/DuotoneHalftone.tsx and installs its dependencies.

The registry command writes the component to src/components/ui/DuotoneHalftone.vue and installs its dependencies.

Overview

Duotone Halftone converts source luminance into the area of one antialiased dot per rotated screen cell.

Each cell samples the image at its own center, so color boundaries cannot slice through individual dots and the print structure stays coherent.

Basic usage

The shader fills its parent. Your layout decides whether that parent is a card, hero, or viewport.

Hero.svelte
<script lang="ts">
	import DuotoneHalftone from '$lib/components/ui/DuotoneHalftone.svelte';
</script>

<section class="relative h-128 overflow-hidden">
	<DuotoneHalftone
		class="absolute inset-0"
		src="/images/your-image.jpg"
	/>

	<div class="relative z-10">Your content</div>
</section>
<script lang="ts">
	import DuotoneHalftone from '$lib/components/ui/DuotoneHalftone.svelte';
</script>

<section class="relative h-128 overflow-hidden">
	<DuotoneHalftone
		class="absolute inset-0"
		src="/images/your-image.jpg"
	/>

	<div class="relative z-10">Your content</div>
</section>
import { DuotoneHalftone } from '@/components/ui/DuotoneHalftone';

export function Hero() {
	return (
		<section className="relative h-128 overflow-hidden">
			<DuotoneHalftone
				className="absolute inset-0"
				src="/images/your-image.jpg"
			/>

			<div className="relative z-10">Your content</div>
		</section>
	);
}
import { DuotoneHalftone } from '@/components/ui/DuotoneHalftone';

export function Hero() {
	return (
		<section className="relative h-128 overflow-hidden">
			<DuotoneHalftone
				className="absolute inset-0"
				src="/images/your-image.jpg"
			/>

			<div className="relative z-10">Your content</div>
		</section>
	);
}
<script setup lang="ts">
import DuotoneHalftone from '@/components/ui/DuotoneHalftone.vue';
</script>

<template>
	<section class="relative h-128 overflow-hidden">
		<DuotoneHalftone
			class="absolute inset-0"
			src="/images/your-image.jpg"
		/>

		<div class="relative z-10">Your content</div>
	</section>
</template>
<script setup lang="ts">
import DuotoneHalftone from '@/components/ui/DuotoneHalftone.vue';
</script>

<template>
	<section class="relative h-128 overflow-hidden">
		<DuotoneHalftone
			class="absolute inset-0"
			src="/images/your-image.jpg"
		/>

		<div class="relative z-10">Your content</div>
	</section>
</template>
  • Pair larger cells with a lower Dot scale to expose more of the paper color.
  • Use Screen angle to align the print texture with surrounding layout geometry.

Component API

Types below match the selected Svelte component.

Property Type Default Range / values
class
string
src
string Image URL or data URL
imageFit
"cover" | "fit" | "stretch" "cover" cover, fit, stretch
paperColor
string "#131315"
inkColor
string "#5867D3"
cellSize
number 9 3–32
dotScale
number 1 0.25–1.2
angle
number 0 -45–45
grain
number 0.05 0–0.3
contrast
number 1.15 0.5–2
brightness
number 0 -0.4–0.4
paused
boolean false
interactive
boolean false
maxDpr
number 2 1–3
resolutionScale
number 1 0.25–1
onReady
(backend: ShaderBackend) => void webgpu, webgl
onRendererChange
(backend: ShaderBackend, reason: string) => void webgl
onError
(error: Error) => void
bind:this
Component public instance pause, resume, reset, resize, destroy

Types below match the selected React component.

Property Type Default Range / values
className
string
src
string Image URL or data URL
imageFit
"cover" | "fit" | "stretch" "cover" cover, fit, stretch
paperColor
string "#131315"
inkColor
string "#5867D3"
cellSize
number 9 3–32
dotScale
number 1 0.25–1.2
angle
number 0 -45–45
grain
number 0.05 0–0.3
contrast
number 1.15 0.5–2
brightness
number 0 -0.4–0.4
paused
boolean false
interactive
boolean false
maxDpr
number 2 1–3
resolutionScale
number 1 0.25–1
onReady
(backend: ShaderBackend) => void webgpu, webgl
onRendererChange
(backend: ShaderBackend, reason: string) => void webgl
onError
(error: Error) => void
ref
DuotoneHalftoneHandle pause, resume, reset, resize, destroy

Types below match the selected Vue component.

Property Type Default Range / values
class
string
src
string Image URL or data URL
imageFit
"cover" | "fit" | "stretch" "cover" cover, fit, stretch
paperColor
string "#131315"
inkColor
string "#5867D3"
cellSize
number 9 3–32
dotScale
number 1 0.25–1.2
angle
number 0 -45–45
grain
number 0.05 0–0.3
contrast
number 1.15 0.5–2
brightness
number 0 -0.4–0.4
paused
boolean false
interactive
boolean false
maxDpr
number 2 1–3
resolutionScale
number 1 0.25–1
@ready
(backend: ShaderBackend) => void webgpu, webgl
@rendererchange
(backend: ShaderBackend, reason: string) => void webgl
@error
(error: Error) => void
ref
Component public instance pause, resume, reset, resize, destroy