phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

making nice images with Phoenix

Open sponce opened this issue 3 years ago • 9 comments

One thing people from the outreach like to get is nice pictures which can be used then by media in general and newspapers in particular. These picture need decent resolution (4K or more typically). Now phoenix is only able to produce screenshots, so requires you have a very big screen if you want a nice picture.

Is there anyway to get a "screenshot" of a virtual screen of a size different from the actual one ? Alternatively does threejs support svg as an output for images ?

sponce avatar May 25 '22 13:05 sponce

@sponce @EdwardMoyse Can I work on this feature? I was thinking about adding another option inside Import and Export options within the Phoenix Iconbar labeled as "Export SVG"

gauravsharma21 avatar Jun 18 '22 19:06 gauravsharma21

You're more than welcome !

sponce avatar Jun 20 '22 09:06 sponce

I have tried to add an option for exporting SVG. I am successfully able to download an SVG image. But, there are a few issues:

  1. Clipping is not working properly in the final SVG.
  2. The info panel is not exported. I haven't found a way yet to export HTML as SVG.
  3. SVG file has all the objects including the occluded ones. So, its size is big.

I have basically added a function similar to makeScreenshot() in "packages\phoenix-event-display\src\managers\three-manager\index.ts":

public exportSceneToSVG() {
    const bkgColor = getComputedStyle(document.body).getPropertyValue(
      '--phoenix-background-color'
    );

    const renderer = new SVGRenderer();
    renderer.overdraw = 0;
    renderer.setSize(window.innerWidth, window.innerHeight);

    const colorValue = parseInt(bkgColor.replace('#', '0x'), 16);
    renderer.setClearColor(new Color(colorValue), 1);

    renderer.render(
      this.sceneManager.getScene(),
      this.controlsManager.getMainCamera()
    );

    const XMLS = new XMLSerializer();
    const svgfile = XMLS.serializeToString(renderer.domElement);
    const svgData = svgfile;
    const preface = '<?xml version="1.0" standalone="no"?>\r\n';
    const svgBlob = new Blob([preface, svgData], {
      type: 'image/svg+xml;charset=utf-8',
    });

    const svgUrl = URL.createObjectURL(svgBlob);
    const downloadLink = document.createElement('a');
    downloadLink.href = svgUrl;
    downloadLink.download = 'scene.svg';
    downloadLink.click();
}

Somya-Bansal159 avatar Mar 09 '23 19:03 Somya-Bansal159

I would like to reiterate the desire for this feature (and/or also https://github.com/HSF/phoenix/issues/581).

I tried to emulate a device with a higher resolution and take a better screenshot with that but sadly in the end they look the same still.

JanEricNitschke avatar Mar 14 '24 16:03 JanEricNitschke

I think quite a lot of this has been added. Did you give it a try - you can now make very large screenshots.

EdwardMoyse avatar Mar 14 '24 19:03 EdwardMoyse

Yeah, i did, both with https://phoenixatlas.web.cern.ch/PhoenixATLAS/ as well as cloned and run locally.

I can do the preset 3860 by 2610 but that still looks quite rough to me when you zoom in even a tiny bit. Setting it bigger to twice each just gives me a grey picture.

screencapture00 screencapture

JanEricNitschke avatar Mar 14 '24 19:03 JanEricNitschke

Which browser? If you can, try with another as I believe they have different limits.

EdwardMoyse avatar Mar 14 '24 19:03 EdwardMoyse

I used chrome initially and also tried edge now. Both give me the same result.

JanEricNitschke avatar Mar 14 '24 19:03 JanEricNitschke

I think this one is just a duplicate of #581 and we only need to find the time to implement the second point described there, and implement a solution using setViewOffset and recomposition of the image

sponce avatar Mar 15 '24 06:03 sponce