码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 前端——一些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>

  • 相关阅读:
    springboot基于WEB的高校文档打印系统毕业设计源码101004
    python之图形用户界面,如何安装wxPython
    JAVA计算机毕业设计演出购票系统Mybatis+系统+数据库+调试部署
    主键、外键和索引的区别
    基于深度学习的恶意软件检测
    Rust Vs Go:从头构建一个web服务
    Fedora 39(需联网)一键安装 Oracle 19C(19.22)单机版
    10个基于.Net开发的Windows开源软件项目
    LIO-SAM论文与代码阅读笔记(一)论文阅读
    微信小程序&会议OA-登录获取手机号流程&登录-小程序&导入微信小程序SDK(从微信小程序和会议OA登录获取手机号到登录小程序导入微信小程序SDK)
  • 原文地址:https://blog.csdn.net/qqqweiweiqq/article/details/128118531
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号