-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from karasjs/performance
Performance
- Loading branch information
Showing
46 changed files
with
4,641 additions
and
2,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=0"/> | ||
<title>text</title> | ||
<link href="style.css" media="all" rel="stylesheet"/> | ||
</head> | ||
<body> | ||
<div class="pre">支持自定义字体的文本,已内置解析字体信息。 | ||
可以用updateContent()来更新文字内容。</div> | ||
<div id="example"></div> | ||
<div id="example2"></div> | ||
<pre><code class="brush:csx"></code></pre> | ||
<script type="text/jsx"> | ||
karas.style.font.register('puhui', './Alibaba-PuHuiTi-Regular.ttf'); | ||
karas.render( | ||
<canvas width="360" height="360"> | ||
<div style={{ fontFamily: 'puhui', fontSize: 48 }}>普惠体 PuHui</div> | ||
</canvas>, | ||
'#example' | ||
); | ||
karas.render( | ||
<svg width="360" height="360"> | ||
<div style={{ fontFamily: 'puhui', fontSize: 48 }}>普惠体 PuHui</div> | ||
</svg>, | ||
'#example2' | ||
); | ||
// text.updateContent('newContent'); | ||
</script> | ||
<script src="sea.js"></script> | ||
<script src="homunculus.js"></script> | ||
<script src="yurine.js"></script> | ||
<script src="../index.js"></script> | ||
<script> | ||
seajs.config({ | ||
alias: { | ||
}, | ||
map: [function(url) { | ||
}] | ||
}); | ||
define('fs', {}); | ||
seajs.use(['jssc'], function(jssc) { | ||
var code = document.querySelector('pre code'); | ||
var jsx = document.querySelector('script[type="text/jsx"]'); | ||
var source = jsx.textContent || jsx.text; | ||
source = source.trim().replace(/\n[ ]{2}/g, '\n'); | ||
var text = document.createTextNode(source); | ||
code.appendChild(text); | ||
jssc.exec(); | ||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
var jsx = document.querySelectorAll('script'); | ||
for(var i = 0, len = jsx.length; i < len; i++) { | ||
var node = jsx[i]; | ||
if(node.getAttribute('type') === 'text/jsx' && !node.getAttribute('yurine')) { | ||
node.setAttribute('yurine', 1); | ||
var code = node.textContent || node.text; | ||
if(!code) { | ||
continue; | ||
} | ||
code = yurine.parse(code); | ||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.text = code; | ||
head.appendChild(script); | ||
} | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.