简体   繁体   English

如何在HTML5画布中获得清晰的文本(使用Javascript旋转)

[英]How to get sharp text in HTML5 canvas, rotating with Javascript

I'm using HTML5 canvas alongside some Javascript to produce a rotating 3D sphere of text links ( source ). 我将HTML5 canvas与一些Javascript结合使用,以生成旋转的3D球形文本链接( )。

HTML: HTML:

<div id="myCanvasContainer">
    <canvas id="myCanvas" width="800" height="800" style="margin: 0 auto; display: block; padding:20px 0;">
      <ul>
        <a href="#">John Cage</a>
        <a href="#">Morton Feldman</a>
        <a href="#">Steve Reich</a>
        <a href="#">John Adams</a>
        <a href="#">Philip Glass</a>
        <a href="#">Arthur Russell</a>
        <a href="#">Brian Eno</a>
        <a href="#">Richard James</a>
      </ul>
   </canvas>

Javascript init file: Javascript初始化文件:

window.onload = function() {

    try {
    TagCanvas.textColour = '#000000';
    TagCanvas.textHeight = 20;
    TagCanvas.outlineColour = '#330000';
    TagCanvas.outlineMethod = 'colour';
    TagCanvas.radiusX = 0.9;
    TagCanvas.radiusY = 0.9;
    TagCanvas.radiusZ = 0.9;
    TagCanvas.depth = 0.5;
    TagCanvas.shuffleTags = true;
    TagCanvas.maxSpeed = 0.01;
    TagCanvas.txtOpt = true;
    TagCanvas.wheelZoom = false;
    TagCanvas.shape = "sphere";
    TagCanvas.textFont =  null;
    TagCanvas.Start('myCanvas');
    } catch(e) {
         document.getElementById('myCanvasContainer').style.display = 'none';
    }
};

This is fixed-width for now, so no interpolation or width changes. 目前这是固定宽度,因此插值或宽度都不会更改。 Zooming is switched off. 变焦关闭。 I'm looking to get sharper text than is shown below. 我希望获得比下面显示的文字更清晰的文字。 Setting textFont to null means it using the default font of the page. 将textFont设置为null意味着它使用页面的默认字体。 It seems a bit blurry compared to the default text. 与默认文本相比,似乎有点模糊。 Is it possible to get it sharper? 有可能变得更清晰吗? How would I do it? 我该怎么办?

在此处输入图片说明

I have suggested you to use SVG instead of Canvas. 我建议您使用SVG代替Canvas。 Since SVG is not affected while zooming. 由于缩放时SVG不会受到影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM