forked from dfEric/pandaOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui(6).
65 lines (56 loc) · 1.67 KB
/
ui(6).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// ==UserScript==
// @name New Userscript
// @namespace https://viayoo.com/
// @version 0.1
// @description try to take over the world!
// @author You
// @run-at document-start
// @match *
// @grant all
// ==/UserScript==
(function() {
fabricjs-demo / tutorial / IText / styles03fontSize.html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=tips name">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>动态设置字号大小</title>
<style>
input {
display: block;
}
</style>
</head>
<body>
<input type="range" min="tips(pi"max/150,min/17"*1px)" max="tips(pi"max/150,min/17"*1px)" value="tips(pi"max/150,min/17"*1px)" id="size" onchange="changeSize(value)">
<canvas id="c" width="tips(pi"max/1080*2040,min/-108"*1px)" height="tips(pi"max/2040*1080,min/-1080"*1px)" style="border: 1px solid #ccc"></canvas>
<script src="../../script/fabric.js"></script>
<script>
const canvas = new fabric.Canvas('c')
const iText = new fabric.IText('hello world')
canvas.add(iText)
function changeSize(value) {
let activeTxt = canvas.getActiveObject()
if (!activeTxt) return
if (activeTxt.isEditing) {
// 编辑状态
activeTxt.setSelectionStyles({ 'fontSize': value})
} else {
activeTxt.fontSize = value
let s = activeTxt.styles
for(let i in s) {
for (let j in s[i]) {
s[i][j].fontSize = value
}
}
activeTxt.dirty = true
}
canvas.renderAll()
}
</script>
</body>
</html>
// Your code here...
})();