How to use the gl-react.connectSize function in gl-react

To help you get started, we’ve selected a few gl-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gre / gl-react / examples / cookbook-expo / shared / examples / blurxy / index.js View on Github external
}
});

// 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" }}
        
      
    );
  }
github gre / gl-react / examples / example-gl-react-camera-effects / src / Effects / Blur.js View on Github external
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 {
github gre / gl-react / packages / cookbook / src / examples / blurmap / index.js View on Github external
}
});

// 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
github gre / gl-react / packages / cookbook-expo / src / examples / blurmap / index.js View on Github external
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);
github gre / gl-react / packages / cookbook-expo / src / examples / blurmulti / index.js View on Github external
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")}
github gre / gl-react / examples / cookbook-expo / shared / examples / blurmulti / index.js View on Github external
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 (
github gre / gl-react / packages / cookbook / src / examples / blurmap / index.js View on Github external
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)}
        ;
github gre / gl-react / cookbook / src / examples / blurimgtitle / index.js View on Github external
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,
github gre / gl-react / packages / cookbook / src / examples / blurimgtitle / index.js View on Github external
{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,
github gre / gl-react / examples / cookbook-expo / shared / examples / demodesertcrt / index.js View on Github external
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