Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
});
// This implements a blur on a single direction (x or y axis for instance)
// connectSize will inject for us the width/height from context if not provided
export const Blur1D = connectSize(
({ children: t, direction, width, height }) => (
)
);
// BlurXY is a basic blur that apply Blur1D on Y and then on X
export const BlurXY = connectSize(({ factor, children }) => (
{children}
));
export default class Example extends Component {
render() {
const { factor, width } = this.props;
return (
{{ uri: "https://i.imgur.com/iPKTONG.jpg" }}
);
}
function directionForPass(p, factor, total) {
const f = factor * 2 * Math.ceil(p / 2) / total;
switch ((p - 1) % 4) { // alternate horizontal, vertical and 2 diagonals
case 0:
return [f, 0];
case 1:
return [0, f];
case 2:
return [f * NORM, f * NORM];
case 3:
return [f * NORM, -f * NORM];
}
}
export default connectSize(
class Blur extends Component {
props: {
factor: number,
children?: any,
passes: number,
width: any,
height: any,
pixelRatio: number,
};
static defaultProps = {
passes: 2,
};
render() {
const {
}
});
// Same concept than Blur1D except it takes one more prop:
// a map texture that tells the blur intensity for a given position.
export const BlurV1D = connectSize(
({ children: t, direction, map, width, height }) => (
)
);
// And its N-pass version
export const BlurV = connectSize(({ children, factor, map, passes }) => {
const rec = pass =>
pass <= 0
? children
:
{rec(pass - 1)}
;
return rec(passes);
});
export default class Example extends Component {
render() {
const { factor, passes, map } = this.props;
return (
https://i.imgur.com/NjbLHx2.jpg
color += texture2D(image, uv) * 0.2270270270;
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
return color;
}
void main() {
gl_FragColor = blur9(t, uv, resolution, direction * texture2D(map, uv).rg);
}` }
});
// Same concept than Blur1D except it takes one more prop:
// a map texture that tells the blur intensity for a given position.
export const BlurV1D =
connectSize(({ children: t, direction, map, width, height }) =>
);
// And its N-pass version
import {directionForPass} from "../blurmulti";
export const BlurV =
connectSize(({ children, factor, map, passes }) => {
const rec = pass =>
pass <= 0
? children
:
{rec(pass-1)}
;
return rec(passes);
import { Blur1D } from "../blurxy";
// empirical strategy to chose a 2d vector for a blur pass
const NORM = Math.sqrt(2)/2;
export const directionForPass = (p: number, factor: number, total: number) => {
const f = factor * 2 * Math.ceil(p / 2) / total;
switch ((p-1) % 4) { // alternate horizontal, vertical and 2 diagonals
case 0: return [f,0];
case 1: return [0,f];
case 2: return [f*NORM,f*NORM];
default: return [f*NORM,-f*NORM];
}
}
// recursively apply Blur1D to make a multi pass Blur component
export const Blur = connectSize(({ children, factor, passes }) => {
const rec = pass =>
pass <= 0
? children
:
{rec(pass-1)}
;
return rec(passes);
});
export default class Example extends Component {
render() {
const { factor, passes, width } = this.props;
return (
{require("../../iPKTONG.jpg")}
export const directionForPass = (p: number, factor: number, total: number) => {
const f = factor * 2 * Math.ceil(p / 2) / total;
switch ((p - 1) % 4) { // alternate horizontal, vertical and 2 diagonals
case 0:
return [f, 0];
case 1:
return [0, f];
case 2:
return [f * NORM, f * NORM];
default:
return [f * NORM, -f * NORM];
}
};
// recursively apply Blur1D to make a multi pass Blur component
export const Blur = connectSize(({ children, factor, passes }) => {
const rec = pass =>
pass <= 0 ? (
children
) : (
{rec(pass - 1)}
);
return rec(passes);
});
export default class Example extends Component {
render() {
const { factor, passes, width } = this.props;
return (
color += texture2D(image, uv) * 0.2270270270;
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
return color;
}
void main() {
gl_FragColor = blur9(t, uv, resolution, direction * texture2D(map, uv).rg);
}`
}
});
// Same concept than Blur1D except it takes one more prop:
// a map texture that tells the blur intensity for a given position.
export const BlurV1D = connectSize(
({ children: t, direction, map, width, height }) => (
)
);
// And its N-pass version
export const BlurV = connectSize(({ children, factor, map, passes }) => {
const rec = pass =>
pass <= 0
? children
:
{rec(pass - 1)}
;
this.refs.blurMap}
factor={4}
passes={4}>
{img}
);
}
}
const ImageTitle = connectSize(ImageTitleC);
export default class Example extends Component {
render() {
const { title, colorThreshold, image } = this.props;
return (
{image}
);
}
static defaultProps = {
title: "Hello\nSan Francisco\n☻",
colorThreshold: 0.6,
{img}
this.refs.blurMap} factor={4} passes={4}>
{img}
);
}
}
const ImageTitle = connectSize(ImageTitleC);
export default class Example extends Component {
render() {
const { title, colorThreshold, image } = this.props;
return (
{image}
);
}
static defaultProps = {
title: "Hello\nSan Francisco\n☻",
colorThreshold: 0.6,
return (
);
}
}
const Desert = connectSize(DesertPassageLoop);
class ShowCaptured extends PureComponent {
render() {
const { t } = this.props;
return (
);
}
}
export default class Example extends Component {
state = {
surfacePixels: null,
desertPixels: null