Sankey diagram using ActionScript - actionscript

I want to draw a Sankey diagram using Action Script. Can anyone provide some direction regarding the algorithms or libraries that are available for this?

For that I would suggest you to use d3 library to draw your Sankey diagram and overlay the diagram above the Flash Player using CSS tricks.
If you instead want to show the diagram as image inside the Flash Player itself, then you can render the diagram inside a hidden HTML5 Canvas and load its dataURL as an image source. Use HTMLCanvasElement.toDataURL() to get dataURL from HTML5 Canvas.
var request:URLRequest = new URLRequest(ExternalInterface.call("CanvasToDataURL")); //js function to get DataURL.
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
Also do some research, as I have not tested my answer yet.

Related

Can you fill a shape with a canvas

I would like to be able to fill a shape with a canvas; potentially to have one konva canvas generate an animation and update another konva canvas shape with it, masked inside a path. Is this possible?
Its not totally clear what you actually want to do, but what you describe is probably achievable with Konva layers. You see Konva is a wrapper for HTML5 canvas and one of its features is layers - so you have one Konva instance that must have a minimum of one layer but can have more. Konva cunningly uses a separate HTML5 canvas for each layer. See the example here in the Konva docs. If you hit F12 you can see the two canvas elements used, and there is a code sample too.
This gives a lot of power and some great performance management potential. And it is all baked in to Konva already so you will not have to manage multiple canvas instances in your own code.

iText Appeareance Stream for annotation MARKUP_HIGHLIGHT

I'm looking at creating an appearance stream for annotation of type markup highlight by applying raw commands and writing them to output stream. However, I could not pinpoint which correct classes to use.
And so far, I could not find a post on how to do it.
This is what I have.
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("/Form Do".getBytes("ISO_8859_1"));
os.write("other commands to draw highlighted rectangle coordinates");
PdfStream stream = pdfAppearance.getFormXObject(0);
stream.writeContent(os);
Or are there any other classes involved needed for writing raw commands.
And correct me if I am wrong but it looks like drawing the rectangle coordinates in the PdfAppearance will have no effect since there seems to be a form necessary where the rectangle fills are drawn instead.

AS2 bitmap resizing external image anti-aliasing (Actionscript 2)

I'm using the dreded AS2 (not by choice) and working with images externally loaded.
I know that
targetClip.forceSmoothing = true;
...exists, but it still doesn't seem to be doing much at all.
The images externally loaded are really big in dimensions and when made smaller in the flash, they pixelate.
Perhaps forceSmoothing is the best method but...
I'm thinking there may be a way to resave the external bitmap resized and use that, instead of resizing a bitmap as a vector.
Any ideas?
Also, I've got an AS3 version of this, so if you know how I can do it in that too, then great. But it seems they do not want to use that yet.
in as2:
add this class to your project BitmapLoader
and use like that:
var loader : BitmapLoader = new BitmapLoader(true);
loader.addListener(this);
loader.loadBitmap("http://foo.tr/example.jpg", this, "doneLoading" );
in as3 :
var loader:Loader = new Loader()
loader.load(new URLRequest("1.jpg"))
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,doneLoad);
function doneLoad(e:Event){
var bitmap:Bitmap = e.target.content as Bitmap
bitmap.smoothing = true
}
How are you loading the image data? If you're doing it with the BitmapData class, you can use a matrix together with the scale() command to shrink it.
http://docs.brajeshwar.com/as2/flash/geom/Matrix.html
http://docs.brajeshwar.com/as2/flash/display/BitmapData.html

OpenLayer3 overlays displayed only on one map

Im working with OpenLayer3 nad overlays. I created a few of them but when I zoomed out ( a few world maps are displayed), the overlays are displayed only on one one world map. But on the others world maps, they are not displayed.
How to fix it?
This is currently a limitation in OpenLayers 3 - vector layers do not support wrapping the world. A workaround would be to configure your tile layers to not wrap the world, using the wrapX: false config option.
wrapX, is now part of the current release of OpenLayers (v 3.2.0).
So if you want your layer to prevent multiple worlds. Just put it on your layer-source. See the example below:
tileLayer = new ol.layer.Tile({
source: new ol.source.OSM({
wrapX: false
})
});

How to add cropper on a particular View(other than ImageView)

I need to implement a cropper in my project. Problem is I found croppers that works with UIImageView. But I have a pdf. I am viewing it using code found on vfr/Reader.GitHub. I need to add a cropper, that will crop the particular page of the PDF. In code am using a ScrollView to show the PDF. Any code? any reference that crops the topmost view? Or the Window?
use view.layer.mask property to mask the portion that you want to see.
CAShapeLayer *layer =[CAShapeLayer layer];
layer.path =[UIBezierPath bezierPathWithRect...].CGPath;
view.layer.mask =layer;
If you want a single pdf page, the vfr library already has page thumbnails functionality which are basically single page images.. you can find ways of directly using those thumbnails.
If however you want to 'crop' a portion of the page, you will have to render the PDF page in a core graphics context, allow user to select the area (or select the predefined area as per your requirements) and crop the context.
You can then render this contet wherever you like or convert this context to jpeg data and save it to a file.
Read the iOS Quartz 2D Programming Guide to get a better idea of drawing views, PDFs images etc into core graphics contexts and working with core graphics contexts in more detail:

Resources