Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
daengdaengLee committed Jun 18, 2020
2 parents 1a0d52b + 0c66964 commit 3476bd2
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 188 deletions.
4 changes: 2 additions & 2 deletions README_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ controller.append({ tx: 10 }).append({ ty: 10 }).end();
## Documentation

- [API Reference](./doc/API.md)
- [Test](./doc/TEST.md)
- [Test](./doc/TEST_KR.md)

## Contributing

FxSVG 개발에 참여하고 싶은 모든 분들을 환영합니다.
FxSVG 코드에 기여하고 싶은 분은 아래 가이드를 참고해주세요.

- [Contributing Guide](./doc/CONTRIBUTING.md)
- [Contributing Guide](./doc/CONTRIBUTING_KR.md)
6 changes: 3 additions & 3 deletions doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

## Test Code

테스트 코드를 작성할 때 `mocha` 테스트 러너의 실행 함수는 모두 `function() {}` 으로 작성해주세요.
`mocha``context`에 접근하기 위해서는 `this` 키워드를 사용해야 합니다.
화살표 함수를 사용하면 `this` 키워드를 사용할 수 없어요!
Please use `function() {}` when write test runner function for `mocha`.
We have to use `this` to access `mocha`'s `context`.
If you use arrow function, you cannot use `this`.
7 changes: 7 additions & 0 deletions doc/CONTRIBUTING_KR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Contributing

## Test Code

테스트 코드를 작성할 때 `mocha` 테스트 러너의 실행 함수는 모두 `function() {}` 으로 작성해주세요.
`mocha``context`에 접근하기 위해서는 `this` 키워드를 사용해야 합니다.
화살표 함수를 사용하면 `this` 키워드를 사용할 수 없어요!
6 changes: 5 additions & 1 deletion doc/SVG_CURRYING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ console.log($$createSVGMatrix($svg)());
```

- `$$controlRotateTransform`
- `$$controlScaleTransform`
- `$$controlTranslateTransform`
- `$$createSVGMatrix`
- `$$createSVGPoint`
Expand All @@ -25,11 +26,14 @@ console.log($$createSVGMatrix($svg)());
- `$$createSVGTransformRotate`
- `$$createSVGTransformScale`
- `$$createSVGTransformTranslate`
- `$$els`
- `$$el`
- `$$els`
- `$$getBoxPoints`
- `$$getCenterPoint`
- `$$initMatrixTransform`
- `$$initRotateTransform`
- `$$initScaleTransform`
- `$$initTranslateTransform`
- `$$mergeRotateTransform`
- `$$mergeScaleTransform`
- `$$mergeTranslateTransform`
11 changes: 7 additions & 4 deletions doc/TEST.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Test

FxSVG 의 모든 함수는 유닛 테스트를 작성하고 있습니다.
We write unit tests for all functions in FxSVG.

각 함수의 유닛 테스트는 함수 본체 파일(`name.index.js`) 과 같은 디렉토리에 `name.spec.js` 라는 이름의 파일에 작성합니다.
Unit test file name is `name.spec.js`.
The test file is in the same directory where the function file(`name.index.js`) is.

유닛 테스트를 실행하고 싶은 경우 `npm run test:browser` 명령어를 실행하고
웹브라우저를 통해 `http://localhost:8080/test` 로 접속하면 됩니다.
When you run tests,

1. run `npm run test:server`
2. go to `http://localhost:8080/test`
10 changes: 10 additions & 0 deletions doc/TEST_KR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Test

FxSVG 의 모든 함수는 유닛 테스트를 작성하고 있습니다.

각 함수의 유닛 테스트는 함수 본체 파일(`name.index.js`) 과 같은 디렉토리에 `name.spec.js` 라는 이름의 파일에 작성합니다.

유닛 테스트를 실행하고 싶은 경우

