Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Particle Engine extension :0 #1724

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SharkPool-SP
Copy link
Collaborator

Create Powerful Particle Engines with NO Clones

Screen.Recording.2024-10-15.at.12.31.42.AM.mov

@BludIsAnLemon
Copy link
Contributor

Peak!!

@Brackets-Coder
Copy link

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?

@theapplesguy2
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

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

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.

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.

6 participants