فيديو المحاضرة
فيديو المحاضرة
بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.
رسوم متحركة
أمثلة كود
أمثلة قصيرة وبسيطة
كل مثال وراه زرار «شغّل خطوة بخطوة»: بيعلّم على السطر اللي بيتنفّذ ويطبع الناتج زي ما بيتنفّذ بالظبط. ده شرح تنفيذ الكود سطر بسطر، مش مترجم حقيقي جوه الصفحة.
المثال ١: كام بكسل في شاشة Full HD؟
const w = 1920, h = 1080;const pixels = w * h;const mb = pixels * 3 / (1024 * 1024);console.log(pixels);console.log(mb.toFixed(2) + " MB");
المثال ٢: زمن الفريم
const hz = 60;console.log((1000 / hz).toFixed(2) + " ms");const hz2 = 120;console.log((1000 / hz2).toFixed(2) + " ms");
المثال ٣: ذاكرة شاشة 4K
const w = 3840, h = 2160, bytesPerPixel = 3;const bytes = w * h * bytesPerPixel;console.log(bytes);console.log((bytes / (1024 * 1024)).toFixed(1) + " MB");
اختبار قصير
اختبر فهمك
1. A random-scan display stores the picture as:
2. Raster-scan systems became popular mainly because:
3. The CRT was invented by:
4. A digitizer (graphics tablet) is used to:
5. An LCD panel is:
تمارين
جرّب بإيدك
التمرين 1
احسب زمن الفريم الواحد لشاشة 144Hz بالمللي ثانية (رقمين عشريين) واطبعه متبوعاً بـ ms.
Compute the frame time of a 144Hz screen in milliseconds (2 decimals) and print it followed by ms.
Starter code:
const hz = 144;// TODO: frame time = 1000 / hz, print with 2 decimals + " ms"
const hz = 144; console.log((1000 / hz).toFixed(2) + " ms");
Expected output
6.94 ms
التمرين 2
اكتب دالة framebufferMB(w, h, bpp) بترجّع حجم الفريم بالميجابايت (رقمين عشريين)، واطبع framebufferMB(1280, 720, 4).
Write framebufferMB(w, h, bpp) returning the frame size in MB (2 decimals), and print framebufferMB(1280, 720, 4).
Starter code:
function framebufferMB(w, h, bpp) { // TODO: bytes = w * h * bpp, return bytes / (1024 * 1024) with 2 decimals}console.log(framebufferMB(1280, 720, 4) + " MB");
function framebufferMB(w, h, bpp) {
const bytes = w * h * bpp;
return (bytes / (1024 * 1024)).toFixed(2);
}
console.log(framebufferMB(1280, 720, 4) + " MB");
Expected output
3.52 MB
مشروع صغير في آخر المحاضرة
نفس المثلث: أوامر ضد بكسلات
الداتا: our own 10x10 grid and three corner points; no external data.
License / source: Our own shape; Canvas API reference by MDN (link only, nothing copied). Reference page
الخطوات
- على ورقة رسم بياني 10 في 10، ارسم مثلث كأنه vector: تلات أوامر خطوط بين تلات نقط.
- وبعدين ظلّل نفس المثلث بكسل بكسل: كل صف امتلأ فيه خلايا من أوله لحد حرف المثلث.
- عدّ البكسلات وقارن: تلات أوامر ضد عشرات البكسلات.
Starter code:
// vector: 3 line commands between (0,0), (9,0), (9,9)// raster: fill row r from x=0 to x=r for r in 0..9// TODO: count the filled pixels and print both counts
// vector: 3 line commands between (0,0), (9,0), (9,9)
console.log("vector: 3 lines");
let pixels = 0;
for (let r = 0; r <= 9; r++) {
for (let x = 0; x <= r; x++) pixels++;
}
console.log("raster: " + pixels + " pixels");
Expected output
vector: 3 lines raster: 55 pixels
مشروع نهاية الفصل
ملف المشروع العملي للفصل 1
ملف PDF فيه مشروع صغير بأسئلة عملية تطبّق بيها كل اللي اتعلمته في الفصل، مع حل نموذجي في الآخر.
Credits: the topic order follows the course notes "Multimedia and Computer Graphics" by Dr. Muhammad Kashif Saeed (Applied College, Muhayil, King Khalid University), shared by the course owner. The explanations, diagrams, data and code in this lecture are our own; we copy nothing from the notes. Extra reference: Multimedia and Computer Graphics notes, Dr. Muhammad Kashif Saeed, King Khalid University (elc.kku.edu.sa) - own text, structure follows the notes.