Posts

Showing posts with the label tutorial

HTML Canvas Tutorial

Image
HTML Canvas Tutorial The HTML Canvas is a powerful tool for creating dynamic and interactive graphics. Let's explore it step by step: Drawing on the Canvas Rectangles You can draw rectangles like this: ctx.fillRect(20, 20, 150, 100); Lines You can draw lines like this: ctx.beginPath(); ctx.moveTo(50, 50); ctx.lineTo(200, 50); ctx.stroke(); Arcs / Circles You can draw circles like this: ctx.beginPath(); ctx.arc(100, 50, 50, 0, 2 * Math.PI); ctx.stroke(); Changing Colors You can change the fill color like this: ctx.fillStyle = 'blue'; ctx.fillRect(20, 20, 150, 100); Drawing Images You can draw images onto the canvas like this (replace the image source with your actual image path): let img = new Image(); img.src = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2DEeFKNOoVcIrAmoUxAvjIjRjxW82SiZ08JYsjx2cvAhZ7Ul60eV_G02IjjlLQ4NU-fp2ASSlEEdTaNCUBaYd1-QwP9x1DZDV_H4dg8seFVObVE4xPumMFanTC2RwUw1J7VMT4s0yjYxDFTvoi5F...

HTML Text Formatting

Image
In HTML, we can format text in various ways to enhance readability and presentation. Let's take a look at some of the common HTML text formatting tags. Bold Text We can make a text bold using the <strong> tag: <strong>This text is bold</strong> output: This text is bold Italic Text To italicize text, we use the <em> tag: <em>This text is italicized</em> output: This text is italicized Superscript and Subscript Text The <sup> and <sub> tags are used for superscripts and subscripts: <p>This is how you write H<sub>2</sub>O and E = mc<sup>2</sup>.</p> output: This is how you write H 2 O and E = mc 2 . Strikethrough Text The <del> tag creates strikethrough text: <del>This text is deleted</del> output: This text is deleted Inserted Text The <ins> tag is used to underline text: <ins>This text is inserted</ins...

Date and time handling in Python

Image
The ability to work with dates and times is an essential skill for any Python programmer. Python provides a built-in module called datetime that allows you to easily work with dates and times in your code. Creating a datetime object To work with dates and times in Python, you need to create a datetime object. You can create a datetime object using the datetime() function in the datetime module. The datetime() function takes four arguments: year , month , day , and hour , minute , second , and microsecond (optional). Here is an example: from datetime import datetime # create a datetime object dt = datetime(2023, 2, 23, 12, 30, 0) print(dt) output: 2023-02-23 12:30:00 In this example, we create a datetime object representing February 23, 2023 at 12:30 PM. We then print out the object using the print() function. Working with datetime objects Once you have created a datetime object, you can use various methods and attributes to work with it....