1. `npm run test:server` 명령어를 실행하고
2. `http://localhost:8080/test` 로 접속하면 됩니다.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fxsvg",
"version": "0.2.7",
"version": "0.3.0",
"description": "Functional SVG Handling Library",
"type": "module",
"main": "./src/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/controlScaleTransform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[`<svg></svg>` 커링](../../doc/SVG_CURRYING.md)이 적용된 함수입니다.
52 changes: 26 additions & 26 deletions src/createSVGMatrix/createSVGMatrix.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,13 @@ import {
pipe,
reduce,
} from "fxjs2";
import { expectSameValueSVGMatrix } from "../../test/assertions/index.js";
import {
makeAllCombinations,
makeRandomNumber,
} from "../../test/utils/index.js";
import { $$createSVGMatrix } from "./createSVGMatrix.index.js";

const expectSameMatrix = (
m,
{ a = 1, b = 0, c = 0, d = 1, e = 0, f = 0 } = {}
) => {
expect(m.a).to.equal(a);
expect(m.b).to.equal(b);
expect(m.c).to.equal(c);
expect(m.d).to.equal(d);
expect(m.e).to.equal(e);
expect(m.f).to.equal(f);
};

const makeCases = () =>
flatMapL(
(f) =>
Expand Down Expand Up @@ -65,23 +54,34 @@ export default ({ describe, it }) => [
});

it(`The matrix will be a identity matrix if there is no arguments.`, function () {
const m1 = $$createSVGMatrix()();
expectSameMatrix(m1, { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 });

const m2 = $$createSVGMatrix(
document.createElementNS("http://www.w3.org/2000/svg", "svg")
)();
expectSameMatrix(m2, { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 });
go(
[
$$createSVGMatrix(),
$$createSVGMatrix(
document.createElementNS("http://www.w3.org/2000/svg", "svg")
),
],
mapL((f) => f()),
each((m) =>
expectSameValueSVGMatrix(m, { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 })
)
);
});

it(`
Each value of the matrix will be same with the given value.
If there is omitted values, the values will be {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0} individually by default.
`, function () {
it(`Each value of the matrix will be same with the given value.
If there is omitted values, the values will be {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0} individually by default.`, function () {
this.slow(100);
each(
({ matrix, values }) => expectSameMatrix(matrix, values),
makeCases()
go(
makeCases(),
mapL(({ matrix, values }) =>
go(
values,
defaultTo({}),
(values) => extend({ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, values),
(values) => ({ matrix, values })
)
),
each(({ matrix, values }) => expectSameValueSVGMatrix(matrix, values))
);
});
}),
Expand Down
2 changes: 2 additions & 0 deletions src/createSVGTransform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
`SVGTransform.SVG_TRANSFORM_MATRIX` 타입을 가집니다.
`transform.matrix` 값으로 `SVGMatrix {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}` 을 가집니다.

[`<svg></svg>` 커링](../../doc/SVG_CURRYING.md)이 적용된 함수입니다.

```javascript
console.log($$createSVGTransform());
// SVGTransform {type: 1, matrix: SVGMatrix, angle: 0}
Expand Down
2 changes: 1 addition & 1 deletion src/isMatrixSVGTransform/isMatrixSVGTransform.index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const $$isMatrixSVGTransform = (transform) => {
if (!(transform instanceof SVGTransform)) {
throw new Error("It's not a SVGTransform.");
return false;
}

const { type, SVG_TRANSFORM_MATRIX } = transform;
Expand Down
71 changes: 36 additions & 35 deletions src/isMatrixSVGTransform/isMatrixSVGTransform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,71 @@ import { $$isMatrixSVGTransform } from "./isMatrixSVGTransform.index.js";

export default ({ describe, it }) => [
describe(`$$isMatrixSVGTransform`, function () {
describe(`The function will throw an error when the input value is not a SVGTransform.`, function () {
it(`Input null.`, function () {
expect(() => $$isMatrixSVGTransform(null)).to.throw();
describe(`The function will return false...`, function () {
it(`When the input value is null.`, function () {
const result = $$isMatrixSVGTransform(null);

expect(result).to.be.false;
});

it(`Input plain empty object.`, function () {
expect(() => $$isMatrixSVGTransform({})).to.throw();
it(`When the input value is a plain empty object.`, function () {
const result = $$isMatrixSVGTransform({});

expect(result).to.be.false;
});

it(`Input plain object with type and SVG_TRANSFORM_ROTATE properties.`, function () {
it(`When the input value is a plain object like
{ type: SVGTransform.SVG_TRANSFORM_MATRIX, SVG_TRANSFORM_MATRIX: SVGTransform.SVG_TRANSFORM_MATRIX }.`, function () {
const obj = {
type: SVGTransform.SVG_TRANSFORM_MATRIX,
SVG_TRANSFORM_MATRIX: SVGTransform.SVG_TRANSFORM_MATRIX,
};
expect(() => $$isMatrixSVGTransform(obj)).to.throw();
});
});
const result = $$isMatrixSVGTransform(obj);

it(`
The function returns true
if the SVGTransform's type is same with a SVGTransform.SVG_TRANSFORM_MATRIX.
`, function () {
const matrix_t = $$createSVGTransformMatrix()({
matrix: makeRandomSVGMatrix(),
expect(result).to.be.false;
});
const result = $$isMatrixSVGTransform(matrix_t);

expect(result).to.be.true;
});

describe(`
The function returns false
if the SVGTransform's type is not same with a SVGTransform.SVG_TRANSFORM_MATRIX.
`, function () {
it(`Use a SVGTransform whose type is a SVGTransform.SVG_TRANSFORM_ROTATE.`, function () {
const matrix_t = $$createSVGTransformRotate()({
angle: makeRandomNumber(),
cx: makeRandomNumber(),
cy: makeRandomNumber(),
it(`When the input value is a SVGTransform whose type is the SVGTransform.SVG_TRANSFORM_ROTATE.`, function () {
const rotate_t = $$createSVGTransformRotate()({
angle: makeRandomNumber(-700, 700),
cx: makeRandomNumber(-100, 100),
cy: makeRandomNumber(-100, 100),
});
const result = $$isMatrixSVGTransform(matrix_t);
const result = $$isMatrixSVGTransform(rotate_t);

expect(result).to.be.false;
});

it(`Use a SVGTransform whose type is a SVGTransform.SVG_TRANSFORM_TRANSLATE.`, function () {
it(`When the input value is a SVGTransform whose type is the SVGTransform.SVG_TRANSFORM_TRANSLATE.`, function () {
const translate_t = $$createSVGTransformTranslate()({
tx: makeRandomNumber(),
ty: makeRandomNumber(),
tx: makeRandomNumber(-100, 100),
ty: makeRandomNumber(-100, 100),
});
const result = $$isMatrixSVGTransform(translate_t);

expect(result).to.be.false;
});

it(`Use a SVGTransform whose type is a SVGTransform.SVG_TRANSFORM_SCALE.`, function () {
it(`When the input value is a SVGTransform whose type is the SVGTransform.SVG_TRANSFORM_SCALE.`, function () {
const scale_t = $$createSVGTransformScale()({
sx: makeRandomNumber(),
sy: makeRandomNumber(),
sx: makeRandomNumber(-100, 100),
sy: makeRandomNumber(-100, 100),
});
const result = $$isMatrixSVGTransform(scale_t);

expect(result).to.be.false;
});
});

describe(`The function will return true...`, function () {
it(`When the input value is a SVGTransform and the type is SVGTransform.SVG_TRANSFORM_MATRIX.`, function () {
const matrix_t = $$createSVGTransformMatrix()({
matrix: makeRandomSVGMatrix(() => makeRandomNumber(-100, 100)),
});
const result = $$isMatrixSVGTransform(matrix_t);

expect(result).to.be.true;
});
});
}),
];
2 changes: 1 addition & 1 deletion src/isRotateSVGTransform/isRotateSVGTransform.index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const $$isRotateSVGTransform = (transform) => {
if (!(transform instanceof SVGTransform)) {
throw new Error("It's not a SVGTransform.");
return false;
}

const { type, SVG_TRANSFORM_ROTATE } = transform;
Expand Down
Loading

0 comments on commit 3476bd2

Please sign in to comment.