Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ADAVANCE JAVA PROGRAMMING, Cheat Sheet of Java Programming

A practical exercise for a Data Visualization course, where the student is asked to draw different shapes using the Canvas element in HTML. The program code is provided, and the student is expected to apply different styles to each shape. The shapes include a line, a rectangle, a circle, an arc, and a house. useful as study notes or as an assignment for a Data Visualization course.

Typology: Cheat Sheet

2021/2022

Available from 03/27/2023

dhruv-7
dhruv-7 🇮🇳

5 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Subject Code : 3160717 Subject Name : Data Visualization Date :31/01/2023
Enrollment No : 200420107076 Name : Raj Dudhat
Practical No. : 2(a)
Problem Statement:
Draw Line, Rectangle, Circle, Arc, House. Apply different styles.
Program:
<!DOCTYPE html>
<html>
<head>
<title>Canvas Drawing</title>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="400" height="400"></canvas>
<script>
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
// Draw a line
ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(200, 50);
ctx.lineWidth = 5;
ctx.strokeStyle = "blue";
ctx.stroke();
// Draw a rectangle
ctx.beginPath();
ctx.rect(50, 100, 200, 100);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.lineWidth = 3;
SCET/CO/2022-23/EVEN/BE Shift-II/Sem-VI Page No : 1
pf3
pf4
pf5

Partial preview of the text

Download ADAVANCE JAVA PROGRAMMING and more Cheat Sheet Java Programming in PDF only on Docsity!

Enrollment No : 200420107076 Name : Raj Dudhat

Practical No. : 2(a)

Problem Statement:

Draw Line, Rectangle, Circle, Arc, House. Apply different styles.

Program:

Canvas Drawing **HOUSE:** Document canvas

Enrollment No : 200420107076 Name : Raj Dudhat context.beginPath(); context.rect(150, 300, 200, 200); context.lineWidth = 5; context.strokeStyle = "red"; context.fillStyle = "brown"; context.fill(); context.stroke(); context.beginPath(); context.rect(225, 400, 50, 100); context.lineWidth = 5; context.strokeStyle = "black"; context.fillStyle = "green"; context.fill(); context.stroke(); context.beginPath(); context.moveTo(100, 300); context.lineTo(400, 300); context.lineWidth = 5; context.strokeStyle = "purple"; context.lineTo(250, 200); context.closePath(); context.fillStyle = "blue"; context.fill(); context.stroke();

Enrollment No : 200420107076 Name : Raj Dudhat

Output:

HOUSE: