-
Notifications
You must be signed in to change notification settings - Fork 18
/
create-circle-uploaded.ts
39 lines (37 loc) · 1.24 KB
/
create-circle-uploaded.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { EShape } from "../e-shape";
import { EShapeBuffer } from "../e-shape-buffer";
import { EShapeUploaded, EShapeUploadedImpl } from "../e-shape-uploaded";
import { CIRCLE_INDEX_COUNT, CIRCLE_VERTEX_COUNT } from "./build-circle";
import { TEXT_INDEX_COUNT_SHIFT, TEXT_VERTEX_COUNT_SHIFT, toTextBufferCount } from "./build-text";
import { BuilderCircle } from "./builder-circle";
import { BuilderText } from "./builder-text";
export const createCircleUploaded = (
buffer: EShapeBuffer,
shape: EShape,
voffset: number,
ioffset: number,
antialiasWeight: number
): EShapeUploaded | null => {
const tcount = toTextBufferCount(shape);
const tvcount = tcount << TEXT_VERTEX_COUNT_SHIFT;
const ticount = tcount << TEXT_INDEX_COUNT_SHIFT;
const vcount = CIRCLE_VERTEX_COUNT + tvcount;
const icount = CIRCLE_INDEX_COUNT + ticount;
if (buffer.check(voffset, ioffset, vcount, icount)) {
return new EShapeUploadedImpl(buffer, voffset, ioffset, vcount, icount, [
new BuilderCircle(buffer, voffset, ioffset),
new BuilderText(
buffer,
voffset + CIRCLE_VERTEX_COUNT,
ioffset + CIRCLE_INDEX_COUNT,
tvcount,
ticount
)
]).init(shape);
}
return null;
};