• 前端——一些js的代码


    1. html>
    2. <html lang="en-us">
    3. <head>
    4. <meta charset="utf-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Simple DOM exampletitle>
    7. <style>
    8. body {
    9. margin: 0;
    10. overflow: hidden;
    11. }
    12. style>
    13. <canvas class="myCanvas">
    14. <p>添加恰当的反馈信息。p>
    15. canvas>
    16. <script>
    17. var canvas = document.querySelector('.myCanvas');
    18. var width = canvas.width = window.innerWidth;
    19. var height = canvas.height = window.innerHeight;
    20. var ctx = canvas.getContext('2d');
    21. ctx.fillStyle = 'rgb(0, 0, 0)';
    22. ctx.fillRect(0, 0, width, height);
    23. ctx.fillStyle = 'rgb(255, 0, 0)';
    24. ctx.fillRect(50, 50, 100, 150);
    25. ctx.fillStyle = 'rgb(0, 255, 0)';
    26. ctx.fillRect(75, 75, 100, 100);
    27. ctx.fillStyle = 'rgba(255, 0, 255, 0.75)';
    28. ctx.fillRect(25, 100, 175, 50);
    29. ctx.strokeStyle = 'rgb(255, 255, 255)';
    30. ctx.strokeRect(25, 25, 175, 200);
    31. ctx.lineWidth = 5;
    32. ctx.fillStyle = 'rgb(255, 0, 0)';
    33. ctx.beginPath();
    34. ctx.moveTo(50, 50);
    35. // 绘制路径
    36. ctx.fill();
    37. function degToRad(degrees) {
    38. return degrees * Math.PI / 180;
    39. };
    40. ctx.fillStyle = 'rgb(255, 0, 0)';
    41. ctx.beginPath();
    42. ctx.moveTo(50, 50);
    43. ctx.lineTo(150, 50);
    44. var triHeight = 50 * Math.tan(degToRad(60));
    45. ctx.lineTo(100, 50+triHeight);
    46. ctx.lineTo(50, 50);
    47. ctx.fill();
    48. ctx.fillStyle = 'rgb(0, 0, 255)';
    49. ctx.beginPath();
    50. ctx.arc(150, 106, 50, degToRad(0), degToRad(360), false);
    51. ctx.fill();
    52. var image = new Image();
    53. image.src = '22.png';
    54. image.onload = function() {
    55. ctx.drawImage(image, 50, 50);
    56. }
    57. // ctx.drawImage(image, 20, 20, 185, 175, 50, 50, 185, 175);
    58. ctx.translate(width/2, height/2);
    59. function degToRad(degrees) {
    60. return degrees * Math.PI / 180;
    61. };
    62. function rand(min, max) {
    63. return Math.floor(Math.random() * (max-min+1)) + (min);
    64. }
    65. var length = 250;
    66. var moveOffset = 20;
    67. for(var i = 0; i < length; i++) {
    68. ctx.fillStyle = 'rgba(' + (255-length) + ', 0, ' + (255-length) + ', 0.9)';
    69. ctx.beginPath();
    70. ctx.moveTo(moveOffset, moveOffset);
    71. ctx.lineTo(moveOffset+length, moveOffset);
    72. var triHeight = length/2 * Math.tan(degToRad(60));
    73. ctx.lineTo(moveOffset+(length/2), moveOffset+triHeight);
    74. ctx.lineTo(moveOffset, moveOffset);
    75. ctx.fill();
    76. length--;
    77. moveOffset += 0.7;
    78. ctx.rotate(degToRad(5));
    79. }
    80. script>
    81. head>
    82. <body>
    83. body>
    84. html>

  • 相关阅读:
    /run/udev/data 磁盘满
    深度学习 Day 19——数据增强
    SpringBoot实现注解方式日志log记录
    【Acwing166】数独(dfs+剪枝+位运算)超级详细题解!
    Java基础封装性
    【用户画像】数据层mybatis、mabatis-plus介绍和使用,多数据源配置、生成分群基本信息(源码实现)
    第3部分 静态路由
    金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
    力扣 1582. 二进制矩阵中的特殊位置
    shell流程控制
  • 原文地址:https://blog.csdn.net/qqqweiweiqq/article/details/128118531