UNPKG

@visactor/vrender-kits

Version:

```typescript import { xxx } from '@visactor/vrender-kits'; ```

65 lines (59 loc) 3.52 kB
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; }; import { injectable, createColor, getScaledStroke, application } from "@visactor/vrender-core"; import { BrowserContext2d } from "../browser"; let LynxContext2d = class extends 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 : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = 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 = application.global.measureTextMethod) { this.setTransform(1, 0, 0, 1, 0, 0, !0, 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([ injectable() ], LynxContext2d); export { LynxContext2d }; //# sourceMappingURL=context.js.map