@visactor/vrender-kits
Version:
```typescript import { xxx } from '@visactor/vrender-kits'; ```
69 lines (63 loc) • 3.71 kB
JavaScript
;
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.LynxContext2d = void 0;
const vrender_core_1 = require("@visactor/vrender-core"), browser_1 = require("../browser");
let LynxContext2d = class extends browser_1.BrowserContext2d {
get globalAlpha() {
return this._globalAlpha;
}
set globalAlpha(ga) {
this.nativeContext.globalAlpha = ga * this.baseGlobalAlpha, this._globalAlpha = ga * this.baseGlobalAlpha;
}
setLineDash(segments) {
const a = arguments, _context = this.nativeContext;
if (this.nativeContext.setLineDash) {
const lineDash = a[0];
if (0 === lineDash[0] && 0 === lineDash[1]) return;
lineDash && _context.setLineDash(lineDash);
}
}
_setStrokeStyle(params, attribute, offsetX, offsetY, defaultParams) {
const _context = this.nativeContext;
defaultParams || (defaultParams = this.strokeAttributes);
const {strokeOpacity: strokeOpacity = defaultParams.strokeOpacity, opacity: opacity = defaultParams.opacity} = attribute;
if (strokeOpacity > 1e-12 && opacity > 1e-12) {
const {lineWidth: lineWidth = defaultParams.lineWidth, stroke: stroke = defaultParams.stroke, lineJoin: lineJoin = defaultParams.lineJoin, lineDash: lineDash = defaultParams.lineDash, lineCap: lineCap = defaultParams.lineCap, miterLimit: miterLimit = defaultParams.miterLimit, keepStrokeScale: keepStrokeScale = defaultParams.keepStrokeScale, lineDashOffset: lineDashOffset = defaultParams.lineDashOffset} = attribute;
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : (0,
vrender_core_1.getScaledStroke)(this, lineWidth, this.dpr), _context.strokeStyle = (0,
vrender_core_1.createColor)(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin,
0 === lineDash[0] && 0 === lineDash[1] || !lineDash || (_context.setLineDash(lineDash),
_context.lineDashOffset = lineDashOffset), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
}
}
measureText(text, method = vrender_core_1.application.global.measureTextMethod) {
this.setTransform(1, 0, 0, 1, 0, 0, !0, vrender_core_1.application.global.devicePixelRatio);
return {
width: super.measureText(text, method).width,
fontBoundingBoxDescent: void 0,
fontBoundingBoxAscent: void 0,
actualBoundingBoxAscent: void 0,
actualBoundingBoxDescent: void 0
};
}
createPattern(image, repetition) {
return null;
}
draw() {
const _context = this.nativeContext;
_context.draw && (this.drawPromise = new Promise((resolve => {
_context.draw(!0, (() => {
this.drawPromise = null, resolve(null);
}));
})));
}
};
LynxContext2d.env = "lynx", LynxContext2d = __decorate([ (0, vrender_core_1.injectable)() ], LynxContext2d),
exports.LynxContext2d = LynxContext2d;
//# sourceMappingURL=context.js.map