SlideShare una empresa de Scribd logo
1 de 28
@byrichardpowell
byrichardpowell.co.uk
   www.thap.co.uk
drawstuff.jit.su
@byrichardpowell   byrichardpowell.co.uk   thap.co.uk
download nodejs: http://nodejs.org/
                 sign up: http://nodejitsu.com/
               (other hosting options available)




@byrichardpowell   byrichardpowell.co.uk   thap.co.uk
How do we make a real-time
                       collaborative drawing... thing?




@byrichardpowell   byrichardpowell.co.uk   thap.co.uk
Using Events

  User A draws: sends drawing to server
                      |
   Server passes User A’s drawing on to:
                      |
User B, C, D, E, F who draw User A’s drawing
canvas: paperjs
                                  websockets: socket.io
                                    nodejs: express




@byrichardpowell   byrichardpowell.co.uk   thap.co.uk
Installing
nodejs & Express
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
nodejs & express

download & install nodejs: nodejs.org/

$   npm install nodemon -g
$   npm install express -g
$   cd Sites/node_projects/jsnortheast/
$   express
$   npm install -d
$   nodemon app.js

Browse to: 127.0.0.1:3000
Express Anatomy
/node_modules
/public
/routes
/views
app.js
package.json
Working with paper.js
Running Paper.js
// 1. Include script using Jade
script(‘javascript/lib/paper.js’)

// 2. Canvas Element
canvas(id=‘myCanvas’, resize=”true”)

// 3. Canvas Behaviour
script(src=‘javascript/canvas.js’, type=”text/
paperscript”, canvas=”myCanvas”)
Mouse Down & Up
// in canvas.js
function onMouseDown(e) {
  path = new Path()
  path.fillColor = active_rgb_color
  path.add(e.point)
}

function onMouseUp(e) {
  path.add( e.point )
  path.closed = true
  path.smooth()
}
Mouse Drag
// in canvas.js
function onMouseDrag(e) {

    // more info: http://bit.ly/mouse-vectors
    var step = e.delta / 2
    step.angle += 90
    var top = e.middlePoint + step
    var bottom = e.middlePoint - step
    path.add(top)
    path.inset(0, bottom)
    path.smooth();
}
Using Socket.io
Installing socket.io
$ npm install socket.io express

// app.js
var io = require('socket.io').listen(app)

// views/layout.jade
script(src='socket.io/socket.io.js')

// public/javascripts/canvas.js
var socket = io.connect('/')
user: send
function onMouseDrag(e) {
  path_to_send.push({ “x” : e.x, “y” : e.y })
  setInterval( function() {
    var data = JSON.stringify( path_to_send )
    socket.emit(‘draw:progress’, uid, data)
  }, 100)
}

function onMouseUp(e) {
  var data = JSON.stringify( path_to_send )
  socket.emit(‘draw:end’, uid, data)
}
server
socket.on(‘draw:progress’, function( a, d ) {
  io.sockets.emit(‘draw:progress’, a, d)
}

socket.on(‘draw:end’, function( a, d ) {
  io.sockets.emit(‘draw:end’, a, d)
}
user: recieve
socket.on(‘draw:progress’, function( a, d ) {
  if ( a !== uid && d ) {
    progress_external_path( d, a )
  }
}

socket.on(‘draw:end’, function( a, d ) {
  if ( a !== uid && d ) {
    end_external_path( d, a )
  }
}
user: recieve
progress_external_path = function( paths , a ) {

    var path = external_paths[a];
    if (!path) {
      // create new path
      // store using external UID in object
    }
    for ( i = 0; i<paths.length; i++ ) {
      // add point to path
    }

}
And thats about it
github.com/byrichardpowell/draw

     byrichardpowell.co.uk

      @byrichardpowell
     richardo@gmail.com

Más contenido relacionado

La actualidad más candente

From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014Verold
 
Standards.Next: Canvas
Standards.Next: CanvasStandards.Next: Canvas
Standards.Next: CanvasMartin Kliehm
 
What a web developer would like to have…
What a web developer would like to have…What a web developer would like to have…
What a web developer would like to have…Giovanni Costagliola
 
PreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 TricksPreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 Tricksincidentist
 
unity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsunity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsDarren Woodiwiss
 
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!FITC
 
Webdings and Wingdings
Webdings and WingdingsWebdings and Wingdings
Webdings and WingdingsRalph Julius
 
React-VR: An Early Experiment with React and WebGL for VR Development
React-VR: An Early Experiment with React and WebGL for VR DevelopmentReact-VR: An Early Experiment with React and WebGL for VR Development
React-VR: An Early Experiment with React and WebGL for VR DevelopmentTony Parisi
 
mastodon API
mastodon APImastodon API
mastodon APItreby
 

La actualidad más candente (9)

From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
 
Standards.Next: Canvas
Standards.Next: CanvasStandards.Next: Canvas
Standards.Next: Canvas
 
What a web developer would like to have…
What a web developer would like to have…What a web developer would like to have…
What a web developer would like to have…
 
PreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 TricksPreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 Tricks
 
unity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsunity-clinic2-unityscript-basics
unity-clinic2-unityscript-basics
 
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
 
Webdings and Wingdings
Webdings and WingdingsWebdings and Wingdings
Webdings and Wingdings
 
React-VR: An Early Experiment with React and WebGL for VR Development
React-VR: An Early Experiment with React and WebGL for VR DevelopmentReact-VR: An Early Experiment with React and WebGL for VR Development
React-VR: An Early Experiment with React and WebGL for VR Development
 
mastodon API
mastodon APImastodon API
mastodon API
 

Similar a Draw stuff at @jsnortheast

Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing NodejsPhil Hawksworth
 
May The Nodejs Be With You
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With YouDalibor Gogic
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角Mei-yu Chen
 
Container (Docker) Orchestration Tools
Container (Docker) Orchestration ToolsContainer (Docker) Orchestration Tools
Container (Docker) Orchestration ToolsDhilipsiva DS
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mateCodemotion
 
Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014Christian Grobmeier
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoJavier Abadía
 
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsEP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsAlessandro Molina
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsJay Harris
 
Real World Optimization
Real World OptimizationReal World Optimization
Real World OptimizationDavid Golden
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfRahulRoy130127
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)wonyong hwang
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotNomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotParis Container Day
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Future Insights
 

Similar a Draw stuff at @jsnortheast (20)

Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
May The Nodejs Be With You
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With You
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
 
Container (Docker) Orchestration Tools
Container (Docker) Orchestration ToolsContainer (Docker) Orchestration Tools
Container (Docker) Orchestration Tools
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar Django
 
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsEP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.js
 
Real World Optimization
Real World OptimizationReal World Optimization
Real World Optimization
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien CadiotNomad, l'orchestration made in Hashicorp - Bastien Cadiot
Nomad, l'orchestration made in Hashicorp - Bastien Cadiot
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
 

Más de Richard Powell

Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Richard Powell
 
Designing user on-boarding
Designing user on-boardingDesigning user on-boarding
Designing user on-boardingRichard Powell
 
Data Visualisation with D3 & Rickshaw - Berlin Expert Days
Data Visualisation with D3 & Rickshaw - Berlin Expert DaysData Visualisation with D3 & Rickshaw - Berlin Expert Days
Data Visualisation with D3 & Rickshaw - Berlin Expert DaysRichard Powell
 
Time-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & RickshawTime-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & RickshawRichard Powell
 
Angular js, Yeomon & Grunt
Angular js, Yeomon & GruntAngular js, Yeomon & Grunt
Angular js, Yeomon & GruntRichard Powell
 
D3 Rickshaw and Backbone in 50 minutes
D3 Rickshaw and Backbone in 50 minutesD3 Rickshaw and Backbone in 50 minutes
D3 Rickshaw and Backbone in 50 minutesRichard Powell
 
Angular.js, Yeomon & Grunt
Angular.js, Yeomon & GruntAngular.js, Yeomon & Grunt
Angular.js, Yeomon & GruntRichard Powell
 
HTML5 Canvas @SuperMondays, Newcastle
HTML5 Canvas @SuperMondays, NewcastleHTML5 Canvas @SuperMondays, Newcastle
HTML5 Canvas @SuperMondays, NewcastleRichard Powell
 

Más de Richard Powell (9)

Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.
 
Designing user on-boarding
Designing user on-boardingDesigning user on-boarding
Designing user on-boarding
 
Data Visualisation with D3 & Rickshaw - Berlin Expert Days
Data Visualisation with D3 & Rickshaw - Berlin Expert DaysData Visualisation with D3 & Rickshaw - Berlin Expert Days
Data Visualisation with D3 & Rickshaw - Berlin Expert Days
 
Time-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & RickshawTime-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & Rickshaw
 
Angular js, Yeomon & Grunt
Angular js, Yeomon & GruntAngular js, Yeomon & Grunt
Angular js, Yeomon & Grunt
 
D3 Rickshaw and Backbone in 50 minutes
D3 Rickshaw and Backbone in 50 minutesD3 Rickshaw and Backbone in 50 minutes
D3 Rickshaw and Backbone in 50 minutes
 
Front end-performance
Front end-performanceFront end-performance
Front end-performance
 
Angular.js, Yeomon & Grunt
Angular.js, Yeomon & GruntAngular.js, Yeomon & Grunt
Angular.js, Yeomon & Grunt
 
HTML5 Canvas @SuperMondays, Newcastle
HTML5 Canvas @SuperMondays, NewcastleHTML5 Canvas @SuperMondays, Newcastle
HTML5 Canvas @SuperMondays, Newcastle
 

Último

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Último (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Draw stuff at @jsnortheast

  • 2. drawstuff.jit.su @byrichardpowell byrichardpowell.co.uk thap.co.uk
  • 3. download nodejs: http://nodejs.org/ sign up: http://nodejitsu.com/ (other hosting options available) @byrichardpowell byrichardpowell.co.uk thap.co.uk
  • 4. How do we make a real-time collaborative drawing... thing? @byrichardpowell byrichardpowell.co.uk thap.co.uk
  • 5. Using Events User A draws: sends drawing to server | Server passes User A’s drawing on to: | User B, C, D, E, F who draw User A’s drawing
  • 6. canvas: paperjs websockets: socket.io nodejs: express @byrichardpowell byrichardpowell.co.uk thap.co.uk
  • 8. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 9. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 10. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 11. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 12. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 13. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 14. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 15. nodejs & express download & install nodejs: nodejs.org/ $ npm install nodemon -g $ npm install express -g $ cd Sites/node_projects/jsnortheast/ $ express $ npm install -d $ nodemon app.js Browse to: 127.0.0.1:3000
  • 18. Running Paper.js // 1. Include script using Jade script(‘javascript/lib/paper.js’) // 2. Canvas Element canvas(id=‘myCanvas’, resize=”true”) // 3. Canvas Behaviour script(src=‘javascript/canvas.js’, type=”text/ paperscript”, canvas=”myCanvas”)
  • 19. Mouse Down & Up // in canvas.js function onMouseDown(e) { path = new Path() path.fillColor = active_rgb_color path.add(e.point) } function onMouseUp(e) { path.add( e.point ) path.closed = true path.smooth() }
  • 20. Mouse Drag // in canvas.js function onMouseDrag(e) { // more info: http://bit.ly/mouse-vectors var step = e.delta / 2 step.angle += 90 var top = e.middlePoint + step var bottom = e.middlePoint - step path.add(top) path.inset(0, bottom) path.smooth(); }
  • 22. Installing socket.io $ npm install socket.io express // app.js var io = require('socket.io').listen(app) // views/layout.jade script(src='socket.io/socket.io.js') // public/javascripts/canvas.js var socket = io.connect('/')
  • 23. user: send function onMouseDrag(e) { path_to_send.push({ “x” : e.x, “y” : e.y }) setInterval( function() { var data = JSON.stringify( path_to_send ) socket.emit(‘draw:progress’, uid, data) }, 100) } function onMouseUp(e) { var data = JSON.stringify( path_to_send ) socket.emit(‘draw:end’, uid, data) }
  • 24. server socket.on(‘draw:progress’, function( a, d ) { io.sockets.emit(‘draw:progress’, a, d) } socket.on(‘draw:end’, function( a, d ) { io.sockets.emit(‘draw:end’, a, d) }
  • 25. user: recieve socket.on(‘draw:progress’, function( a, d ) { if ( a !== uid && d ) { progress_external_path( d, a ) } } socket.on(‘draw:end’, function( a, d ) { if ( a !== uid && d ) { end_external_path( d, a ) } }
  • 26. user: recieve progress_external_path = function( paths , a ) { var path = external_paths[a]; if (!path) { // create new path // store using external UID in object } for ( i = 0; i<paths.length; i++ ) { // add point to path } }
  • 28. github.com/byrichardpowell/draw byrichardpowell.co.uk @byrichardpowell richardo@gmail.com

Notas del editor

  1. * Hi, Im Richard\n* web designer, alot of time writing Javascript\n* Work for Thap, cool company\n* Give jQuery workshops\n
  2. * Real-Time Collaborative Drawing tool\n* Lets check it out\n
  3. * How many people here have installed nodejs?\n* Would love it if you could, can follow some of the slides &amp; run your first nodejs App\n* Can help at the end\n* Please interrupt if you have questions.\n
  4. * How do you make a real-time collaborative drawing thing?\n* Simpler than you might think\n
  5. * Its all about events\n* When user A draws, they send their drawing to the server.\n* Server then sends the drawing onto all other users \n
  6. * HTML5 Canvas: Element, Drawing Context, Bitmap using javascript.\n* PaperJS: covers key concepts: points, paths, shapes, text, animations\n* Websockets: Continuous 2 way connection between 2 points. Better than AJAX\n* Nodejs: How many people know of this?\n* Express makes it easy, will try and install both during presentation\n
  7. * Try and code-along. Will offer help at end.\n
  8. * Hopefully you&amp;#x2019;ve already done this\n
  9. * Designers: Dont be scared of terminal\n* NPM: handles javascript packages. Like dealing with Ruby gems\n* Nodemon, runs your app but restarts when you make changes\n* I&amp;#x2019;ve wasted a few hours by not using nodemon\n* This command means you can use nodemon wherever you want\n
  10. * You can now create new Express applications\n* Express is a great little framework\n
  11. * Cd means change directory\n* Im going to create my app in a folder called jsnortheast\n
  12. * Creates a new Express application\n
  13. * Express has dependencies; jade, for example.\n* Jade is a templating engine for HTML, think HAML for javascript\n* this command installs those dependencies so that Express can run\n
  14. * Use node monitor to run the newly created express application\n
  15. * You should see &amp;#x201C;Welcome to Express&amp;#x201D;\n\n
  16. * Follows familiar MVC structure\n* node_modules - dependencies reside here: jade, socket.io etc\n* public: images, css, client-side javascript\n* routes: the URL structure of your application\n* views: the HTML (Jade) of your app\n* app.js: runs your application\n* package.json: dependencies list &amp; versions, dont need to edit\n
  17. * Im using a very small part of paper.js\n* Honestly, its all on the paperjs website.\n
  18. * 1. Include paperJS on the page. This is Jade which is converted into a HTML script tag\n* 2. Include a Canvas element &amp; tell paperJS to automatically re-size it to the window dimensions\n* 3. A file our javascript. Type tells paperJS to run it, canvas tells paperJS which canvas to use \n
  19. * on mouse down we create a new path at the cursors poistion and give it a color\n* on mouse up we close the path &amp; smooth it\n
  20. * make path wider/narrower depending on speed of mouse movement\n* Add new points to the path at the cursors position\n* Paths are drawn as the user drags &amp; closed as they mouse up\n
  21. * Socket io passes draw data from user to server to other users in real time\n
  22. * First install a version of socket.io just for express\n* Include socket.io in the HTML\n* Connect to the server in the client side javascript\n
  23. * on mouse drag we add points to an array\n* Every 100ms we send that array to the server with a UID and the event name: &amp;#x2018;draw:progress&amp;#x2019;\n* on mouse up we send the the array and UID to the server\n* this time we send it with a different event name.\n
  24. * Rugby ball pass, recieves data, passes on to users as quickly as possible\n
  25. * On both types of draw event, user checks &amp;#x2018; is this my UID ? &amp;#x2018;\n* if not it draws that path.\n
  26. * first we check to see if a path has already been created using that UID (a)\n* if not we create it\n* Then we add each point in the paths array to the path\n
  27. * This was a hack day project, you can achieve a lot in 8 hours\n* This is really fun technology\n* Very popular tech: 1,500 visits in 5 days.\n* Real-time good to be playing with\n\n \n
  28. * Please do download the source code &amp; create your own &amp;#x2018;things&amp;#x2019;\n* I wrote a blog post about draw stuff, check it out\n* I tweet a lot, feel free to tweet me questions or ask for help, or email me.\n* Any questions?\n\n