The Sys.UI.DomEvent class in the Microsoft AJAX library provides methods for adding and removing event handlers from DOM elements. It allows attaching handlers to elements using addHandler(), adding multiple handlers with addHandlers(), and removing handlers with removeHandler(). Event handler functions are passed the event object which contains information like key presses and mouse coordinates.
The document defines an AreaVolumen class with constructors that take parameters to define dimensions. It contains fields to store the dimensions and a method ayv() that calculates and returns the area or volume based on whether the constructors took 2 or 3 dimensional parameters. The Main class creates AreaVolumen objects with different parameters and calls ayv() to output the calculated area or volume.
XNA coding series.
Exercise 1:
Hello World in XNA.
Exercise 2:
Draw 2d image.
Exercise 3:
Using Keyboard and Mouse in a PC game.
Exercise 4:
Crating a Menu system in a PC game.
Exercise 5:
Play MP3 in XNA.
The document describes code for a game that uses sprites. It defines an interface for sprites that includes reset, draw, and update methods. It loads a texture, creates a sprite, and adds it to a list. It includes code for initializing gestures, reading gestures to get positions to create sprites, and a growing sprite class that overrides the update method. It also includes code snippets for deployment, capabilities, and app metadata.
The document describes an implementation of the Model-View-Intent (MVI) architecture pattern for Android applications. It explains the key components of MVI - the Intent, Model, and View. The Intent interprets user interactions and outputs actions. The Model manages application state from actions and outputs state changes. The View renders state. It then provides code examples of an Android drawing app implemented using MVI, including classes for the Intent, Model, View, and drawing state data.
The document describes the initialization, loading, updating, and drawing of sprites for a game engine. It defines an interface for sprites that includes resetting, drawing, and updating methods. It shows sample code for loading a texture, creating a sprite, and drawing sprites. It also includes code for updating sprite properties, generating random colors, removing and adding sprites on touch gestures, and deployment and capabilities manifests.
Александр Зимин – Анимация как средство самовыраженияCocoaHeads
Расскажу о том, как создавать сложные анимации в iOS приложениях.
- CoreAnimation и его особенности
- Анимационные переходы между экранами
- Работа с анимациями, экспортированными из Adobe After Effects
The Sys.UI.DomEvent class in the Microsoft AJAX library provides methods for adding and removing event handlers from DOM elements. It allows attaching handlers to elements using addHandler(), adding multiple handlers with addHandlers(), and removing handlers with removeHandler(). Event handler functions are passed the event object which contains information like key presses and mouse coordinates.
The document defines an AreaVolumen class with constructors that take parameters to define dimensions. It contains fields to store the dimensions and a method ayv() that calculates and returns the area or volume based on whether the constructors took 2 or 3 dimensional parameters. The Main class creates AreaVolumen objects with different parameters and calls ayv() to output the calculated area or volume.
XNA coding series.
Exercise 1:
Hello World in XNA.
Exercise 2:
Draw 2d image.
Exercise 3:
Using Keyboard and Mouse in a PC game.
Exercise 4:
Crating a Menu system in a PC game.
Exercise 5:
Play MP3 in XNA.
The document describes code for a game that uses sprites. It defines an interface for sprites that includes reset, draw, and update methods. It loads a texture, creates a sprite, and adds it to a list. It includes code for initializing gestures, reading gestures to get positions to create sprites, and a growing sprite class that overrides the update method. It also includes code snippets for deployment, capabilities, and app metadata.
The document describes an implementation of the Model-View-Intent (MVI) architecture pattern for Android applications. It explains the key components of MVI - the Intent, Model, and View. The Intent interprets user interactions and outputs actions. The Model manages application state from actions and outputs state changes. The View renders state. It then provides code examples of an Android drawing app implemented using MVI, including classes for the Intent, Model, View, and drawing state data.
The document describes the initialization, loading, updating, and drawing of sprites for a game engine. It defines an interface for sprites that includes resetting, drawing, and updating methods. It shows sample code for loading a texture, creating a sprite, and drawing sprites. It also includes code for updating sprite properties, generating random colors, removing and adding sprites on touch gestures, and deployment and capabilities manifests.
Александр Зимин – Анимация как средство самовыраженияCocoaHeads
Расскажу о том, как создавать сложные анимации в iOS приложениях.
- CoreAnimation и его особенности
- Анимационные переходы между экранами
- Работа с анимациями, экспортированными из Adobe After Effects
Devenez contributeur pour la première plateforme collaborative dédiée aux e-commerçants français !
Grâce à E-commerce Nation :
-Gagnez en visibilité
-Devenez la solution aux problèmes des e-commerçants
-Attirer de nouveaux prospects
-Obtenez un statut de référence dans votre domaine
http://www.ecommerce-nation.fr/
This document discusses the application of remote sensing techniques in monitoring crop fields for site-specific crop management. Periodic satellite imagery from Landsat 8 and Sentinel-2 is used to identify spatial variability in vegetation growth across fields at a medium resolution. Vegetation indices like NDVI and EVI are calculated from the imagery and used to assess crop stands and delineate management zones. High resolution aerial imagery from an Ultracam camera is also used to map fields and guide variable applications of fertilizers and pesticides. Farm telemetry sensors monitor tractor movement, fuel usage, and work logs to optimize farm inputs and machinery utilization.
דשן גת מחויבת לספק פתרונות דישון, http://www.deshengat.co.il באופן יעיל ומדויק ובאיכות מעולה, בהתאם למפרטים הטכניים של כל מוצר ומוצר תוך פיתוח תהליכי ייצור ייחודיים, יעילים ואמינים, בהתאם לעקרונות איכות הסביבה.
החברה מחויבת לתת שירות אמין ללקוחותיה כולל ייעוץ אגרונומי וטכנולוגי למתן פתרונות מיטביים לדישון גידולים חקלאיים לפי מיטב הידע הקיים ארץ ובעולם.
Future of testing – impact of mobile devices somenath nag- calsoft labsSomenath Nag
Over last couple of years, mobile devices have shown a phenomenal growth, at the same time PC industry is on a declining path. Due to this, we are experiencing a paradigm shift on how applications are built, tested, and used by the end users, and has a potential to create a disruption in the traditional way of software development and QA. Though it started with consumers, enterprises are also embracing mobility more and more, especially after the stupendous success of iPad. At the same time enterprises are also facing challenges in the area of provisioning, data management, device management, and security. Mobile devices are also used differently compared to traditional computing platforms. Due to this mobility devices and platforms throw up a new kind of challenges to testing fraternity. Calsoft Labs, with its unique competence and experience of working with leading Software and Hardware companies, has been in the forefront of mobility. Calsoft Labs’ Mobility & Testing practice have been working together for some time to build methodologies, processes, and frameworks to address the challenges arising because of the above mentioned challenges shift and to create a new paradigm in application and product testing.
L'intelligence ambiante - publication Kamitis decembre 2013 - KAMITIS
Jean CAELEN, expert en dialogue Homme-Machine et directeur adjoint de l’institut Carnot LSI (Logiciels et Systèmes Intelligents) a accepté de nous parler de ses recherches et de partager avec nous sa vision de l’habitat intelligent.
La rubrique Focus, qui détaille ces tendances, met également en évidence le manque de maturité du secteur et les prédictions contradictoires quant à son évolution. Mais malgré ces incertitudes, il est aujourd’hui évident que l’intelligence ambiante fera bien partie de notre quotidien de demain
modern security risks for big data and mobile applicationsTrivadis
The document discusses modern security risks for big data and mobile applications. It covers past data breach incidents, privacy and protection issues with big data like lack of anonymity and profiling risks. For mobile applications, it outlines decomposition risks, bad permission definitions, and risks with unencrypted data both in transit and at rest. The presentation recommends focusing on security controls like access controls and monitoring for big data, and addressing vulnerabilities from permissions, encryption, and component interactions for mobile applications.
The canvas element allows rendering of graphs and visual images directly in the browser. It provides an API for drawing primitives like rectangles, paths, text and images. The API is small but allows drawing complex shapes. However, coding paths can be painful and there is no way to store paths. Browser support for the canvas element is improving but still lacks in some older browsers.
This document provides an overview of a presentation about creating masterpieces using the JavaScript library Raphaël. The presentation will demonstrate how to make a 1970s board game interactive in the browser using Raphaël, including drawing hexagonal tiles, rivers, forests, villages, slopes and game pieces. It will explain how Raphaël was used to solve various drawing challenges and manage vector graphics, but will not show infrastructure details like jQuery, PHP and database usage. The goal is to illustrate Raphaël's capabilities for precise scalable vector graphics.
SaveI need help with this maze gui that I wrote in java, I am tryi.pdfarihantstoneart
Save
I need help with this maze gui that I wrote in java, I am trying to find the shortest path but I dont
know how to implement the FindshortestPath Method.
I was given this as a stragedy to solve the findshortestpathMethod():
Create two LinkedLists of MazeMap objects. One will be the list of map objects for cells at
distance x from the center. The other will be the list of map objects for cells at distance x + 1.
Initialize the list at distance x to contain a MazeMap object which refers to the center cell of the
maze. Since this map object refers to the center cell, it does not need to refer to any other
MazeMap object, so its MazeMap reference can be set to null. Set the center cell’s visited field
to true to indicate that this cell has already been added to the map.
Set up a loop to run until the maze entrance is mapped. This loop does the following:
Set up a loop to process each map object from the list at distance x. This loop does the following:
i.Get the cell from the map object
ii.If this cell is the entrance cell, set the entrance and break out of the loop!
iii.Check each direction from this cell and for an accessible neighbor cell
Get a reference to that neighbor cell
If the neighbor cell has not already been visited
Set the cell’s visited field to true so its only processed once
Create a MazeMap object that refers to this neighbor cell
Make this MazeMap object refer to the current map object being processed – ie the cell one step
closer to center
Add this MazeMap object to the list at distance x + 1
List at distance x has been processed. The list at distance x + 1 is now complete, so make the list
at distance x refer to list at distance x + 1. Then create a new empty list for the list at distance x +
1.
At this point, the entrance points at the map object which refers to cell 1,1. That map object also
refers to a map object which is one step closer to the center. Write a loop that traverses this trail
of references until it reaches the end (a null reference). For each map object:
Get the cell referred to.
Call the drawCircle method with a color, the cell’s row and column, and SMALL.
Call the delay method with a SHORT delay. This slows down the drawing process so you can
watch the path being displayed.
Advance to the next map object in the list.
here is the code so far*********
here is my code: ******mazeApp*******
package mazepackage;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.TextInputDialog;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class MazeApp extends Application
{
// default canvas size is DEFAULT_SIZE-by-DEFAULT_SIZE
private static final int DEFAULT_SIZE = 768;
private int width = DEFAULT_SIZE;
private int height = DEFAULT_SIZE;
// The graphics context is needed to enable drawing on the canvas
private Graphics.
The document discusses using mouse and keyboard events in Java programs. It provides examples of using MouseListener and MouseEvent to detect mouse clicks on objects. It also demonstrates using MouseMotionListener to handle mouse drag and move events. Keyboard events are handled using KeyListener. The examples show drawing shapes by clicking buttons or keys, and changing shape properties by clicking or dragging the mouse.
The document provides source code for generating and manipulating computer graphics using various algorithms. It includes algorithms for drawing lines, circles and curves, as well as algorithms for translating, rotating, and scaling two-dimensional and three-dimensional objects. The source code is written in C/C++ and uses graphics libraries to output the results. Various input parameters are taken from the user and output is displayed to demonstrate the algorithms.
The document provides an overview of using the HTML5 canvas element to draw graphics and animations. It covers topics like rendering contexts, paths, styles, gradients, text, shapes, mouse/touch interaction, animation, and libraries. Code examples demonstrate how to draw basic shapes, handle user input, interpolate lines, add gradients, render to canvas, and more. The document is a tutorial for learning the capabilities of the canvas element.
need help with code I wrote. This code is a maze gui, and i need hel.pdfarcotstarsports
need help with code I wrote. This code is a maze gui, and i need help with the method
shorterstpath(); here is my code:
******mazeApp*******
package mazepackage;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.TextInputDialog;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class MazeApp extends Application
{
// default canvas size is DEFAULT_SIZE-by-DEFAULT_SIZE
private static final int DEFAULT_SIZE = 768;
private int width = DEFAULT_SIZE;
private int height = DEFAULT_SIZE;
// The graphics context is needed to enable drawing on the canvas
private GraphicsContext gc;
// boundary of drawing canvas, 0% border
// private static final double BORDER = 0.05;
private static final double BORDER = 0.00;
private double xmin, ymin, xmax, ymax;
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage)
{
Group root = new Group();
Canvas canvas = new Canvas(width, height);
gc = canvas.getGraphicsContext2D();
gc.setLineWidth(2);
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, width, height);
root.getChildren().add(canvas);
TextInputDialog tid = new TextInputDialog();
tid.setTitle(\"Maze Size\");
tid.setHeaderText(\"Enter maze size between 10 and 50\");
tid.showAndWait();
int size = Integer.parseInt(tid.getResult());
if (size > 50)
size = 50;
if (size < 10)
size = 10;
primaryStage.setTitle(\"Maze Application\");
primaryStage.setScene(new Scene(root));
primaryStage.setResizable(false);
// Make sure that the application goes away when then window is closed
primaryStage.setOnCloseRequest(e -> System.exit(0));
primaryStage.show();
Maze maze = new Maze(this, size);
// Must solve the maze in a separate thread or else
// the GUI wont update until the end.....
Thread solver = new Thread(
new Runnable () {
public void run()
{
while(true)
{
maze.buildAndDrawMaze();
maze.findShortestPath();
try
{
Thread.sleep(5000);
}
catch(Exception e) { }
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, width, height);
}
}
});
solver.start();
}
/**
* Sets the pen color to the specified color.
*
* @param color the color to make the pen
*/
public void setPenColor(Color color) {
gc.setStroke(color);
}
/**
* Sets the pen color to the specified color.
*
* @param color the color to make the pen
*/
public void setFillColor(Color color) {
gc.setFill(color);
}
/**
* Sets the x-scale to the specified range.
*
* @param min the minimum value of the x-scale
* @param max the maximum value of the x-scale
* @throws IllegalArgumentException if {@code (max == min)}
*/
public void setXscale(double min, double max) {
double size = max - min;
if (size == 0.0) {
throw new IllegalArgumentException(\"the min and max are the same\");
}
xmin = min - BORDER * size;
xmax = max + BORDER * size;
}
/**
* Sets the y-scale to the specified range.
*
* @param min the minimum valu.
This program writes a C code to shear a cuboid. It includes graphics header files and uses the Bresenham's line algorithm to draw lines. The program defines a function called 'bress' to draw lines using the Bresenham algorithm. It takes coordinates of two points as input and uses conditions on the slope to determine the increment, endpoint and direction of line drawing. This function is used to draw the individual lines of the cuboid before and after shearing.
This document provides instructions for drawing graphs in Pascal using the Graph unit. It discusses initializing graphics mode, calculating appropriate coordinates for the screen, and algorithms for drawing normal and polar functions. Examples are given to illustrate drawing the linear function f(x)=x and polar function f(u)=1+sin(u). The document concludes with reminding students what they need to do in exams and providing contact information for the programming group.
- HTML5 Canvas allows for dynamic drawing and animating directly in HTML using JavaScript scripting. It can be used to draw shapes, images, text and respond to user input like mouse clicks.
- The canvas element creates a grid that allows positioning images and objects by x and y coordinates. Basic drawing functions include lines, rectangles, curves and filling areas with colors.
- Transformations like translation and rotation can change the orientation of drawings on the canvas. The drawing state can be saved and restored to return to previous settings.
- Images can be drawn and manipulated at the pixel level by accessing image data. Animation is achieved by redrawing the canvas repeatedly with small changes.
- Data from sources like JSON can be
The document contains 10 programs written in C programming language to perform various 2D and 3D graphics operations like drawing lines, rectangles, circles, ellipses, torus, scaling, rotating, shearing and reflecting objects. Program 1-5 demonstrate drawing basic shapes like line, rectangle, circle and ellipse. Program 6 draws a 3D torus using OpenGL. Program 7-9 demonstrate transformations like scaling, rotating and shearing of objects. Program 10 shows reflection of an object about x-axis, y-axis and origin.
The document provides instructions and examples for making games using HTML5 canvas and JavaScript. It discusses using canvas to draw basic shapes and images. It introduces the concept of sprites as reusable drawing components and provides an example sprite class. It demonstrates how to create a game loop to continuously update and render sprites to animate them. It also provides an example of making a sprite respond to keyboard input to allow user control. The document serves as a tutorial for building the core components of a simple HTML5 canvas game.
Devenez contributeur pour la première plateforme collaborative dédiée aux e-commerçants français !
Grâce à E-commerce Nation :
-Gagnez en visibilité
-Devenez la solution aux problèmes des e-commerçants
-Attirer de nouveaux prospects
-Obtenez un statut de référence dans votre domaine
http://www.ecommerce-nation.fr/
This document discusses the application of remote sensing techniques in monitoring crop fields for site-specific crop management. Periodic satellite imagery from Landsat 8 and Sentinel-2 is used to identify spatial variability in vegetation growth across fields at a medium resolution. Vegetation indices like NDVI and EVI are calculated from the imagery and used to assess crop stands and delineate management zones. High resolution aerial imagery from an Ultracam camera is also used to map fields and guide variable applications of fertilizers and pesticides. Farm telemetry sensors monitor tractor movement, fuel usage, and work logs to optimize farm inputs and machinery utilization.
דשן גת מחויבת לספק פתרונות דישון, http://www.deshengat.co.il באופן יעיל ומדויק ובאיכות מעולה, בהתאם למפרטים הטכניים של כל מוצר ומוצר תוך פיתוח תהליכי ייצור ייחודיים, יעילים ואמינים, בהתאם לעקרונות איכות הסביבה.
החברה מחויבת לתת שירות אמין ללקוחותיה כולל ייעוץ אגרונומי וטכנולוגי למתן פתרונות מיטביים לדישון גידולים חקלאיים לפי מיטב הידע הקיים ארץ ובעולם.
Future of testing – impact of mobile devices somenath nag- calsoft labsSomenath Nag
Over last couple of years, mobile devices have shown a phenomenal growth, at the same time PC industry is on a declining path. Due to this, we are experiencing a paradigm shift on how applications are built, tested, and used by the end users, and has a potential to create a disruption in the traditional way of software development and QA. Though it started with consumers, enterprises are also embracing mobility more and more, especially after the stupendous success of iPad. At the same time enterprises are also facing challenges in the area of provisioning, data management, device management, and security. Mobile devices are also used differently compared to traditional computing platforms. Due to this mobility devices and platforms throw up a new kind of challenges to testing fraternity. Calsoft Labs, with its unique competence and experience of working with leading Software and Hardware companies, has been in the forefront of mobility. Calsoft Labs’ Mobility & Testing practice have been working together for some time to build methodologies, processes, and frameworks to address the challenges arising because of the above mentioned challenges shift and to create a new paradigm in application and product testing.
L'intelligence ambiante - publication Kamitis decembre 2013 - KAMITIS
Jean CAELEN, expert en dialogue Homme-Machine et directeur adjoint de l’institut Carnot LSI (Logiciels et Systèmes Intelligents) a accepté de nous parler de ses recherches et de partager avec nous sa vision de l’habitat intelligent.
La rubrique Focus, qui détaille ces tendances, met également en évidence le manque de maturité du secteur et les prédictions contradictoires quant à son évolution. Mais malgré ces incertitudes, il est aujourd’hui évident que l’intelligence ambiante fera bien partie de notre quotidien de demain
modern security risks for big data and mobile applicationsTrivadis
The document discusses modern security risks for big data and mobile applications. It covers past data breach incidents, privacy and protection issues with big data like lack of anonymity and profiling risks. For mobile applications, it outlines decomposition risks, bad permission definitions, and risks with unencrypted data both in transit and at rest. The presentation recommends focusing on security controls like access controls and monitoring for big data, and addressing vulnerabilities from permissions, encryption, and component interactions for mobile applications.
The canvas element allows rendering of graphs and visual images directly in the browser. It provides an API for drawing primitives like rectangles, paths, text and images. The API is small but allows drawing complex shapes. However, coding paths can be painful and there is no way to store paths. Browser support for the canvas element is improving but still lacks in some older browsers.
This document provides an overview of a presentation about creating masterpieces using the JavaScript library Raphaël. The presentation will demonstrate how to make a 1970s board game interactive in the browser using Raphaël, including drawing hexagonal tiles, rivers, forests, villages, slopes and game pieces. It will explain how Raphaël was used to solve various drawing challenges and manage vector graphics, but will not show infrastructure details like jQuery, PHP and database usage. The goal is to illustrate Raphaël's capabilities for precise scalable vector graphics.
SaveI need help with this maze gui that I wrote in java, I am tryi.pdfarihantstoneart
Save
I need help with this maze gui that I wrote in java, I am trying to find the shortest path but I dont
know how to implement the FindshortestPath Method.
I was given this as a stragedy to solve the findshortestpathMethod():
Create two LinkedLists of MazeMap objects. One will be the list of map objects for cells at
distance x from the center. The other will be the list of map objects for cells at distance x + 1.
Initialize the list at distance x to contain a MazeMap object which refers to the center cell of the
maze. Since this map object refers to the center cell, it does not need to refer to any other
MazeMap object, so its MazeMap reference can be set to null. Set the center cell’s visited field
to true to indicate that this cell has already been added to the map.
Set up a loop to run until the maze entrance is mapped. This loop does the following:
Set up a loop to process each map object from the list at distance x. This loop does the following:
i.Get the cell from the map object
ii.If this cell is the entrance cell, set the entrance and break out of the loop!
iii.Check each direction from this cell and for an accessible neighbor cell
Get a reference to that neighbor cell
If the neighbor cell has not already been visited
Set the cell’s visited field to true so its only processed once
Create a MazeMap object that refers to this neighbor cell
Make this MazeMap object refer to the current map object being processed – ie the cell one step
closer to center
Add this MazeMap object to the list at distance x + 1
List at distance x has been processed. The list at distance x + 1 is now complete, so make the list
at distance x refer to list at distance x + 1. Then create a new empty list for the list at distance x +
1.
At this point, the entrance points at the map object which refers to cell 1,1. That map object also
refers to a map object which is one step closer to the center. Write a loop that traverses this trail
of references until it reaches the end (a null reference). For each map object:
Get the cell referred to.
Call the drawCircle method with a color, the cell’s row and column, and SMALL.
Call the delay method with a SHORT delay. This slows down the drawing process so you can
watch the path being displayed.
Advance to the next map object in the list.
here is the code so far*********
here is my code: ******mazeApp*******
package mazepackage;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.TextInputDialog;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class MazeApp extends Application
{
// default canvas size is DEFAULT_SIZE-by-DEFAULT_SIZE
private static final int DEFAULT_SIZE = 768;
private int width = DEFAULT_SIZE;
private int height = DEFAULT_SIZE;
// The graphics context is needed to enable drawing on the canvas
private Graphics.
The document discusses using mouse and keyboard events in Java programs. It provides examples of using MouseListener and MouseEvent to detect mouse clicks on objects. It also demonstrates using MouseMotionListener to handle mouse drag and move events. Keyboard events are handled using KeyListener. The examples show drawing shapes by clicking buttons or keys, and changing shape properties by clicking or dragging the mouse.
The document provides source code for generating and manipulating computer graphics using various algorithms. It includes algorithms for drawing lines, circles and curves, as well as algorithms for translating, rotating, and scaling two-dimensional and three-dimensional objects. The source code is written in C/C++ and uses graphics libraries to output the results. Various input parameters are taken from the user and output is displayed to demonstrate the algorithms.
The document provides an overview of using the HTML5 canvas element to draw graphics and animations. It covers topics like rendering contexts, paths, styles, gradients, text, shapes, mouse/touch interaction, animation, and libraries. Code examples demonstrate how to draw basic shapes, handle user input, interpolate lines, add gradients, render to canvas, and more. The document is a tutorial for learning the capabilities of the canvas element.
need help with code I wrote. This code is a maze gui, and i need hel.pdfarcotstarsports
need help with code I wrote. This code is a maze gui, and i need help with the method
shorterstpath(); here is my code:
******mazeApp*******
package mazepackage;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.TextInputDialog;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class MazeApp extends Application
{
// default canvas size is DEFAULT_SIZE-by-DEFAULT_SIZE
private static final int DEFAULT_SIZE = 768;
private int width = DEFAULT_SIZE;
private int height = DEFAULT_SIZE;
// The graphics context is needed to enable drawing on the canvas
private GraphicsContext gc;
// boundary of drawing canvas, 0% border
// private static final double BORDER = 0.05;
private static final double BORDER = 0.00;
private double xmin, ymin, xmax, ymax;
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage)
{
Group root = new Group();
Canvas canvas = new Canvas(width, height);
gc = canvas.getGraphicsContext2D();
gc.setLineWidth(2);
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, width, height);
root.getChildren().add(canvas);
TextInputDialog tid = new TextInputDialog();
tid.setTitle(\"Maze Size\");
tid.setHeaderText(\"Enter maze size between 10 and 50\");
tid.showAndWait();
int size = Integer.parseInt(tid.getResult());
if (size > 50)
size = 50;
if (size < 10)
size = 10;
primaryStage.setTitle(\"Maze Application\");
primaryStage.setScene(new Scene(root));
primaryStage.setResizable(false);
// Make sure that the application goes away when then window is closed
primaryStage.setOnCloseRequest(e -> System.exit(0));
primaryStage.show();
Maze maze = new Maze(this, size);
// Must solve the maze in a separate thread or else
// the GUI wont update until the end.....
Thread solver = new Thread(
new Runnable () {
public void run()
{
while(true)
{
maze.buildAndDrawMaze();
maze.findShortestPath();
try
{
Thread.sleep(5000);
}
catch(Exception e) { }
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, width, height);
}
}
});
solver.start();
}
/**
* Sets the pen color to the specified color.
*
* @param color the color to make the pen
*/
public void setPenColor(Color color) {
gc.setStroke(color);
}
/**
* Sets the pen color to the specified color.
*
* @param color the color to make the pen
*/
public void setFillColor(Color color) {
gc.setFill(color);
}
/**
* Sets the x-scale to the specified range.
*
* @param min the minimum value of the x-scale
* @param max the maximum value of the x-scale
* @throws IllegalArgumentException if {@code (max == min)}
*/
public void setXscale(double min, double max) {
double size = max - min;
if (size == 0.0) {
throw new IllegalArgumentException(\"the min and max are the same\");
}
xmin = min - BORDER * size;
xmax = max + BORDER * size;
}
/**
* Sets the y-scale to the specified range.
*
* @param min the minimum valu.
This program writes a C code to shear a cuboid. It includes graphics header files and uses the Bresenham's line algorithm to draw lines. The program defines a function called 'bress' to draw lines using the Bresenham algorithm. It takes coordinates of two points as input and uses conditions on the slope to determine the increment, endpoint and direction of line drawing. This function is used to draw the individual lines of the cuboid before and after shearing.
This document provides instructions for drawing graphs in Pascal using the Graph unit. It discusses initializing graphics mode, calculating appropriate coordinates for the screen, and algorithms for drawing normal and polar functions. Examples are given to illustrate drawing the linear function f(x)=x and polar function f(u)=1+sin(u). The document concludes with reminding students what they need to do in exams and providing contact information for the programming group.
- HTML5 Canvas allows for dynamic drawing and animating directly in HTML using JavaScript scripting. It can be used to draw shapes, images, text and respond to user input like mouse clicks.
- The canvas element creates a grid that allows positioning images and objects by x and y coordinates. Basic drawing functions include lines, rectangles, curves and filling areas with colors.
- Transformations like translation and rotation can change the orientation of drawings on the canvas. The drawing state can be saved and restored to return to previous settings.
- Images can be drawn and manipulated at the pixel level by accessing image data. Animation is achieved by redrawing the canvas repeatedly with small changes.
- Data from sources like JSON can be
The document contains 10 programs written in C programming language to perform various 2D and 3D graphics operations like drawing lines, rectangles, circles, ellipses, torus, scaling, rotating, shearing and reflecting objects. Program 1-5 demonstrate drawing basic shapes like line, rectangle, circle and ellipse. Program 6 draws a 3D torus using OpenGL. Program 7-9 demonstrate transformations like scaling, rotating and shearing of objects. Program 10 shows reflection of an object about x-axis, y-axis and origin.
The document provides instructions and examples for making games using HTML5 canvas and JavaScript. It discusses using canvas to draw basic shapes and images. It introduces the concept of sprites as reusable drawing components and provides an example sprite class. It demonstrates how to create a game loop to continuously update and render sprites to animate them. It also provides an example of making a sprite respond to keyboard input to allow user control. The document serves as a tutorial for building the core components of a simple HTML5 canvas game.
Reactive programming with RxJS - ByteConf 2018Tracy Lee
Reactive programming paradigms are all around us. So why does is it awesome? We'll explore reactive programming in standards, frameworks and libraries and talk about how to think reactively.
Then we'll take a more practical approach and talk about how to utilize reactive programming patterns with an abstraction like RxJS, a domain specific language for reacting to events and how using this abstraction can make your development life much easier in React Native.
1. The document discusses various processing functions for drawing shapes and images including rect(), ellipse(), translate(), rotate(), scale(), and image().
2. It provides examples of how to use these functions individually or together to manipulate shapes and images on a canvas.
3. Key functions covered include using translate() and rotate() to move and rotate shapes, scale() to resize shapes and images, and imageMode() to control how images are positioned on the canvas.
I need help with this maze gui that I wrote in java, I am trying to .pdfarihantgiftgallery
I need help with this maze gui that I wrote in java, I am trying to find the shortest path but I dont
know how to implement the FindshortestPath Method.
using a BREADTH FIRST SEARCH and the stradgey below to ONLY FIND THE SHORTEST
PATH, the method \"FindshortestPath(); is the only part you need to add code too.
I was given this as a stragedy to solve the findshortestpathMethod():
Create two LinkedLists of MazeMap objects. One will be the list of map objects for cells at
distance x from the center. The other will be the list of map objects for cells at distance x + 1.
Initialize the list at distance x to contain a MazeMap object which refers to the center cell of the
maze. Since this map object refers to the center cell, it does not need to refer to any other
MazeMap object, so its MazeMap reference can be set to null. Set the center cell’s visited field
to true to indicate that this cell has already been added to the map.
Set up a loop to run until the maze entrance is mapped. This loop does the following:
Set up a loop to process each map object from the list at distance x. This loop does the following:
i.Get the cell from the map object
ii.If this cell is the entrance cell, set the entrance and break out of the loop!
iii.Check each direction from this cell and for an accessible neighbor cell
Get a reference to that neighbor cell
If the neighbor cell has not already been visited
Set the cell’s visited field to true so its only processed once
Create a MazeMap object that refers to this neighbor cell
Make this MazeMap object refer to the current map object being processed – ie the cell one step
closer to center
Add this MazeMap object to the list at distance x + 1
List at distance x has been processed. The list at distance x + 1 is now complete, so make the list
at distance x refer to list at distance x + 1. Then create a new empty list for the list at distance x +
1.
At this point, the entrance points at the map object which refers to cell 1,1. That map object also
refers to a map object which is one step closer to the center. Write a loop that traverses this trail
of references until it reaches the end (a null reference). For each map object:
Get the cell referred to.
Call the drawCircle method with a color, the cell’s row and column, and SMALL.
Call the delay method with a SHORT delay. This slows down the drawing process so you can
watch the path being displayed.
Advance to the next map object in the list.
here is the code so far*********
package mazepackage;
import java.util.LinkedList;
import java.util.Random;
import javafx.scene.paint.Color;
public class Maze {
private int N; // dimension of maze
private MazeCell[][] maze;
private Random rand = new Random();
// Used to signal the maze has been solved
private boolean done;
// time in milliseconds (from currentTimeMillis()) when we can draw again
// used to control the frame rate
private long nextDraw = -1;
private MazeApp mf;
// Define constants for the circle size
private final double BI.
The document provides instructions for building a basic space shooter game using JavaScript and canvas. It demonstrates how to load assets like images, handle input events from keyboard keys to control player movement, create enemy objects that move across the screen, detect collisions between lasers and enemies, and add game states to track lives and score. The game loop redraws the game objects on an interval to animate their movement. Event handling is implemented through an event emitter to avoid messy code. The final sections provide a demo of the moving game elements and lasers firing, along with tips for continuing to learn game development.
Exploring fractals in CSS, @fronttrends, Warsaw, 2015pixelass
The document discusses fractal patterns that can be generated using mathematical equations and rendered using CSS. It provides examples of fractals like the Mandelbrot set, Barnsley fern, Sierpinski triangle, Menger sponge, and Pythagoras tree. Code snippets are included that demonstrate how to algorithmically generate the fractal patterns and style the output using CSS properties like box-shadow and transforms. The document also references concepts like self-similarity and how fractals display repeating patterns at different scales.
ASFWS 2012 - Obfuscator, ou comment durcir un code source ou un binaire contr...Cyber Security Alliance
This document discusses software obfuscation techniques. It provides an overview of the Obfuscator project, which aims to develop tools for LLVM-based source code obfuscation and binary obfuscation for ARM processors. Specific techniques discussed include code substitution, insertion of fake branches with opaque predicates, code flattening, addition of junk code, and use of opaque predicates and condition codes to add junk code to ARM binaries.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Your One-Stop Shop for Python Success: Top 10 US Python Development Providersakankshawande
Simplify your search for a reliable Python development partner! This list presents the top 10 trusted US providers offering comprehensive Python development services, ensuring your project's success from conception to completion.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Fueling AI with Great Data with Airbyte WebinarZilliz
This talk will focus on how to collect data from a variety of sources, leveraging this data for RAG and other GenAI use cases, and finally charting your course to productionalization.
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
2. Abstract.
CoW is a Web (mobile) Aplication that allows the colaborative editing of a
whiteboard using the canvas element provided by HTML5. The aplication allows users to
use different „pencils”, insert text, geometric figures, external images and draw upun the
whiteboard. The whiteboard can also be exported as a PNG image for the purpose of being
saved and later restored.
1. Introduction
CoW was created during the Client Side Web Application Development laboratory
held by Negru Stefan and having as course teacher Dr Sabin-Corneliu Buraga.
2. Tehnologies used
CoW was created using JavaScript, HTML5, and Socket.io tehnologies. The main
element of the CoW application is a canvas (HTML5 element) which allows the running of
drawing scripts. The functions that allow the user to interact with the app are part of the
jQuery lirbrary(for PC users) and the jQuery mobile library(for mobile users).
Comunicating between users is done by means of the Socket.IO module of the Node.JS
project, which, amongst other functionalities provides real time comunication amongst
multiple clients.
2.1 JavaScript+Canvas
2.1.1 Drawing functions
Each canvas has a drawing contex. In the CoW app, the context is a 2D one and is
called as follows:
var canvas = document.getElementById("sheet");
var context = canvas.getContext("2d");
Where sheet is the canvas’s ID within the index.html file.
For the mobile website the canvas is automaticly generated, resized and placed
within the contentholder div as follows:
function resizeCanvas(){
var w = window.innerWidth / 1.2;
var h = window.innerHeight / 1.2;
var canvasString = '<canvas id="mainCanvas" width="'
+ w + '" height="' + h + '">Canvas is not
supported</canvas>';
$('#contentholder').empty();
$(canvasString).appendTo('#contentholder');
context = $('#mainCanvas').get(0).getContext('2d');}
To draw within the canvas’s context we use the following functions:
To draw freely with the pencil:
3. var line = function(x1, y1, x2, y2, s) {
s.globalCompositeOperation = 'source-over';
setStyle(s);
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.closePath();
context.stroke();
}
Where x1 and y1 are the coordonates where the mouseDown (touchstart for
mobile)event took place and x2 and y2 are the coordinates where mouseMove (touchmove
for mobile) event took place.
To draw a line:
var line = function(x1, y1, x2, y2, s) {
s.globalCompositeOperation = 'source-over';
setStyle(s);
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.closePath();
context.stroke();
}
Where x1 and y1 are the coordonates where the mouseDown (touchstart for
mobile)event took place and x2 and y2 are the coordinates where the mouseUp (touchend
for mobile) event took place.
To draw a circle:
var circle = function(x1, y1, x2, y2, s) {
s.globalCompositeOperation = 'source-over';
minX = (x1<x2) ? x1 : x2;
minY = (y1<y2) ? y1 : y2;
radiusX = Math.abs(x1 - x2) / 2;
radiusY = Math.abs(y1 - y2) / 2;
context.beginPath();
setStyle(s);
context.arc(minX+radiusX, minY+radiusY, radiusX,
0, 2*Math.PI, false);
context.closePath();
context.stroke();
}
Where x1 and y1 are the coordonates where the mouseDown (touchstart for
mobile)event took place and x2 and y2 are the coordinates where the mouseUp (touchend
for mobile) event took place.
To draw a rectangle:
4. var rectangle = function(x1, y1, x2, y2, s) {
s.globalCompositeOperation = 'source-over';
minX = (x1<x2) ? x1 : x2;
minY = (y1<y2) ? y1 : y2;
xl = Math.abs(x1-x2);
yl = Math.abs(y1-y2);
setStyle(s);
context.beginPath();
context.rect(minX, minY, xl, yl);
context.closePath();
context.stroke();
}
Where x1 and y1 are the coordonates where the mouseDown (touchstart for
mobile)event took place and x2 and y2 are the coordinates where the mouseUp (touchend
for mobile) event took place.
Withing all four functions s represents the shape’s style (colour, thickness,
transparency, lineJoin and lineCap).
To erase:
var eraser = function(x1, y1, x2, y2, s) {
s.globalCompositeOperation = 'copy';
s.strokeStyle = 'rgba(0,0,0,0)';
setStyle(s);
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.closePath();
context.stroke();
}
Where x1 and y1 are the coordonates where the mouseDown (touchstart for
mobile)event took place and x2 and y2 are the coordinates where mouseMove (touchmove
for mobile) event took place.
For a new sheet we use the following function:
$('#newSheet').click(function(){
canvas.width = canvas.width;
});
2.1.2 Mouse/Touch event handlers
5. The following functions are used to handle mouse events (mouseDown, mouseUp,
mouseMove):
// event handler for Mouse Down
$('#sheet').mousedown(function(e) {
mouseDown = true; //used for checking if left click is down
mouseX = e.pageX - this.offsetLeft; //used to get the
position of the mouse inside the canvas
mouseY = e.pageY - this.offsetTop; //used to get the position
of the mouse inside the canvas
context.moveTo(mouseX, mouseY);
switch(tool){
case Pen: // draws in case the pen is selected
pencil(mouseX, mouseY, mouseX, mouseY, style);
message = { "x1":mouseX, "y1":mouseY, "x2":mouseX+1,
"y2":mouseY, "tool":Pen, "style":style };
socket.send(JSON.stringify(message));
break;
case Text: // text insertion
if($('#textVal').val() != '')
{ //checks for the bold, italic and underline options
font = '';
if($('#bold').is(':checked'))
font += 'bold ';
if($('#underline').is(':checked'))
font += 'underline ';
if($('#italic').is(':checked'))
font += 'italic ';
font += $('#penSize').slider('value')*5 + 'px sans-serif';
context.font = font;
context.fillStyle = style.strokeStyle;
context.fillText($('#textVal').val(), mouseX, mouseY);
message = { "x":mouseX, "y":mouseY, "tool":Text, "
font":font, "text":$('#textVal').val(), "style":style
};
socket.send(JSON.stringify(message)); }
break;
case IMAGE: // drawing an image onto the canvas at the
mouseX mouseY position
context.drawImage(image, mouseX, mouseY);
message = { "x":mouseX, "y":mouseY, "image":image.src,
"tool":IMAGE };
socket.send(JSON.stringify(message));
break;
break; }
6. });
// event handler for Mouse Up
$('#sheet').mouseup(function(e) {
mouseDown = false; // click is no longer pressed
newX = e.pageX - this.offsetLeft;// used to get the position
of the mouse inside the canvas
newY = e.pageY - this.offsetTop;// used to get the position
of the mouse inside the canvas
oldX = mouseX;
oldY = mouseY;
switch(tool) {
case Pen: // do nothing because the drawing has been done
insed the mousemove function
break;
case Circ: //draws the circle from the oldX and oldY
position to the newX newY position with the
diameter give by the distance between the 2
circle(oldX, oldY, newX, newY, style);
message = { "x1":oldX, "y1":oldY, "x2":newX, "y2":newY,
"tool":Circ, "style":style };
socket.send(JSON.stringify(message));
break;
case Rec:// draws the rectangle from the oldX and oldY
position to the newX newY position with the
diameter give by the distance between the 2
rectangle(oldX, oldY, newX, newY, style);
message = { "x1":oldX, "y1":oldY, "x2":newX, "y2":newY,
"tool":Rec, "style":style };
socket.send(JSON.stringify(message));
break;
case Line://draws the line from the oldX and oldY position
in the newX and newY position
line(oldX, oldY, newX, newY, style);
message = { "x1":oldX, "y1":oldY, "x2":newX, "y2":newY,
"tool":Line, "style":style };
socket.send(JSON.stringify(message));
break; }
});
// event handler for mouse move
$('#sheet').mousemove(function(e) {
newX = e.pageX - this.offsetLeft;
newY = e.pageY - this.offsetTop;
7. if(mouseDown) { //as long as the mouse is downdraws or erases
depending on the selected tool
oldX = mouseX;
oldY = mouseY;
switch(tool){
case Pen:
pencil(oldX, oldY, newX, newY, style);
message = { "x1":oldX, "y1":oldY, "x2":newX,
"y2":newY,"tool":Pen,"style":style };
socket.send(JSON.stringify(message));
mouseX = newX;
mouseY = newY;
break;
case Eraser:
eraser(oldX, oldY, newX, newY, style);
message = { "x1":oldX, "y1":oldY, "x2":newX, "y2":newY,
"tool":Eraser, "style":style };
socket.send(JSON.stringify(message));
mouseX = newX;
mouseY = newY;
break;
break; } }
});
// handles the mouse leaving the canvas
$('#sheet').mouseleave(function() {
mouseDown = false;
});
The handling of the touch events is done pretty much the same, with the exception
of the syntax upon binding the events to the canvas:
//the equivalent of mouseDown
$('#mainCanvas').bind('touchstart',(function(e) { }
//the equivalent of mouseUp
$('#mainCanvas').bind('touchend',(function(e) { }
//the equivalent of mousemove
$('#mainCanvas').bind('touchmove',(function(e) { }
These events appear upon mouse/touch actions on the browser surface.
8. 2.1.3 Choosing the color
Choosing the color is done by means of
the 3 sliders you can see on your right which
indicate the percentage of red green and blue the
color will have. The sample of the output color is
located in the #selected color div.
// color and size
//adjsusts the brush depending
on the information provided by
the sliders (amount of Red,
Green and Blue)
$('#red').slider({
value: 95,
min: 0,
max: 255,
slide: function(event, ui) {
changeColor();}
}).width(160);
$('#green').slider({
value: 221,
min: 0,
max: 255,
slide: function(event, ui) {
changeColor();}
}).width(160);
$('#blue').slider({
value: 122,
min: 0,
max: 255,
slide: function(event, ui) {changeColor();}
}).width(160);
$('#opac').slider({
value: 100,
min: 0,
max: 100,
slide: function(event, ui) {changeColor();}
9. }).width(160);
//Changes the brush colour update'ing the style and the
colour of the Selected colour div's background
var changeColor = function(){
c='rgba('+$('#red').slider('value')+','+$('#green').slider('v
alue')+','+$('#blue').slider('value')+','+$('#opac').slider('
value') / 100) + ')';
$('#selectedColor').css({backgroundColor: c});
style.strokeStyle = 'rgb(' + $('#red').slider('value') + ','
+$('#green').slider('value')+','+$('#blue').slider('val
ue') + ')';
style.globalAlpha = ($('#opac').slider('value') / 100);
}
2.2 Communicating between users
Data transmition is done using Socket.IO which automaticly selects the data
transmition protocol for each browser that calls it. Installing NodeJS and Socket.IO is
detailed in the youtube link of the biblografy.
Server side:
var io = require('socket.io').listen(31520);
io.sockets.on('connection', function(client){
client.on('message',function(event){
client.broadcast.send(event);
});
client.on('disconnect',function(){
});
});
Client side:
//connects to the server
var socket = io.connect('http://localhost:31520');
//sends the tool data to the other clients
socket.on('message', function(Data) {
Data = $.parseJSON(Data);
switch(Data.tool){
case Pen:
pencil(Data.x1, Data.y1, Data.x2, Data.y2, Data.style);
break;
case Circ:
circle(Data.x1, Data.y1, Data.x2, Data.y2, Data.style);
break;
case Rec:
rectangle(Data.x1, Data.y1, Data.x2, Data.y2,
10. Data.style);
break;
case Line:
line(Data.x1, Data.y1, Data.x2, Data.y2, Data.style);
break;
case Text:
context.font = Data.font;
context.fillStyle = Data.style.strokeStyle;
context.fillText(Data.text, Data.x, Data.y);
break;
case New:
canvas.width = canvas.width;
break;
case IMAGE:
image = new Image();
image.src = Data.image;
context.drawImage(image, Data.x, Data.y);
break;
case Eraser:
eraser(Data.x1, Data.y1, Data.x2, Data.y2, Data.style);
break;
break;}
});
2.3 Usage
2.3.1 For the desktop app
11. The tools are displayed in the upper left corner. The drawing possibilities are:
pencil, line, rectangle, circle and eraser, which are to be used upon the canvas(the
whiteboard). Bellow those we have the option to export, which opens the content of the
canvas as a new PNG image in a new tab, and the browse button which opens a file browser
that can select an image to be inserted onto the canvas upon click(these 2 can be combined
and used as a sort of save/load function.
On the right side the brush options are displayed. They can be used to adjust the
size, color and opacity of the brush. Above them we have the New Sheet button which
clears the canvas.
Bellow the brush options we have the text insertion options. The text goes in the
textbox and will be inserted upon click after first selecting Insert Text.
2.3.2 For the mobile app
12. From the upper side of the screen we may select the tool we wish to use and it
shall be used by touching the screen.
Bibliografie:
http://socket.io
http://profs.info.uaic.ro/~busaco/teach/courses/cliw/web.html
http://www.w3schools.com/
http://docs.jquery.com/Main_Page
http://jquerymobile.com/demos/1.0/
http://www.youtube.com/watch?v=3nnpCXtPXHg