Gallery Texture Script

Hello dear friends

Most of us are familiar with this script that Mr. @josh_beckwith created it. it basically changes the orientation of original Gallery Texture image from Fill to Aspect Fit.
but is there any way that we can change it to Aspect Fill somehow?

const Patches = require('Patches')
const Textures = require('Textures')
const {log} = require('Diagnostics')
const R = require('Reactive')

Textures.findFirst('galleryTexture0').then(tex => {
  Patches.inputs.setPoint2D('galleryTextureSize', R.point2d(tex.width, tex.height))
  Patches.inputs.setString('galleryTextureState', tex.state)
  tex.state.monitor().subscribe(val => {
    log('Gallery texture changed')
    Patches.inputs.setPulse('galleryTextureStateChanged', R.once())

I think the “contain” checkbox should do what you want. It will prevent the largest edge from extending beyond the screen bounds. I’m using CSS terms (contain, cover) to describe the behavior, in general.

I found two handy shaders that do the job just right
I want to share them here for whoever that may need this tool in future.
they’re really easy to use, just drag them into your projects and connect your gallery texture. no scripts or patches are needed.
if you don’t know what Aspect Fill or Aspect Fit is, just look at the pictures in the beginning of this thread.
Aspect (2.0 KB)
Aspect (739 Bytes)


Very cool, thank you for sharing those! This is the same idea behind the fit2rect patch, but it was missing from the gallery texture project. I made an update so it’s more convenient for everyone. See this thread for more info: GitHub - positlabs/spark-gallery-texture-state: Test case for gallery texture size and state changes

1 Like

fantastic job :+1:
thank you so much for making all these great and useful patches.

1 Like