Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG And Perl London.pm Tech Talks.

Slides:



Advertisements
Similar presentations
HTML Basic Lecture What is HTML? HTML (Hyper Text Markup Language) is a a standard markup language used for creating and publishing documents on.
Advertisements

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Building an SVG GUI with Perl Ronan Oger RO IT Systems GmbH
Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystem s.com A Web Interface to Autotrace 9 March 2004 Ronan Oger RO IT Systems GmbH London.
Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Building an SVG GUI with Perl YAPC::EU 2003.
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Farhan Nisar University of Peshawar
Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Part R: Thin-client SVG GUI forms Ronan Oger – SVG Open 2003 SVG GUI Workshop.
Name: Date: Read temperatures on a thermometer Independent / Some adult support / A lot of adult support
1 Introduction to Web Application Implement JavaScript in HTML.
1 Roger L. Costello 16 June 2010 XQuery
CSS3 OVERVIEW Owen Williams Owen at dynabooks daht com.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
1 © Netskills Quality Internet Training, University of Newcastle Structure, Presentation and Navigation © Netskills, Quality.
Applications of XSLT. generating Word documents WordML provides formatting and content elements Word 2003 can read WordML files XSLT can be used to transform.
I can interpret intervals on partially numbered scales and record readings accurately ? 15 ? 45 ? 25 ? 37 ? 53 ? 64 Each little mark.
Data Visualization Lecture 4 Two Dimensional Scalar Visualization
Slice and Dice: From PSD Image to XHTML+CSS Svetlin Nakov Telerik Corporation
4. Internet Programming ENG224 INFORMATION TECHNOLOGY – Part I
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
Social Web Design 1 Darby Chang Social Web Design.
Chapter 3 – Web Design Tables & Page Layout
Centro de Referência em Informação Ambiental, CRIA Sidnei de Souza Abril 2006 mapcria web service.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
© Park University, 2006 Creating an Interactive Web Page with DHTML and JavaScript Park University.
1 Programming the Web: HTML Basics Computing Capilano College.
Images Images are a key component of any multimedia presentation.
HTML5 Overview HOANGPT2. 1. General 2. New Elements List 3.
Multimedia and weBLOGging Grade 7-9 | Cahaya Bangsa Classical School (C) 2010 Digital Media Production Facility 06 – Blog HTML Basic.
Dr. Alexandra I. Cristea XHTML.
Making Numbers Two-digit numbers Three-digit numbers Click on the HOME button to return to this page at any time.
Lesson One: The Beginning
Bring Life to Your Web Pages with JavaScript and HTML5 Part 2 Ole Ildsgaard Hougaard -
Chapter 2: Using Objects Part 2. Assume you wish to test the behaviour of some method. This is accomplished by providing a tester class: Supply a main.
Let’s Add! Click the cloud below for a secret question! Get Started!
New Tags, New Attributes, New JavaScript APIs, Forms, Validation, Audio, Video, SVG, Canvas Doncho Minkov Telerik Corporation
2.744 Dreamweaver Tutorial Sangmok Han Feb 24, 2010.
Programming Club IIT Kanpur. Work environment Before you begin coding,always set up your work environment to your needs IDE Notepad++ Sublime Text 2.
Presenter: James Huang Date: Sept. 26,  Introduction  Basics  Lists  Links  Forms  CSS 2.
A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
Lecture # 11 JavaScript Graphics. Scalable Vector Graphics (SVG) Scalable Vector Graphics (SVG), as the name implies, are - scalable (without pixelation):
Web Technologies Using the Internet to publish data and applications.
SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
Responsive and Adaptive Web Design By: Chad W. Stoker (MCTS, MCP, MCAD) President & Chief Technology Officer.
JQuery A Javascript Library Hard things made eas(ier) Norman White.
In this lecture, you will learn: ❑ How to link between pages of your site ❑ How to link to other sites ❑ How to structure the folders on your web site.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Day 2 – JavaScript & PHP.  Have the hover effect display an extra image  Add an extra image for each of the tags  In your writeText() function, you.
Chapter 14 Introduction to HTML
UNIT 8 DRAWING WITH THE HTML5 CANVAS ELEMENTS AND FORMS.
HTML (HyperText Markup Language)
Building the User Interface by Using HTML5: Text, Graphics, and Media Lesson 2.
Presented by Nassib Awad
XHTML TAGS I Basic Tags. North Lake College 2 by Sean Griffin Sample XHTML Code.
SVG for Designers Tom Hoferek. Objectives Introduce SVG Illustrate its capabilities Demonstrate SVG in action Speculate, discuss, answer questions.
Lecture 16 Image Document Formats. Bitmap vs. Vector Images Bitmaps do not generally.
Cascading Style Sheets Robin Burke ECT 360. Outline Midterm CSS CSS selection Positioning SVG Final project.
So far  Reviewed CSS  Added a table  3 rows  Copy/paste from course syllabus Anchorsandlists.pptx 01/22/2016.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
Part – 3 : HTML 5 SVG Tag. † SVG stands for Scalable Vector Graphics. † SVG is used to define vector-based graphics for the Web. † SVG defines the graphics.
SVG & DOM Manipulation via Javascript
HTML CS422 Dick Steflik.
Introduction to D3.js and Bar Chart in D3.js
D3.js Tutorial (Hands on Session)
D3.js Tutorial (Hands on Session)
HTML5 - 2 Forms, Frames, Graphics.
Presentation transcript:

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG And Perl London.pm Tech Talks

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG Modules on CPAN SVG SVG::Parse r SVG::TT::G raph SVG::Plot SVG::Graph GD::SVG SVG::GD

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG.pm DOM-ish XML-generation module Lightweight / fast – Optimized for speed – Not strictly DOM-compliant – Supports most of W3's DOM API 2 Extensible – Can add arbitrary XML tags – html & arbitrary XML #!/usr/bin/perl use SVG; use strict; my $svg = SVG->new(); $svg->circle(x=>0,y=>0, r=>10,id=>'test'); print $svg->xmlify;

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG.pm output Hello SVG World! Draw a line Navigating the DOM Tessalate YAPH Click on images to view as SVG

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG::Parser – Peter Wainwright Built to work with SVG module #!/usr/bin/perl -w use strict; use SVG::Parser; die "Usage: $0 \n" my $xml;my $out { local $/=undef; $xml=<>; } my $parser=new SVG::Parser(-debug => 1); my $svg=$parser->parse($xml); print $svg->xmlify; #!/usr/bin/perl -w use strict; use SVG::Parser qw(SAX=XML::LibXML::Parser::SAX Expat SAX); die "Usage: $0 \n" my $svg=SVG::Parser->new()->parsefile($ARGV[0]); print $svg->xmlify;

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Hello SVG World! #!/usr/bin/perl -w use strict; use SVG; print "Content-Type: image/svg+xml\n\n"; my $svg=new SVG(); $svg->rect(id=>'rect1',x=>'20px',y=>'55px', width=>10,height=>10,fill=>'yellow'); my $text = $svg->text(x=>20, y=>55, fill=>'red', stroke=>'black'); $text->cdata("Hello SVG world!"); #grab the fill element my $fill = $svg->getElementByID('rect1') ->getAttribute('fill'); #modify the fill attribute of the text element $text->setAttribute('fill',$fill); print $svg->render(); #xmlify

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Draw a Line #!/usr/bin/perl -w use strict; use SVG; print "Content-Type: image/svg+xml\n\n"; my $svg=new SVG(width=>60, height=>45); my $group1=$svg->group(id=>"outer_group"); my $group2=$group1->group(id=>"inner_group"); $group2->line(x1=>20, y1=>30, x2=>50, y2=>35, stroke=>"blue"); print $svg->render();

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Navigate the DOM...Part 1 #!/usr/bin/perl –w use strict; use SVG; print "Content-Type: image/svg+xml\n\n"; my $svg=new SVG(width=>60, height=>60); my $group1=$svg->group(id=>"outer_group"); $group1->rect(x=>10, y=>10, width=>40, height=>40, fill=>"yellow"); my $group2=$group1->group(id=>"inner_group", stroke=>"blue"); $group2->line(x1=>10, y1=>30, x2=>50, y2=>40); $group2->line(x1=>30, y1=>10, x2=>40, y2=>50); $group2->line(x1=>10, y1=>40, x2=>40, y2=>10); my $anchor = $group1->anchor(-href=>' my $circle = $anchor->circle(cx=>30, cy=>30, r=>6, fill=>"red"); $circle->set(begin=>"mouseover", end=>"mouseout", attributeName=>'fill', to=>'cyan'); print $svg->render(); #or xmlify or serialize

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Navigate the DOM...Part 2 iterate($svg); sub iterate { my $depth=0 unless defined $depth; my $child=$element->getFirstChild(); return unless $child; do { print "\t"x$depth, "Element $child is a ", $child->getElementName(), "\n"; iterate($child,$depth+1) if $child->hasChildren; } while ($child = $child->getNextSibling); }

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com #!/usr/bin/perl -w use strict; use SVG; my $svg = SVG->new(width=>"100%", height=>"100%"); my $g = $svg->group(style=>{"fill-rule"=>"evenodd","stroke- linejoin"=>"round", "stroke-linecap"=>"round"}); my $d1 = $g->defs(); my $path = $svg->get_path(-type=>"path", x=>[0,90,60], y=>[0,60,90], - closed=>1); my $d1g1p = $d1->group(id=>"Tess0p")->path(%$path); my $d1g0 = $d1->group( id=>"Tess0", fill=>"rgb(255,255,0)", stroke=>"none")->use(-href=>"#Tess0p"); Tessalate...Part 1

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Tessalate...Part 2 my $d1g1 = $d1->group(id=>"Tess1", fill=>"none", stroke=>"rgb(0,0,0)", "stroke-width"=>"2.413")->use(-href=>"#Tess0p"); $path = $svg->get_path(-type=>"path", x=>[15,75,50], y=>[15,50,75], -closed=>1); my $d1g2p = $d1->group( id=>"Tess2p")->path(%$path); my $d1g2 = $d1->group(id=>"Tess2", fill=>"rgb(255,170,255)", stroke=>"none")- >use(-href=>"#Tess2p"); my $d1g3 = $d1->group( id=>"Tess3", fill=>"none", stroke=>"rgb(0,0,0)", "stroke-width"=>"2.413")->use(-href=>"#Tess2p"); my $d2p2 = $g->defs()->pattern(id=>"TessPattern", patternUnits=>"userSpaceOnUse", x=>"0", y=>"0",width=>"100", height=>"100", viewBox=>" ", overflow=>"visible"); $d2p2->group()->use(-href=>"#Tess0"); $d2p2->group()->use(-href=>"#Tess1"); $d2p2->group()->use(-href=>"#Tess2"); $d2p2->group()->use(-href=>"#Tess3");

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Tessalate...Part 3 $svg->comment('Now let us define the polygon with the fill inside it refered to by url reference'); $svg->polygon(points=>" ,337.5 ".(140+rand(20)).",".(400+rand(60))." , , , , ,".(160+rand(60))." , , , , , ".(100+rand(10)).','.(200+rand(40))." , , , , , ",fill=>"url(#TessPattern)", stroke=>"black"); $svg->text(x=>100,y=>20)->cdata("Using A tessalated pattern to create a fill"); $svg->anchor(-href=>' >text(x=>50,y=>400, fill=>'red' )->cdata("View Script Source"); print "Content-type: image/svg+xml\n\n"; print $svg->xmlify;

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com Based on TT (no SVG.pm dependency) SVG::TT::Graph – Leo Lapworth #!/usr/bin/perl -w use SVG::TT::Graph::Bar; my $width = '500', my $heigh = '300', = qw(field_1 field_2 field_3); my $graph = SVG::TT::Graph::Bar->new({ # Required for some graph types 'fields' => #.. other config options 'height' => '500', }); = qw( ); $graph->add_data({ 'data' => 'title' => 'Sales 2002', }); print $graph->burn();

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com GD::SVG and SVG::GD An API to an API: – Trying to allow us to re-use GD (raster) code to output SVG (vector) drawings – Translates the GD API to the SVG.pm API – Early development stages. GD::SVG is a replacement to GD – all calls to GD are replaced with calls to GD::SVG. SVG::GD steals some of the GD namespace – Can be dropped in place – Can be used with GD::Graph or GD::Whatever effectively.

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com GD::SVG – Very good – Used in bioperl GD::SVG and SVG::GD SVG::GD – Versatile – Mine

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG::Plot – Kake & Jo Walsh Uses SVG.pm For semantic web experiments – Plot dat triplets (x,y,url anchor) #!/usr/bin/perl -w use SVG::Plot; my $points = [[0,1,' rgeROITtitle.png'],[20,20,' my $plot = SVG::Plot->new( points => $points, debug => 0, max_width => 800, max_height => 400, point_size => 3, point_style => { fill => 'blue', stroke => 'yellow' }, line => 'follow', margin => 10, ); $plot->scale(4); my $grid = { min_x => 0, min_y => 0, max_x => 20, max_y => 20 }; $plot->grid($grid); print $plot->plot;

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG::Graph – SourceForge Based on SVG.pm #!/usr/bin/perl -w use strict; use SVG::Graph; use SVG::Graph::Data; use SVG::Graph::Data::Datum; #create a new SVG document to plot in... my $graph = SVG::Graph->new(width=>600,height=>600,margin=>40); #and create a frame to hold the data/glyphs my $frame = $graph->add_frame; #lets plot y = x^2 = map {SVG::Graph::Data::Datum->new(x=>$_,y=>$_**2)} (0.1,0.2,1,2,3,4,5); my $data = SVG::Graph::Data->new(data => #put the xy data into the frame $frame->add_data($data); #add some glyphs to apply to the data in the frame $frame->add_glyph('axis', #add an axis glyph 'x_absolute_ticks' => 1, #with ticks every one #unit on the x axis 'y_absolute_ticks' => 1, #and ticks every one #unit on the y axis 'stroke' => 'black', #draw the axis black 'stroke-width' => 2, #and 2px thick ); $frame->add_glyph('scatter', #add a scatterplot glyph 'stroke' => 'red', #the dots will be outlined in red, 'fill' => 'red', #filled red, 'fill-opacity' => 0.5, #and 50% opaque ); #print the graphic print $graph->draw;

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com What people are doing with SVG KDE3.2 GPS traces on calibrated maps London Underground track management – No more wrong kind of snow...? Met Office – Graphical weather product (maps) NASA/ESA – Astronaut users manuals in SVG on tablet Pcs Integrated documents Maps, maps, maps Financial data and business graphics 3G Mobile data: MMS -> uses SVG/SMIL – animated, colour phone spam :-(

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com What you can do with SVG... Vector graphics Declarative Vector animations Javascripted Animations Trivial text positionning for CMS systems with text boxes. Media-independance (print/monitor/mobile consistency) – Yeah, right! Open source, open source, open source

Copyright 2001 RO IT Systems GmbH RO IT Systems GmbHwww.roitsystems.com SVG & Perl Resources Sites – http// Serverside SVG portal – by RO IT systems. – SVG recommendation – Comprehensive SVG documentation with extensive examples. – SVG Open conference home – Repository of papers and presentations from past conferences dating back to SVG Open – Petra Kukofkas SVG design page – SVG cartoons and animations, discussions, SVG articles. – project: SVG Programmers' Application Resource Kit. Sponsored by SchemaSoft. – SVG page by Tobias rief in Berlin. – Foundation. – SVG wiki – excellent site for cross-reference. – an SVG discussion forum sponsored by EvolGrafiX. – A rich cartography-specific SVG site with a number of high quality academic papers and demos. – More links to selected SVG- and Perl- related sites – Adobe SVG site. SVG plugin vendor 1. – Corel SVG site. SVG plugin vendor 2. Newsgroups – SVG Developers – Gemeral, dominant SVG newsgroup – SVG Coders – programmers newsgroup Manuals – SVG.pm manual. – Programming SVG With Perl - The first chapter of a book presenting the basics on SVG programming with Perl – SVG Books listed on the SVG wiki