2 karma · joined Dec 25, 2023 (2y ago) · 3 submissions
comment 1y ago · link · parent
You can name hooks whatever you want. The `use` prefix is just a linting thing. Once transpiled to JS, there isn't really any way for React to know whether you prefixed your hook with `use`.
I understand the mistake though. The React docs state `You must follow these naming conventions` when talking about the `use` prefix. But that's all it is -- a convention.
comment 2y ago · link · parent
The reason for isolating the middle pixel is because it is the only pixel in the cell that contains the average color of the cell (after box blurring). Once isolated, we can use feMorphology to dilate this pixel so that it fills the cell.
Here is a React version to more clearly demonstrate the relationship between cell size and all of the attributes: https://codepen.io/tommyquant/pen/yLwyoGO
comment 2y ago · link · parent
<div id="comparator">
<img src="https://meyerweb.com/eric/thoughts/wp-content/uploads/wikipedia-home.png" alt="">
<img src="https://meyerweb.com/eric/thoughts/wp-content/uploads/wikipedia-home.png" alt="">
</div>
<svg xmlns='http://www.w3.org/2000/svg'>
<filter id='pixelate'>
<!-- Perform two 1D blurs (vertical and horizontal pass). This is a more efficient way of doing a 2D box blur -->
<feConvolveMatrix order="5 1" kernelMatrix="1 1 1 1 1"/>
<feConvolveMatrix order="1 5" kernelMatrix="1 1 1 1 1" result="blur"/>
<!-- Generate tiling pattern -->
<feFlood x="2" y="2" height="1" width="1"/>
<feComposite width="5" height="5"/>
<feTile/>
<!-- Combine tiling pattern and blurred image -->
<feComposite in="blur" operator="in"/>
<!-- Dilate each pixel to fill each cell of our pixelation grid -->
<feMorphology operator="dilate" radius="2"/>
</filter>
</svg>