Skip to content

ObjectProfile/Roassal3Exporters

Repository files navigation

Attention

image

WE ARE MOVING

New repositories:

Roassal is part of pharo thats why we want to keep it as part of the pharo ecosystem, thats why we are moving and this repository will be frozen.

To load pharo-graphics/Roassal in a pharo10/11 you will have to remove roassal3 first to avoid conflicts.

#(Roassal3 Numeric) do: [:string |
  regExp := '*', string ,'*'.
  packages := RPackageOrganizer default packages
	  select: [ :each | regExp match: each name ].
  packages do: [ :each | each removeFromSystem ].
]

Roassal3Exporter

CI

Exporters for Roassal3.

Execute the following code snippet in a Playground:

Metacello new
    baseline: 'Roassal3Exporters';
    repository: 'github://ObjectProfile/Roassal3Exporters';
    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: 'Roassal3Exporters';
    repository: 'github://ObjectProfile/Roassal3Exporters';
    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: 'Roassal3Demo';
	export
"result will be Roassal3Demo.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: 'Roassal3Demo';
	export
"result will be Roassal3Demo.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: 'Roassal3Exporters';
    repository: 'github://ObjectProfile/Roassal3Exporters';
    load: 'AFrame'.

Then execute the example example12AFrameExport, you will get: