mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-27 06:25:13 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
var textHelper = require("../helper/text");
|
|
|
|
var BoundingRect = require("../../core/BoundingRect");
|
|
|
|
var _constant = require("../constant");
|
|
|
|
var WILL_BE_RESTORED = _constant.WILL_BE_RESTORED;
|
|
|
|
/**
|
|
* Mixin for drawing text in a element bounding rect
|
|
* @module zrender/mixin/RectText
|
|
*/
|
|
var tmpRect = new BoundingRect();
|
|
|
|
var RectText = function () {};
|
|
|
|
RectText.prototype = {
|
|
constructor: RectText,
|
|
|
|
/**
|
|
* Draw text in a rect with specified position.
|
|
* @param {CanvasRenderingContext2D} ctx
|
|
* @param {Object} rect Displayable rect
|
|
*/
|
|
drawRectText: function (ctx, rect) {
|
|
var style = this.style;
|
|
rect = style.textRect || rect; // Optimize, avoid normalize every time.
|
|
|
|
this.__dirty && textHelper.normalizeTextStyle(style, true);
|
|
var text = style.text; // Convert to string
|
|
|
|
text != null && (text += '');
|
|
|
|
if (!textHelper.needDrawText(text, style)) {
|
|
return;
|
|
} // FIXME
|
|
// Do not provide prevEl to `textHelper.renderText` for ctx prop cache,
|
|
// but use `ctx.save()` and `ctx.restore()`. Because the cache for rect
|
|
// text propably break the cache for its host elements.
|
|
|
|
|
|
ctx.save(); // Transform rect to view space
|
|
|
|
var transform = this.transform;
|
|
|
|
if (!style.transformText) {
|
|
if (transform) {
|
|
tmpRect.copy(rect);
|
|
tmpRect.applyTransform(transform);
|
|
rect = tmpRect;
|
|
}
|
|
} else {
|
|
this.setTransform(ctx);
|
|
} // transformText and textRotation can not be used at the same time.
|
|
|
|
|
|
textHelper.renderText(this, ctx, text, style, rect, WILL_BE_RESTORED);
|
|
ctx.restore();
|
|
}
|
|
};
|
|
var _default = RectText;
|
|
module.exports = _default; |