Is there a library or tool for svg or raphael that allows to pan over and zoom into drawings? - dictionary

Does somebody know if there is a library (or something like a library) that allows me to create text annoted vector graphics (preferably on the basis of svg or raphael) with the feature to pan over these graphics and zoom into them and, when I zoom into, shows more and more details, or, when zooming out, shows less details so that the image is not cluttered with details that are irrelevant for a particular zoom level.
I am aware I could do the panning and zooming with setting a corresponding viewport, but this would still show details that I don't want to see on a zoomed-out level.
Thanks for any pointers.

SVGPan is a small script for this pourpose:
http://code.google.com/p/svgpan/
demo page:
http://www.cyberz.org/projects/SVGPan/tiger.svg

There is a solution provided here using Raphael
http://dashasalo.com/2011/04/13/svg-image-zooming-and-panning-with-raphaeljs/

Related

Render 2D text in Autodesk Forge without aliasing or blurring

Turns out I’m working with the Autodesk Forge viewer and Three.js, trying to render 2D text that can be interacted with (specifically select, rotate, and move).
To do this I am working with meshes (using MeshBasicMaterial, Mesh and TextGeometry) but it turns out that the text does not look perfectly sharp, it presents aliasing and I found that according to the API reference, the antialiasing is not applicable to 2d.
Here are some examples of the problem, as you can see, the more I move away from the plane, the worse the text looks (and even up close it doesn't look perfect):
I have tried to make a test representing the text with a Sprite (despite the fact that it would mean having to change the entire implementation already made with meshes of other functionalities) but apart from the fact that I cannot see it, I have seen example images and they do not appear either well: aliasing is visible from a distance and it looks really blurry up close. Here some examples:
Is there a way to correct this problem or is this the most I can get in 2D? I've tried searching for information on this but can't find anything helpful. And what has puzzled me the most has been realizing that antialiasing was not applicable in the case of 2d, like making it clear that nothing can be done to fix it.
I would be very grateful if you could solve my doubts, thank you very much in advance for your help.
An easier alternative, is to just use a higher pixel ratio for the renderer...
window.devicePixelRatio=2;
viewer.resize();
For example, using the custom geometry text, from Joao's demo, you can see the same aliasing issue at DPR=0.5 and DPR=1.0 ...
https://joaomartins-forge.github.io/textgeometry-sample/
But when I set the DPR=2.0, the text looks clean. The trade off is rendering performance, but your 2D drawings may be simple enough that it won't matter. You can use a 'mouse up' camera settle trick, to switch between DPR of 1 and 2, if you want a better UX experience.
There are a few ways to solve this aliasing issue for 2D (and 3D text).
The way I would recommend for your use case, is to use DIV elements (THREE.CSS3DRenderer), instead of text converted into three.js tessellated triangle geometry, as shown in this blog post:
https://forge.autodesk.com/blog/how-do-you-add-labels-forge-viewer
You can find out more information about THREE.CSS3DRenderer here:
https://threejs.org/docs/#examples/en/renderers/CSS3DRenderer
and an Example here: https://threejs.org/examples/#css3d_periodictable
Using CSS3DRenderer instead of CSS2DRenderer, means you will get the correct scaling (and rotation) of the div element as you zoom into your 2D drawing and the mathematics inside the calculation for the matrix transform has less edge-cases.
Once you are using DIV elements for your text, you will notice that the text is sharper and has no aliasing issues. That's because it is not being rasterized by the webGL pipeline, but by the SKIA library used by chrome/firefox/opera/etc for rasterizing text.
There is one final option, that uses signed-distance fields, but it's probably overkill for what you need.
Let me know if you want some example code.

Clearing pixels of font path in HTML <canvas>

I would like to know how I can create a colored canvas but with transparent parts with the font. I want the font to create a hole in this canvas. Is this possible and how ? My goal is to create the impression that an image is embbed in a font...
Thank you :)
<canvas> offers something called composite operations for cut off and such effects. I believe the operation you want is called destination out:
https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html
And here is some more technical details in the spec:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing
I cannot provide you an actual working code (your use case is pretty rare), but you should be able find a globalComposite tutorials and with little playing with their code you can find out how to apply the operation for your case.

Flex Pan & Zoom with vector images

I've looked at http://www.adobe.com/devnet/flex/samples/fig_panzoom/ for pan & zoom, and it does a very good job of it. However, it only works with raster images. Does anyone know how to modify this for vector images (SVG converted to SWF).
My limited attempts have not gone well, as the Imageviewer.as class is clearly designed around bitmaps.
I can load the SVG images in an Image, but I'd really like to pan & zoom too.
Thanks.
Have you looked at OpenZoom? AFAIK it supports anything that can be loaded on the stage.

What web technology to opt for to offer interactive colouring?

A customer has asked us to a add a feature to his website allowing visitors to colour in panels in a simple line drawing.
The website visitor will have a limited palette to choose from and will select a colour and click in a shape within the line drawing to colour it in as in:
There will only be four or five of these line drawings. The drawings themselves are not required to be interactive or flexible, only the colouring.
The line drawings will be super simple and we don't need to save the visitor's selections although the visitor will want to print or email the result.
Simple simple stuff. Most of the time where you see this done on sophisticated websites I assume it's done with Flash.
But is Flash the only way to go? Or can it be done with JQuery/Javascript or Silverlight or something else? Our team's knowledge covers ASP.NET, HTML, CSS, Javascript. No experience of Flash.
If you have a finite number of line drawings, and a limited number of colours, you could just pre-generate every possible colour/section combination - isolate each area as a transparent GIF/PNG and composite them using position:absolute to create an "onion skin" / animation cel effect. Use some old-school HTML image-map code (or server-side parsing of the myimage.X / myimage.Y parameters, or jQuery) to work out where they clicked, identify the image section under the mouse click location, and replace that image only with the corresponding version in their selected colour.
You can't draw these kinds of shape without using canvas or SVG. And I am not sure about the support provided by browsers for these.
If you can go for canvas then you ca ntake a look at
Processing js library
or for SVG
Raphaël—JavaScript Library
There are only two ways i can think of atm:
Split the line drawings into the colourable elements and show each image absolutly positioned to merge the images into one on the website.
Use Javascript to load a pre-coloured image of that part with "onclick" (or generate a coloured version with asp/php/whatever server-side.
Not sure if it's possible to print absolute positioned elements cleanly.
Use flash, it's simple there so even without experience you should be able to do it in 1-2 workdays.
My guess is that you could use the new HTML 5 canvas element to achieve this goal in an open, standards compliant manner.
Note: canvas is a new feature and is only supported in recent browser releases (latest Safari, Firefox or Chrome for example).

Flex / AS3 : Red Eye reduction

I was looking a component to reduce red eye effect on taken photos. Ive found an image Processing library, but it does not work well at all. I was thinking on brush an image, manually, and only paint if the base pixel color its red or near in RGB.
Have no time now to explain all the process, but i need help to get this idea, or to get a working comp
Thanks in advance!
If you are wishing to manipulate the pixels of an image/component then pixelbender would be a pretty good way to go.
Have a look at http://www.adobe.com/cfusion/exchange/index.cfm?event=productHome&exc=26 for downloadable examples.
These can be run using the toolkit found at http://labs.adobe.com/technologies/pixelbender/
Video tutorials on pixel bender can be found at http://www.gotoandlearn.com/
With this you could change just the required pixel colours to anything and it works with everything in flash (images, canvas, button's etc)

Resources