1金币
本帖最后由 jackming 于 2020-2-13 15:42 编辑
- // 重写Base类型
- var CustomBase = spreadNS.CellTypes.Base;
- var oldPaint = spreadNS.CellTypes.Base.prototype.paint;
- CustomBase.prototype.paint = function (context, value, x1, y1, a1, b1, style, ctx) {
- if (!context) {
- return;
- }
- if(this.showEffect){
- context.save();
- let base = a1 > b1 ? b1 / 2 : a1 / 2;
- context.beginPath();
- context.moveTo(x1 + a1, y1);
- context.lineTo(x1 + a1, y1 + base);
- context.lineTo(x1 + a1 - base, y1);
- context.fillStyle ='red';
- // context.backgroundImage = 'http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg'
- context.fill();
- context.closePath();
- context.restore();
- }
- oldPaint.apply(this, [context, value, x1, y1, a1, b1, style, ctx]);
- };
复制代码 能不能帮忙画一个旗子(三角形+一竖,最简单那种),水平垂直居中万分感谢
参考的这个 https://gcdn.grapecity.com.cn/showtopic-51177-1-116.html,
|
最佳答案
查看完整内容
https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.CellTypes.Base~paint.htmlpaint方法的API文档 有解释每个参数含义,另外这个绘制是用canvas来绘制的图形,您可以搜索canvas 的绘图方法,可以绘制您要的形状,
禁用单元格可以用表单保护来实现:
https://demo.grapecity.com.cn/spreadjs/SpreadJSTutorial/features/worksheet/protection/purejs
设置sheet.options.isProtected = true; 再锁 ...
|