Skip to content

Conversation

SharkPool-SP
Copy link
Collaborator

@SharkPool-SP SharkPool-SP commented Oct 15, 2024

Create Powerful Particle Engines with NO Clones

Screen.Recording.2024-10-15.at.12.31.42.AM.mov
wow.particles.mp4

@BludIsAnLemon
Copy link
Contributor

Peak!!

@Brackets-Coder
Copy link
Contributor

Two questions I have:

  1. Does high quality pen affect rendering quality?
  2. I've noticed that a lot of your extensions have gradient blocks. This looks cool, but the way you're implementing it with the patch is very weird. I think it'd be sick if we could use CSS colors and gradients as the color values for blocks instead of just hex values. How involved in the scratch-gui would it be to be able to do this?

@circledude64
Copy link

yes

@hammouda101010
Copy link

WOW! a new particle engine with no clones! that's great for performance and now overflow your projects with clones! (even if i use clones, a lot)

@SharkPool-SP
Copy link
Collaborator Author

Two questions I have:

  1. Does high quality pen affect rendering quality?

  2. I've noticed that a lot of your extensions have gradient blocks. This looks cool, but the way you're implementing it with the patch is very weird. I think it'd be sick if we could use CSS colors and gradients as the color values for blocks instead of just hex values. How involved in the scratch-gui would it be to be able to do this?

  1. no, this is not a "pen" canvas, to change quality, you'd need to use the set stage size block, but it comes at a cost of lower performance.

  2. The gui doesn't allow gradients in blocks at all. So I can't simply just put it in the extension block code. So I have to use the patch.

Additionally, blocks in the editor are all SVGs, which means you can't color them with any html property. You have do what I do and make SVG gradients or patterns.

@hammouda101010
Copy link

hammouda101010 commented Oct 15, 2024

Two questions I have:

  1. Does high quality pen affect rendering quality?
  2. I've noticed that a lot of your extensions have gradient blocks. This looks cool, but the way you're implementing it with the patch is very weird. I think it'd be sick if we could use CSS colors and gradients as the color values for blocks instead of just hex values. How involved in the scratch-gui would it be to be able to do this?

well, i just stole borrowed code for you to use the patch:

   function add2Body() {
    var svg = document.createElement("div");
    svg.innerHTML = \`<svg><defs>
      <linearGradient x1="100" y1="0" x2="100" y2="200" id="SPpartEngine-GRAD1" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0090ff"></stop><stop offset="50%" stop-color="#0000ff"></stop></linearGradient>
      </defs></svg>`;
    document.body.appendChild(svg);
  }
  if (Scratch.gui) Scratch.gui.getBlockly().then((SB) => {
    add2Body();
    if (!SB?.SPgradients?.patched) { // Gradient Patch by 0znzw & SharkPool
      SB.SPgradients = {gradientUrls: {}, patched: false};
      const BSP = SB.BlockSvg.prototype, BSPR = BSP.render;
      BSP.render = function(...args) {
        const res = BSPR.apply(this, args);
        let category;
        if (this?.svgPath_ && this?.category_ && (category = this.type.slice(0, this.type.indexOf("_"))) && SB.SPgradients.gradientUrls[category]) {
          const urls = SB.SPgradients.gradientUrls[category];
          if (urls) this.svgPath_.setAttribute("fill", urls[0]);
        }
        return res;
      }
      SB.SPgradients.patched = true;
    }
    SB.SPgradients.gradientUrls["SPpartEngine"] = ["url(#SPpartEngine-GRAD1)"];
  });

@Brackets-Coder
Copy link
Contributor

Two questions I have:

  1. Does high quality pen affect rendering quality?
  2. I've noticed that a lot of your extensions have gradient blocks. This looks cool, but the way you're implementing it with the patch is very weird. I think it'd be sick if we could use CSS colors and gradients as the color values for blocks instead of just hex values. How involved in the scratch-gui would it be to be able to do this?

well, i just stole borrowed code for you to use the patch:

function add2Body() { var svg = document.createElement("div"); svg.innerHTML = <svg><defs> <linearGradient x1="100" y1="0" x2="100" y2="200" id="SPpartEngine-GRAD1" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0090ff"></stop><stop offset="50%" stop-color="#0000ff"></stop></linearGradient> </defs></svg>; document.body.appendChild(svg); } if (Scratch.gui) Scratch.gui.getBlockly().then((SB) => { add2Body(); if (!SB?.SPgradients?.patched) { // Gradient Patch by 0znzw & SharkPool SB.SPgradients = {gradientUrls: {}, patched: false}; const BSP = SB.BlockSvg.prototype, BSPR = BSP.render; BSP.render = function(...args) { const res = BSPR.apply(this, args); let category; if (this?.svgPath_ && this?.category_ && (category = this.type.slice(0, this.type.indexOf(""))) && SB.SPgradients.gradientUrls[category]) { const urls = SB.SPgradients.gradientUrls[category]; if (urls) this.svgPath.setAttribute("fill", urls[0]); } return res; } SB.SPgradients.patched = true; } SB.SPgradients.gradientUrls["SPpartEngine"] = ["url(#SPpartEngine-GRAD1)"]; });

I've already looked at the code, but I don't intend to use it for my extensions. Thank you anyway though.

@Brackets-Coder
Copy link
Contributor

Brackets-Coder commented Oct 15, 2024

Two questions I have:

  1. Does high quality pen affect rendering quality?
  2. I've noticed that a lot of your extensions have gradient blocks. This looks cool, but the way you're implementing it with the patch is very weird. I think it'd be sick if we could use CSS colors and gradients as the color values for blocks instead of just hex values. How involved in the scratch-gui would it be to be able to do this?
  1. no, this is not a "pen" canvas, to change quality, you'd need to use the set stage size block, but it comes at a cost of lower performance.
  2. The gui doesn't allow gradients in blocks at all. So I can't simply just put it in the extension block code. So I have to use the patch.

Additionally, blocks in the editor are all SVGs, which means you can't color them with any html property. You have do what I do and make SVG gradients or patterns.

Interesting. I was just curious as to if we could change the scratch-gui repo to add some sort of functionality for gradients and CSS colors in the block color APIs, but I guess not - It didn't occur to me that the SVGs can't use CSS gradients. Maybe we could use this patch though, and manually inject the colors into the patch? IDK, it's just an idea. Probably won't be done though. What might be more possible is expanding the customizable block colors addon to allow for gradients.

@GarboMuffin GarboMuffin added the pr: new extension Pull requests that add a new extension label Oct 15, 2024
@SharkPool-SP
Copy link
Collaborator Author

Theres now an interpolation option! :)

hammouda101010

This comment was marked as abuse.

@CubesterYT
Copy link
Member

!format

@SharkPool-SP
Copy link
Collaborator Author

!format

@SharkPool-SP
Copy link
Collaborator Author

Rewritten in WebGL! This is now much faster and efficient :)

image

@Brackets-Coder
Copy link
Contributor

Basically just remove the text from the banner then I guess we're good to merge this peak

@SharkPool-SP
Copy link
Collaborator Author

Basically just remove the text from the banner then I guess we're good to merge this peak

I think documentation can be saved for another time, the blocks are in order of usability. So it should be easy to pickup. It works closely to the geometry dash particle engine as well.

We can always go back and add it if need be

@Brackets-Coder
Copy link
Contributor

Basically just remove the text from the banner then I guess we're good to merge this peak

I think documentation can be saved for another time, the blocks are in order of usability. So it should be easy to pickup. It works closely to the geometry dash particle engine as well.

We can always go back and add it if need be

In my testing it didn't take me long to figure out but I couldn't get engines working on sprites, only the stage? Maybe I was doing something wrong

@SharkPool-SP
Copy link
Collaborator Author

Basically just remove the text from the banner then I guess we're good to merge this peak

I think documentation can be saved for another time, the blocks are in order of usability. So it should be easy to pickup. It works closely to the geometry dash particle engine as well.

We can always go back and add it if need be

In my testing it didn't take me long to figure out but I couldn't get engines working on sprites, only the stage? Maybe I was doing something wrong

Wdym. The engines don't follow sprites, they're just attached to them

@Brackets-Coder
Copy link
Contributor

Wdym. The engines don't follow sprites, they're just attached to them

No, I meant I for some reason couldn't get them working when attached to a sprite, I rushed through it so I must've done something wrong

add punctuation to end of description comment
@SharkPool-SP
Copy link
Collaborator Author

Wdym. The engines don't follow sprites, they're just attached to them

No, I meant I for some reason couldn't get them working when attached to a sprite, I rushed through it so I must've done something wrong

Maybe you didn't make an emitter for that engine?

@Brackets-Coder
Copy link
Contributor

Maybe you didn't make an emitter for that engine?

Oops I got it working sorry

@Brackets-Coder
Copy link
Contributor

Yeah just change the banner and we should be good to go

@PPPDUD
Copy link
Contributor

PPPDUD commented Sep 18, 2025

Is that a gradient for the block colors? Looks really nice.

@Brackets-Coder
Copy link
Contributor

Is that a gradient for the block colors? Looks really nice.

Yes

@PPPDUD
Copy link
Contributor

PPPDUD commented Sep 18, 2025

Is that a gradient for the block colors? Looks really nice.

Yes

I didn't know that block colors could use gradients!

@Brackets-Coder
Copy link
Contributor

Is that a gradient for the block colors? Looks really nice.

Yes

I didn't know that block colors could use gradients!

They can't by default, it's an SVG patch.

@PPPDUD
Copy link
Contributor

PPPDUD commented Sep 18, 2025

Is that a gradient for the block colors? Looks really nice.

Yes

I didn't know that block colors could use gradients!

They can't by default, it's an SVG patch.

I see.

@SharkPool-SP
Copy link
Collaborator Author

alright fixed

Copy link
Contributor

@Brackets-Coder Brackets-Coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, everything looks good!

@Brackets-Coder
Copy link
Contributor

@PPPDUD

@PPPDUD
Copy link
Contributor

PPPDUD commented Sep 18, 2025

@PPPDUD

I'm going to have to pass for tonight, but I might be willing to review tomorrow.

Copy link
Member

@GarboMuffin GarboMuffin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • when i change the VM fps to 60, i would expect the particles to not move twice as fast. there does seem to be delta time logic at least in some places. is it not being used? ✅
  • when i have an emitter going and i resize the stage, i would expect the particle canvas to resize too and at least appear in the right spot after the resize (as is, stage emitter is very offset to the right after resizing 480x360 to 640x360) ✅
  • the dropdowns in the flyout only update after exiting the editor and going back in; newly creates sprites will not show up ✅
  • uploading one webgl context to another context seems to be slow. create like 10 particle engines, even with almost nothing going on, it gets really slow: https://share.firefox.dev/4gty2bI[Not Fixing, other gallery extensions use this method]
  • chrome limits max webgl contexts per tab to something like 16, so by the time someone makes their 16th particle context, the context used by the vm will be lost until a full refresh ✅
  • even if unused engines are removed with the block, it's not guaranteed that chrome will garbage collect them and release the webgl slot right away (make a "create engine for x / remove engine for x" script and duplicate it on top of itself 20 times to see example)
  • blend modes are seemingly affected by same problems as in #2142 (set particle blend mode to subtract in light mode for an example) ✅
  • the particles are highly pixelated in fullscreen and on high dpi displays outside of fullscreen ✅ [Not Fixing]

}
}

if (Scratch.gui)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think if you want gradients i think you should make a documented pr with a couple test cases so all the extensions get it. as-is this also breaks colored context menus

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colored context menus is bug with the addon, even if you make this a actual thing, the addon would still be broken

Copy link
Collaborator Author

@SharkPool-SP SharkPool-SP Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and Id rather not wait 6+ months just to get a PR merged from you

@Brackets-Coder
Copy link
Contributor

Next time I'll review more thoroughly...

@SharkPool-SP
Copy link
Collaborator Author

!format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new extension Pull requests that add a new extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants