mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt some
This commit is contained in:
parent
3280bf81d5
commit
e1b3ec589f
@ -301,4 +301,11 @@ Volcanos("page", {
|
|||||||
requireDraw: function(can, cb) { can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
requireDraw: function(can, cb) { can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||||
can.onimport._last_init(can, can.request(), can._output), can.onappend.style(can, wiki.DRAW, can._fields), cb()
|
can.onimport._last_init(can, can.request(), can._output), can.onappend.style(can, wiki.DRAW, can._fields), cb()
|
||||||
}) },
|
}) },
|
||||||
|
drawText: function(can, text, size, margin) { text = text.slice(0, 1), size = size||80, margin = margin||10
|
||||||
|
var colors = ["rgb(239,150,26)", 'rgb(255,58,201)', "rgb(111,75,255)", "rgb(36,174,34)", "rgb(80,80,80)"]
|
||||||
|
var canvas = can.page.Create(can, html.CANVAS, {width: size, height: size}), ctx = canvas.getContext("2d")
|
||||||
|
ctx.fillStyle = can.base.isIn(can.getHeaderTheme(), html.DARK, chat.BLACK)? cli.BLACK: cli.WHITE, ctx.fillRect(0, 0, size, size), ctx.fillStyle = colors[Math.floor(Math.random()*(colors.length))], ctx.fillRect(margin, margin, size-2*margin, size-2*margin)
|
||||||
|
ctx.fillStyle = cli.WHITE, ctx.font = (size/text.length-30)+"px Arial", ctx.textAlign = "center", ctx.textBaseline = "middle", ctx.fillText(text, size/2, size/2)
|
||||||
|
return canvas.toDataURL(nfs.IMAGE_JPEG, 1)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
2
proto.js
2
proto.js
@ -128,6 +128,8 @@ var nfs = {
|
|||||||
_CSS: ".css", _JS: ".js",
|
_CSS: ".css", _JS: ".js",
|
||||||
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
||||||
PWD: "./", SRC: "src/",
|
PWD: "./", SRC: "src/",
|
||||||
|
|
||||||
|
IMAGE_JPEG: "image/jpeg",
|
||||||
}
|
}
|
||||||
var cli = {
|
var cli = {
|
||||||
PWD: "pwd", SYSTEM: "system", DAEMON: "daemon", ORDER: "order", BUILD: "build",
|
PWD: "pwd", SYSTEM: "system", DAEMON: "daemon", ORDER: "order", BUILD: "build",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user