Skip to content

pharo-graphics/RoassalExporters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RoassalExporter

CI

Exporters for Roassal.

Execute the following code snippet in a Playground:

Metacello new
    baseline: 'RoassalExporters';
    repository: 'github://pharo-graphics/RoassalExporters';
    load.

Available exporters:

  • PNG, with methods: exportToPNG, pngExporter or class RSPNGExporter
  • SVG, with methods: exportToSVG, svgExporter or class RSSVGExporter
  • PDF, with methods: exportToPDF, pdfExporter or class RSPDFExporter
  • Video mp4 or mov, with: methods exportToVideo, videoExporter or class RSVideoExporter

Example of usage:

classes := Collection withAllSubclasses.

c := RSCanvas new.
shapes := classes collect: [ :cls |
	RSBox new model: cls;
		height: (cls numberOfMethods max: 5);
		width: (cls instVarNames size * 4 max: 5);
		@ RSPopup;
		@ RSDraggable  ].

c addAll: shapes.

eb := RSEdgeBuilder orthoVertical.
eb withVerticalAttachPoint.
eb canvas: c.
eb connectFrom: #superclass.

RSTreeLayout on: shapes.
c @ RSCanvasController.

(c shapes shapeFromModel: Collection) @ (RSLabeled new text:'Über, genießen').

RSPDFCairoExporter new
		canvas: c;
		exportToFile: '/tmp/foo.pdf' asFileReference

You can access some of these exporters in the inspector

Video

You can export your animations in a video. Load this baseline to load its dependencies.

Metacello new
    baseline: 'RoassalExporters';
    repository: 'github://pharo-graphics/RoassalExporters';
    load: 'Video'.

Also you will need to install ffmpeg.

In your terminal use

xcode-select --install

or:

brew install ffmpeg

Example video

| c b |
c := RSCanvas new.
b := RSBox new
	extent: 100@100;
	withBorder.
c addShape: b.
c newAnimation
	easing: RSEasing bounce;
	from: -100@ -100;
	to: 100@100;
	on: b set: #position:.
c newAnimation
	from: Color red;
	to: Color blue;
	on: b set: #color:.
c newAnimation
	from: 0;
	to: 10;
	on: b border set: 'width:'.
c
	when:RSMouseClick
	do: [ c animations do: #pause ];
	when: RSMouseDoubleClick
	do: [ c animations do: #continue ].
c clearBackground: false.

c videoExporter
	duration: 2 seconds;
	fileName: 'RoassalDemo';
	export
"result will be RoassalDemo.mp4"

You can export the video with transparency and then use that video to edit another video. Videos with transparency take more disk memory.

"..."
c color: Color transparent.
c videoExporter
	duration: 2 seconds;
	transparent;
	fileName: 'RoassalDemo';
	export
"result will be RoassalDemo.mov"

Windows users can not use the video exporter, because it depends on OSSubProcess and that project does not run well in windows, let us know if this is important to you to work on that.

AFrame 3D

You can export a canvas to an html 3D basic exporter with AFrame https://aframe.io/

Metacello new
    baseline: 'RoassalExporters';
    repository: 'github://pharo-graphics/RoassalExporters';
    load: 'AFrame'.

Then execute the example example12AFrameExport, you will get: