Skip to content

Commit 3dd8b5b

Browse files
authored
Merge pull request #5 from YujiSODE/Y20180720
Y20180720
2 parents 9cfbe8a + 0944b7b commit 3dd8b5b

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,34 @@ ______
99
- `dataMappingGuide.js`
1010

1111
## 2. Synopsis
12+
`var obj=dataMappingGuide(canvas,src);`
13+
This function returns an object with some methods to control.
14+
15+
### Parameters
16+
- `canvas`: a canvas element
17+
- `src`: an optional filename or pathname of an image for background
18+
19+
### Main methods
20+
#### 1) Resizing and background
21+
- `resize(w,h,src)`; it sets canvas size and background image
22+
- `setDivisions(x,y)`; it sets horizontal and vertical divisions
23+
- `w` and `h`: new values for canvas width and canvas height
24+
- `src`: filename or pathname of an image; 'none' is default value
25+
- `x` and `y`: numbers for horizontal and vertical divisions
26+
27+
#### 2) Colors
28+
- `setColor(rgb,alpha)`; it sets rgb color and alpha value
29+
- `rgb`: rgb color value
30+
- `alpha`: an optional value between 0.0 (fully transparent) and 1.0 (fully opaque)
31+
32+
#### 3) Focus area
33+
- `xy(x,y)`; it puts focus on a area that is specified using integer coordinates
34+
- `x` and `y`: positive integer indices for horizontal and vertical divisions
35+
36+
#### Focus area indices
37+
An example of 3x3 divided focus area:
38+
_|1|2|3|
39+
1|x|x|x|
40+
2|x|x|x|
41+
3|x|x|x|
42+

dataMappingGuide.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
* - `canvas`: a canvas element
1717
* - `src`: an optional filename or pathname of an image for background
1818
*=== Methods ===
19-
*### 1) resizing and background ###
19+
*### 1) Resizing and background ###
2020
* - `resize(w,h,src)`; it sets canvas size and background image
2121
* - `setDivisions(x,y)`; it sets horizontal and vertical divisions
2222
* - `w` and `h`: new values for canvas width and canvas height
2323
* - `src`: filename or pathname of an image; 'none' is default value
2424
* - `x` and `y`: numbers for horizontal and vertical divisions
25-
*### 2) colors ###
25+
*### 2) Colors ###
2626
* - `setColor(rgb,alpha)`; it sets rgb color and alpha value
2727
* - `rgb`: rgb color value
2828
* - `alpha`: an optional value between 0.0 (fully transparent) and 1.0 (fully opaque)
29-
*### 3) focus area ###
29+
*### 3) Focus area ###
3030
* - `xy(x,y)`; it puts focus on a area that is specified using integer coordinates
3131
* - `x` and `y`: positive integer indices for horizontal and vertical divisions
32-
*### other methods ###
32+
*### Other methods ###
3333
* - `clear()`; it clears canvas
3434
* - `next()`; it returns coordinates for the next focus area as form of [x,y]
3535
* - `info()`; it returns the current state of sampling
@@ -65,7 +65,7 @@ function dataMappingGuide(canvas,src){
6565
cvs.img=!src?'none':src;
6666
canvas.style.backgroundRepeat='no-repeat';
6767
canvas.style.backgroundImage=!src?'none':'url('+src+')';
68-
//### 1) resizing and background ###
68+
//### 1) Resizing and background ###
6969
//it sets canvas size and background image
7070
cvs.resize=function(w,h,src){
7171
// - w and h: new values for canvas width and canvas height
@@ -94,7 +94,7 @@ function dataMappingGuide(canvas,src){
9494
cvs.dh=+canvas.height/cvs.Ny;
9595
return [cvs.Nx,cvs.Ny];
9696
};
97-
//### 2) colors ###
97+
//### 2) Colors ###
9898
//it sets rgb color and alpha value
9999
cvs.setColor=function(rgb,alpha){
100100
// - rgb: rgb color value
@@ -103,7 +103,7 @@ function dataMappingGuide(canvas,src){
103103
cvs.alpha=!alpha?cvs.alpha:alpha;
104104
return [cvs.color,cvs.alpha];
105105
};
106-
//### 3) focus area ###
106+
//### 3) Focus area ###
107107
//it puts focus on a area that is specified using integer coordinates
108108
cvs.xy=function(x,y){
109109
// - `x` and `y`: positive integer indices for horizontal and vertical divisions
@@ -138,7 +138,7 @@ function dataMappingGuide(canvas,src){
138138
ctx=null;
139139
return [cvs.X,cvs.Y];
140140
};
141-
//### other methods ###
141+
//### Other methods ###
142142
//it clears canvas
143143
cvs.clear=function(){
144144
var ctx=canvas.getContext('2d');

0 commit comments

Comments
 (0)