front_idill/src/search/js/curve.js
author bastiena
Wed, 30 May 2012 10:21:36 +0200
changeset 35 4267d6d27a7d
child 44 8393d3473b98
permissions -rw-r--r--
Front IDILL : Config file added dor the Front Random play at the beginning (when no user is detected) Pointers added Curves added (search and filter modes) Mosaic completion added (depletion to come later) State of the Front : just before the communication module creation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     1
/*
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     3
*
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     5
*
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     7
* file that was distributed with this source code.
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     8
*/
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
     9
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    10
/*
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    11
 * Projet : TraKERS
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    12
 * Module : Front IDILL
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    13
 * Fichier : mosaic.js
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    14
 * 
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    16
 * 
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    17
 * Fonctionnalités : Définit la "classe" courbe et définit des fonctions d'intéractions (dessin...).
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    18
 */
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    19
 
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    20
function curve()
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    21
{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    22
	tool.fixedDistance = 10;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    23
	this.path;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    24
	this.pathStroke;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    25
	this.lastPoint;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    26
}
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    27
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    28
curve.prototype.onMouseDown = function(event)
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    29
{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    30
	this.pathStroke = new Path();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    31
	this.path = new Path();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    32
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    33
	this.pathStroke.fillColor = '#366F7A';
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    34
	this.path.fillColor = '#02FEFF';
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    35
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    36
	console.log('down');
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    37
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    38
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    39
curve.prototype.onMouseDrag = function(event)
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    40
{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    41
	//if(event.point.x < 0 || event.point.x > canvasWidth || event.point.y < 0 || event.point.y > canvasHeight)
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    42
		//return;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    43
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    44
	var step = event.delta / 5;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    45
	var stepStroke = event.delta / 3;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    46
	step.angle += 90;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    47
	stepStroke.angle += 90;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    48
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    49
	var top = event.point + step;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    50
	var bottom = event.point - step;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    51
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    52
	var topStroke = event.point + stepStroke;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    53
	var bottomStroke = event.point - stepStroke;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    54
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    55
	this.path.add(top);
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    56
	this.path.insert(0, bottom);
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    57
	this.path.smooth();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    58
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    59
	this.pathStroke.add(topStroke);
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    60
	this.pathStroke.insert(0, bottomStroke);
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    61
	this.pathStroke.smooth();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    62
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    63
	this.lastPoint = event.middlePoint;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    64
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    65
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    66
curve.prototype.onMouseUp = function(event)
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    67
{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    68
	this.pathStroke.remove();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    69
	this.path.remove();
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    70
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    71
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    72
curve.prototype.onKeyDown = function(event)
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    73
{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    74
	//S'il n'y a rien a colorier, on quitte.
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    75
	if(typeof this.pathStroke === 'undefined' || typeof this.path === 'undefined')
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    76
		return;
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    77
	
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    78
	if(event.key == 'r' || event.key == 'R')
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    79
	{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    80
		this.pathStroke.fillColor = '#49564F';
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    81
		this.path.fillColor = '#00FE00'
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    82
	}
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    83
	else if(event.key == 'x' || event.key == 'X')
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    84
	{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    85
		this.pathStroke.fillColor = '#535F6D';
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    86
		this.path.fillColor = '#CCCCCC'
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    87
	}
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    88
	else if(event.key == 'w' || event.key == 'W')
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    89
	{
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    90
		this.pathStroke.fillColor = '#366F7A';
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    91
		this.path.fillColor = '#02FEFF'
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    92
	}
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    93
};