Create SpriteFrame From Graphics Component Drawn Shape

Let’s say if draw a shape with

 const g = this.getComponent(Graphics);
        g.lineWidth = 10;
        g.fillColor.fromHEX('#ff0000');
        g.moveTo(-40, 0);
        g.lineTo(0, -80);
        g.lineTo(40, 0);
        g.lineTo(0, 80);
        g.close();
        g.stroke();
        g.fill();

and wanted to convert this drawn shape into a sprite frame that can be used in another node’s sprite component, how it’s achievable?