三個Javascript函數sin,cos與canvas.font

Javascript在網頁就可以執行不需要開啟Spyder

以上程式碼

<style>BUTTON{BORDER:GREEN 5PX SOLID;BORDER-RADIUS:30PX;}</style>
<h1>Javascript在網頁就可以執行不需要開啟Spyder</h1>
<button onclick="LHsin()">sin執行</button>
<button onclick="LHcos()">cos執行</button>
<button onclick="xLine()">橫軸</button>
<canvas height="400" id="my" style="background: black;" width="1200"></canvas>
<script>
var c = document.getElementById("my");
var cty = c.getContext("2d");
var g = 0.01;//增加一個廣域變數,用在下面的Math.sin(g*x);
var h = 180;
function LHsin()
{
var x = 0;
var y = 200;
cty.beginPath(); 
cty.lineWidth = 5; 
cty.moveTo(x,y);
while (x < 1000){
  x = x + 1;
  y = 200 - h * Math.sin(g*x);
  cty.lineTo(x, y);
  cty.strokeStyle = "yellow";
  cty.stroke();
   };
}
function LHcos()
{
var x = 0;
var y = 200-h;//上面的sin是y =200這裡要改掉
cty.beginPath(); 
cty.lineWidth = 5; 
cty.moveTo(x,y);
while (x < 1000){
  x = x + 1;
  y = 200 - h * Math.cos(g*x);
  cty.lineTo(x, y);
  cty.strokeStyle = "red";
  cty.stroke();
   };
}
function xLine(){
cty.beginPath(); 
cty.lineWidth = 3; 
cty.moveTo(0,200);
    cty.lineTo(1000,200);
    cty.strokeStyle = "white";
    cty.stroke();
}
</script>

留言

  1. https://zhou-wei-ling.blogspot.com/2025/05/javascript.html

    回覆刪除
  2. https://huuiiiiman.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  3. https://yuweiiiiiiiiiiii.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  4. https://takming123.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  5. 作者已經移除這則留言。

    回覆刪除
  6. https://ting100000.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  7. https://sincewayne.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  8. https://gbsddik.blogspot.com/2025/05/javascruptsincoscanvasfont.html

    回覆刪除
  9. https://ting11111.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  10. https://mumeng-ru.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  11. https://xuan-ang.blogspot.com/2025/05/javascriptspyder.html

    回覆刪除
  12. https://pagestjing.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  13. https://jamie941128.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  14. https://huutingyu.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  15. https://tzuchenchu.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  16. https://kiannc1201.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  17. https://yangyami.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  18. https://winnielee0311.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  19. https://christina-lqw.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  20. https://chinenkohana.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  21. https://pei940922.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  22. https://vovo8564513.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  23. https://lin-yujing.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  24. https://ypayupinan.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  25. https://sklnfijseifjsk.blogspot.com/2025/05/javascriptsincoscanvasfont.html

    回覆刪除
  26. https://yuci0124.blogspot.com/2025/05/javascript.html

    回覆刪除
  27. https://koala111222.blogspot.com/2025/05/javasciptfontfillsylefilltext.html

    回覆刪除
  28. https://slu804387.blogspot.com/2025/05/buttonbordergreen-5px-solidborder_44.html

    回覆刪除
  29. https://d11117315111.blogspot.com/2025/06/javascriptsincoscanvasfont.html

    回覆刪除
  30. https://yangyoyo0125.blogspot.com/2025/06/javascriptsincoscanvasfont.html

    回覆刪除
  31. https://d11117242.blogspot.com/2025/06/javascriptsincoscanvasfont.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

2025年3月4日上課Python 陣列array串列的函數(方法)

劉任昌Javascript物件導向Python物件導向