2025年9月5日 星期五

[HTML] [JS] HTML Canvas Download Image

  To enable the download of an image from an HTML canvas element, the following steps are typically performed using JavaScript:

  • Retrieve the Canvas Element: Obtain a reference to the HTML <canvas> element from which the image will be downloaded.
JavaScript
    const canvas = document.getElementById('myCanvas');
  • Convert Canvas to Data URL: Use the toDataURL() method of the canvas element to convert its current content into a data URL. This data URL represents the image in a base64-encoded format. The toDataURL() method can accept arguments for image format (e.g., 'image/png''image/jpeg') and quality (for JPEG/WebP).
JavaScript
    const imageDataURL = canvas.toDataURL('image/png'); // Or 'image/jpeg', 'image/webp'
  • Create a Download Link: Dynamically create an anchor (<a>) element in the DOM. This element will act as the download link.
JavaScript
    const downloadLink = document.createElement('a');
  • Set Link Attributes: Configure the href and download attributes of the newly created anchor element.
    • The href attribute is set to the imageDataURL obtained in the previous step.
    • The download attribute is set to the desired filename for the downloaded image. This attribute triggers the download behavior when the link is clicked.
JavaScript
    downloadLink.href = imageDataURL;    downloadLink.download = 'my_canvas_image.png'; // Specify desired filename and extension

Difference Between a Speech and an Essay

https://peachyessay.com/blogs/difference-between-speech-and-essay/

An essay is used to convey information if the targeted audience is reading. One that can access the written essay and read it. This falls short of providing immediate feedback.

While an essay is a piece of writing meant for the readers who have no direct interaction with the writer. There will be no room to interact or even have the reading audience engaged.

==

A speech is meant to be delivered by a speaker before an active audience. It is spoken before the audience that can be engaged in the presentation of the speech. At some point, the active audience can ask questions and get direct feedback from the speaker. This helps to enhance understanding and also gives further direction on areas that may not seem clear.

... a speech is frequently a spontaneous exchange involving two or more persons. Because context and common knowledge are important, it is possible to leave a lot of important content unspoken or inferred based on the audience’s input and response.

The timing, tone, volume, and timbre can all be used to lend an emotional element to a speech. Furthermore, certain language is used exclusively or primarily in a speech. Slang idioms and tags all fall in this category.

==

On a written page, formatting provides a helpful road map: the reader sees topic headings, paragraph breaks, and other visual cues that signal transitions naturally. You can replicate these cues and signal transitions using visual aids and body language, but it will take more conscious effort than simply hitting “enter” to create a paragraph break. As a public speaker, you will need to emphasize transition points through a combination of visual aids, body language, vocal delivery, and transitional words and phrases.

==

https://edge.sagepub.com/sites/default/files/elements_section_01_module02.pdf

Remember, the last things they hear will be the first things they remember.

亞健康狀態

因著不同事務要處理,最近的晚上已經實行不到九時半入睡的習慣;結果身體一直處於亞健康狀態,早上超級眼瞓(!!!!!),幾乎睜不開眼T.T 這種掙扎中的狀態真痛苦…… 結果星期中真的不行了,放下一切要處理的事務,吃完飯八時半就去睡了,而終於……終於!第二天早上找回了靈魂,工作不用再因...