Gen AI in Business - Global Trends Report 2024.pdf
Using SVG with Ample SDK cross browser
1. Using SVG cross-browser with Ample SDK, JavaScript GUI Framework. SVG Open 2009 2-4 October 2009, Mountain View, CA Sergey Ilinsky
2. Agenda 1) Web-browsers and markup-based Vector Graphics 2) Introduction to the Ample SDK GUI Framework 3) Scope of SVG implementation 4) Using SVG with Ample SDK 5) VML problems encountered while implementing 6) Directions 7) Questions
3. 1. Web-browsers and markup-based Vector Graphics Modern browsers claim to support SVG SVG, First WD on 11/02/1999 One of the first usable implementations in Opera 9 (2006) Other – try hiding deep VML VML, W3C Note on 13/05/1998 First implementation shipped with Internet Explorer 5.0 (1999)
5. Chrome 3.0 / Firefox 3.0 Opera 10.0 BTW, Modern browsers do have quirks
6. Chrome 3.0 Firefox 3.0 / Opera 10.0 Very modern browsers do have quirks too
7. 2. Introduction to the Ample SDK 1) Goals 2) Solution 3) Programming model 4) Technologies breakdown 5) Componentization model
8. 2.1 Goals - equalize browsers APIs without introducing new - extend on browser UI technologies stacks - create a framework for reusable UI components - do not enforce application programming model - keep it transparent
9. 2.2 Solution virtualizing browser native technologies: - pass through if available - implement if not - fix if broken Ben Galbraith: «Ample SDK: Browser-in-a-Browser»
10. 2.3 Programming model Programming model is that of web-browser: - XML for UI - CSS for Style - DOM/JavaScript for Logic
17. 4. Using SVG with Ample SDK 1) Embedding SVG fragments into HTML 2) Dynamically modifying SVG fragments 3) Styling SVG fragments with CSS
18. 4.1 Embedding SVG fragments into HTML a) Inline, using a script tag with type="application/ample+xml" <body> <!-- other HTML code --> <script type="application/ample+xml"> <!-- Ample SDK inline XML markup --> </script> <!-- other HTML code --> </body> b) Referencing a resource, using a script tag with src attribute <body> <!-- other HTML code --> <script type="application/ample+xml" src="ui.xml"></script> <!-- other HTML code --> </body> c) Inline, using ample.open() and ample.close() <body> <!-- other HTML code --> <script type="text/javascript">ample.open()</script> <!-- Ample SDK inline XML markup --> <script type="text/javascript">ample.close()</script> <!-- other HTML code --> </body>
19. 4.2 Dynamically modifying SVG fragments 1) Using pure DOM APIs <svg:rect if="myrect" fill="red" x="0" y="0" width="100" height="100" onclick="setOpacity(event .target )"/> <script type="text/javascript"> function setOpacity(oElement) { oElement.setAttribute("opacity", "0.5"); } </script> 2) Using SMIL <svg:rect if="myrect" fill="red" x="0" y="0" width="100" height="100"> <smil:set begin="click" attributeName="opacity" to=”0.5” attributeType="XML" fill="freeze"/> </svg:rect> 3) Using SVG-specific DOM APIs Not available yet (planned)
20. 4.3 Styling SVG fragments with CSS 1) Using class selectors <text class="text1"><tspan>SVG In internet explorer</tspan></text> .text1 { font-weigth: 600; } 2) Using element selectors <svg:rect x="100" y="100"/> svg|rect { fill: red; } 3) Specifying styles inline (also with attributes) <svg:circle style="stroke:none; fill:green; opacity:0.5" r="100" cx="100" cy="100"/>
21. 5. VML problems encountered while implementing - IE8 is 10x times slower compared to IE6 rendering VML - Certain VML attributes can't be set at runtime - No native transformations on groups - Stroke lines thiner than 1 unit cannot be drawn - VML radial gradient is too much sophisticated
22. 6. Directions Ample SDK is set to go Open-Source on 1 st November 2009 IRC Channels #amplesdk on irc.freenode.net #amplesdk-dev on irc.freenode.net (developers) Mailing Lists / Discussion Groups http://groups.google.com/group/amplesdk http://groups.google.com/group/amplesdk-dev (developers) Bugtracker http://www.amplesdk.com/bugtracker/ Documentation (online/offline) http://www.amplesdk.com/reference/