zoukankan      html  css  js  c++  java
  • 【canvas】--------------处理canvas物理像素模糊问题-------------【劉】

    js代码:
    var
    canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); // Set display size (css pixels). var size = 200; canvas.style.width = size + "px"; canvas.style.height = size + "px"; // Set actual size in memory (scaled to account for extra pixel density). var scale = window.devicePixelRatio; // <--- Change to 1 on retina screens to see blurry canvas. canvas.width = size * scale; canvas.height = size * scale; // Normalize coordinate system to use css pixels. ctx.scale(scale, scale); ctx.fillStyle = "#bada55"; ctx.fillRect(10, 10, 300, 300); ctx.fillStyle = "#ffffff"; ctx.font = '18px Arial'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; var x = size / 2; var y = size / 2; var textString = "I love MDN"; ctx.fillText(textString, x, y);
  • 相关阅读:
    javascript中闭包
    bootstrap模版
    JS中DOM操作
    css重置样式
    API--未完待续
    JavaScript 的面向对象
    「 JavaScript 篇 」
    CSS篇
    淘宝前端的一些面试题
    BOM里的window命令; cookie的用法
  • 原文地址:https://www.cnblogs.com/lstcon/p/10518230.html
Copyright © 2011-2022 走看看