Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Coding JavaScript the expressive way Learning & Development Telerik Software Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
With Mocha and Karma Telerik Academy Telerik Software Academy.
C# Fundamentals – Part I
Welcome to the JSON-stores world Telerik Software Academy Databases.
NoSQL Concepts, Redis, MongoDB, CouchDB
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Marketing Mix, SWOT Analysis and Stages of Developing an Idea Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Optimization problems, Greedy Algorithms, Optimal Substructure and Greedy choice Learning & Development Team Telerik Software.
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Telerik Software Academy End-to-end JavaScript Applications.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Creating Graphics for the Web Learning & Development Team Telerik Software Academy.
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy

 KineticJS overview and setup  Working with KineticJS  Initializing canvas  Drawing shapes  Rects, circles, paths, blobs  Event handlers  Attaching click, drag&drop

Overview and Setup

 KineticJS is a JavaScript framework to work with the Canvas  Introduces a refined API for canvas functionality  Has stages and layers for better canvas performance

 To use KineticJS:  Download the kinetic.js framework from the site  At  Include the framework into your HTML page:  Create a div with ID, where you want the canvas to be initialized:

 To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer);

 To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer); Create a stage using the div id

 To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer); Create a stage using the div id Create a layer to add shapes

 To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer); Create a stage using the div id Create a layer to add shapes Create shapes

Add the shapes to the layer  To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer); Create a stage using the div id Create a layer to add shapes Create shapes Add the shapes to the layer

 To use KineticJS (cont.):  Do the following in the script var stage = new Kinetic.Stage({ container: 'canvas-container', container: 'canvas-container', width: 450, width: 450, height: 350 height: 350}); var layer = new Kinetic.Layer(); var rect = new Kinetic.Rect(options); var circle = new Kinetic.Circle(options); layer.add (rect); layer.add (circle); stage.add(layer); Create a stage using the div id Create a layer to add shapes Create shapes Add the layer to the stage Create shapes Add the shapes to the layer

Live Demo

 KineticJS has all the default shapes from Canvas, and some more:  Rectangular rect = new Kinetic.Rect({ fill: 'yellowgreen', fill: 'yellowgreen', stroke: '#CCCCCC', stroke: '#CCCCCC', x: 250, x: 250, y: 350, y: 350, width: 57, width: 57, height: 93 height: 93}); circle = new Kinetic.Circle({ radius: 45, radius: 45, fill: 'purple', fill: 'purple', stroke: 'blue', stroke: 'blue', strokeWidth: 3, strokeWidth: 3, x: 450, x: 450, y: 350, y: 350,});  Circle

 KineticJS has all the default shapes from Canvas, and some more:  Rectangular rect = new Kinetic.Rect({ fill: 'yellowgreen', fill: 'yellowgreen', stroke: '#CCCCCC', stroke: '#CCCCCC', x: 250, x: 250, y: 350, y: 350, width: 57, width: 57, height: 93 height: 93}); circle = new Kinetic.Circle({ radius: 45, radius: 45, fill: 'purple', fill: 'purple', stroke: 'blue', stroke: 'blue', strokeWidth: 3, strokeWidth: 3, x: 450, x: 450, y: 350, y: 350,});  Circle

 KineticJS has all the default shapes from Canvas, and some more:  Straight line  Curved line straight = new Kinetic.Line({ points: [x1, y1, x2, y2], points: [x1, y1, x2, y2], stroke: 'green', stroke: 'green', strokeWidth: 2, strokeWidth: 2, lineJoin: 'round' lineJoin: 'round'}); curved = new Kinetic.Line({ points: [x1, y1, x2, y2], points: [x1, y1, x2, y2], stroke: 'green', stroke: 'green', strokeWidth: 2, strokeWidth: 2, tension: 1 tension: 1});

 KineticJS has all the default shapes from Canvas, and some more:  Straight line  Curved line straight = new Kinetic.Line({ points: [x1, y1, x2, y2], points: [x1, y1, x2, y2], stroke: 'green', stroke: 'green', strokeWidth: 2, strokeWidth: 2, lineJoin: 'round' lineJoin: 'round'}); curved = new Kinetic.Line({ points: [x1, y1, x2, y2], points: [x1, y1, x2, y2], stroke: 'green', stroke: 'green', strokeWidth: 2, strokeWidth: 2, tension: 1 tension: 1});

 KineticJS has all the default shapes from Canvas, and some more:  Polygon  Blob polygon = new Kinetic.Line({ points: [ … ] points: [ … ] stroke: 'green', stroke: 'green', fill: 'yellowgreen' fill: 'yellowgreen' strokeWidth: 2, strokeWidth: 2, closed: true closed: true}); blob = new Kinetic.Line({ points: [ … ], points: [ … ], stroke: 'green', stroke: 'green', fill: 'purple', fill: 'purple', closed: true, closed: true, tension: 0.5 tension: 0.5});

 KineticJS has all the default shapes from Canvas, and some more:  Polygon  Blob polygon = new Kinetic.Line({ points: [ … ] points: [ … ] stroke: 'green', stroke: 'green', fill: 'yellowgreen' fill: 'yellowgreen' strokeWidth: 2, strokeWidth: 2, closed: true closed: true}); blob = new Kinetic.Line({ points: [ … ], points: [ … ], stroke: 'green', stroke: 'green', fill: 'purple', fill: 'purple', closed: true, closed: true, tension: 0.5 tension: 0.5});

Live Demo

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

1. Read the tutorial on KineticJS:  At canvas-events-tutorials-introduction-with-kineticjs/ canvas-events-tutorials-introduction-with-kineticjs/ canvas-events-tutorials-introduction-with-kineticjs/  Read about custom shapes and text 2. Using Kinetic create a family tree var familyMembers = [{ mother: 'Maria Petrova', mother: 'Maria Petrova', father: 'Georgi Petrov', father: 'Georgi Petrov', children: ['Teodora Petrova', 'Peter Petrov'] children: ['Teodora Petrova', 'Peter Petrov'] }, { mother: 'Petra Stamatova', mother: 'Petra Stamatova', father: Todor Stamatov', father: Todor Stamatov', children: ['Maria Petrova'] children: ['Maria Petrova']}]