Skill
|
اصنع شاشة Bluescreen الخاصة بك تتيح لك هذه الصفحة تشغيل Bluescreen أو تعليمات برمجية أخرى باستخدام الصور الخاصة بك. يعد إنشاء شاشة زرقاء خاصة بك هنا مجرد نشاط اختياري للمتعة ، وليس شيئًا تم تقديره للدورة التدريبية. في بداية الأسبوع الثالث ، سننشئ موضوع منتدى للأشخاص لنشر صورهم التي تم إنشاؤها ومشاهدة صور الآخرين. بالنسبة إلى أحدث CS101 في جامعة ستانفورد ، كان لدينا اقتراحات الفئة التالية لألوان البلوز التي تم إنشاؤها خصيصًا. هذه ليست متطلبات ، ولكنها قد تساعد في إشعال بعض الأفكار حول ما يمكنك القيام به. فئات Bluescreen: فني فكاهة استخدام تأثيرات ما بعد الطلاء أنت تتسكع مع أوباما 1. إنشاء صور مقدمة ، ليست كبيرة جدًا قم أولاً بإنشاء صورة "مقدمة" مع أشخاص أو أي شيء أمام خلفية ملونة ، واحفظ تلك الصورة على جهاز الكمبيوتر الخاص بك. ملاحظة: لا تريد إنشاء صورة أكبر من أن تعمل معها. تقوم العديد من الكاميرات الرقمية بإنشاء صور كبيرة جدًا مثل 4000 إلى 3000. قد تكون هذه الصور الكبيرة أكبر من أن تعمل بثقة هنا ، لذلك من الأفضل إنشاء صورة متوسطة الحجم مثل 800 × 600. يمكنك القيام بذلك إما عن طريق تعيين الكاميرا لالتقاط صورة صورة صغيرة ، أو عن طريق تغيير حجم الصورة أو اقتصاصها قبل تحميلها في هذه الصفحة. على نظام التشغيل Mac ، يمكن لتطبيق "المعاينة المدمجة" اقتصاص الصور وتغيير حجمها وتصديرها ، وفي Windows أفترض وجود شيء مماثل. أو يمكنك استخدام موقع ويب مجاني للقيام بذلك مثل picresize.com (يفتح في نافذة جديدة). 2. التكوين الفني التقط بعض الصور الأمامية المختلفة للعب بها. إحدى الاستراتيجيات هي تركيز الشخص ، وستظهر الخلفية خلفه. تتمثل الإستراتيجية الأخرى في وضع الشخص على جانب واحد ، بحيث يمكن أن يبدو أنه ينظر إلى الخلفية التي تحددها أو يتفاعل معها. يمكنك أيضًا تجربة ارتداء ملابس الأشخاص في المقدمة بالملابس الزرقاء أو النظارات الشمسية الزرقاء أو أي شيء آخر ، لذلك ستظهر الخلفية من خلال تلك المناطق. ليس لديك لاستخدام الأزرق والأخضر هو أيضا شعبية. لاحظ أن الأقمشة الزرقاء الرخيصة الرخيصة لا تعمل بشكل صحيح كخلفية ، لأنها تميل إلى امتلاك مناطق بيضاء لامعة تفتقر إلى اللون. قد تتمكن من إصلاح هذا في "نشر" أدناه. 3. Fix It In Post (اختياري) "Fix It In Post" هي نوع من نكتة Hollywood ، في إشارة إلى إصلاح بعض الأخطاء التي تظهر على الكاميرا لاحقًا في مرحلة ما بعد الإنتاج بالكمبيوتر. هذا اختياري تمامًا ، لكن يمكنك القيام بنفس الشيء باستخدام صورة الشاشة الزرقاء. على سبيل المثال ، إذا لم يخرج جزء من الخلفية الزرقاء بالطريقة التي تريدها ، فيمكنك تحرير الصورة في برنامج الطلاء ، ورسم مستطيل أزرق فوق المنطقة لجعلها باللون الأزرق بالطريقة التي تريدها. (لقد قمت بذلك ، على سبيل المثال ، بعيون السمك في أحد الواجبات المنزلية ، لجعلها زرقاء حقًا حتى تبدو النتيجة صحيحة). نظرًا لأن اللون الأزرق يتم إزالته بواسطة خوارزمية الشاشة الزرقاء ، فإنه لا يظهر في الصورة النهائية. أنت تقوم فقط بإنشاء نوع من الثقوب لإظهار صورة الخلفية. على نظام Mac ، يتمتع تطبيق معاينة الصورة المدمجة بقدرة محدودة جدًا على وضع مستطيلات وأشكال بيضاوية ملونة على الأشياء ، ويتشابه برنامج Windows في برنامج الرسام. انطلاقًا من روح ترميز هذا الأمر بمفردك - يمكنك معالجة المقدمة والخلفية في برنامج الطلاء ، ولكن تجميعها جميعًا يجب أن يتم بواسطة الكود ومنطق if-statement الخاص بك. 4. تحميل الصورة في هذه الصفحة لتحميل صورة إلى هذه الصفحة ، استخدم الزر "استعراض" لتحديد ملف صورة على جهاز الكمبيوتر الخاص بك. يؤدي هذا إلى تحميل الصورة في هذه الصفحة حتى يتمكن الرمز من الرجوع إليها باسم الملف الخاص بها ، مثل "myimage.jpg" أو أيًا كان. هذا لا يحمّل الصورة على بعض الخوادم أو أي شيء من هذا القبيل ؛ الصورة تجلس فقط على جهاز الكمبيوتر الخاص بك طوال الوقت. عند إعادة تحميل هذه الصفحة ، يتم مسحها جميعًا. تصفح: الملفات التي قمت بتحميلها مع تحميل صورة واحدة أو أكثر أعلاه ، يمكنك كتابة التعليمات البرمجية التي تستخدمها أدناه. يمكنك تحميل صورة واحدة للمقدمة وصورة أخرى للخلفية. يجب أن يبدو الرمز كما يلي ، باستخدام اسم الصورة الفعلي ضمن علامات الاقتباس. image = جديد بسيط ("myimage.jpg") ؛ // الصورة تصفحها في وقت سابق بالاسم back = new SimpleImage ("moon.jpg")؛ back.setSameSize (صورة)؛ / / مفيدة في كثير من الأحيان للقيام بذلك // ... / / رمز للعمل في الصور / العودة الصور // ... طباعة (صورة)؛ عندما يكون لديك رمز يطبع صورة تريد الاحتفاظ بها ، يمكنك النقر بزر الماوس الأيمن فوق الصورة المطبوعة على الشاشة لحفظها محليًا. بالنسبة لي ، تعمل هذه الميزة في أحدث إصدار من Firefox و Chrome. ربما يكون الملف المحفوظ ملف صورة .png ، مشابهًا لـ jpg. ، ولكنه يميل إلى تناول المزيد من وحدات البايت. بالتناوب ، يمكنك التقاط لقطة شاشة على جهاز الكمبيوتر الخاص بك لالتقاط صورة بما في ذلك الصورة المطبوعة. Make Your Own Bluescreen This page lets you run Bluescreen or other code with your own images. Creating your own bluescreen here is just an optional activity for fun, not something graded for the course. At the start of week-3, we'll create a forum topic for people to post their created images and see other people's images. For the most recent Stanford on-campus CS101, we had the following category suggestions for custom created bluescreens. These are not requirements, but might help spark some ideas of what you could do. Bluescreen categories: Artistic Humor Use of post-paint effects You hanging out with an Obama 1. Create Foreground Images, Not Too Big First create a "foreground" image with people or whatever in front of a colored background, and save that image on your computer. Note: you don't want to create an image that is too large to work with. Many digital cameras create very large images like 4000 by 3000. Such large images may be too big to work reliably here, so it's best to create a moderate size image like 800 x 600. You can do this either by setting your camera to take a small image, or by resizing or cropping the image before loading it into this page. On the Mac, the built-in Preview application can crop and resize and export images, and on Windows I assume there's something similar. Or alternately you can use a free web site to do it such as picresize.com (opens in a new window). 2. Artistic Composition Take a few different foreground images to play with. One strategy is to have the person centered, and the background will appear behind them. Another strategy is to place the person to one side, so they can appear to look at or interact with the background you select. You can also try dressing the people in the foreground with blue clothes, or blue sunglasses or whatever, so the background will show through those areas. You don't have to use blue -- green is also popular. Note that the common cheap blue tarps don't work quite right as a background, because they tend to have shiny white areas which lack color. You might be able to fix this in "post" below. 3. Fix It In Post (optional) "Fix It In Post" is a sort of Hollywood joke, referring to fixing some on-camera mistake later on in the computer post-production phase. This is totally optional, but you can do the same sort thing with your bluescreen image. For example, if part of the blue background is not coming out the way you like, you can edit the image in a paint program, and draw a blue rectangle over the area to just make it be blue the way you want. (I did this, for example, with the fish's eyes in one homework, to make them really blue so the result looked right.) Since the blue gets removed by the bluescreen algorithm, it does not appear in the final image. You are just creating a sort of hole for the background image to show through. On the Mac, the built-in Preview image app has a very limited ability to put colored rectangles and ovals on things, and on Windows the Paint program is similar. In the spirit of coding this up on your own -- you can manipulate the foreground and background in a paint program, but putting it all together should be done by your code and your if-statement logic. 4. Load Image Into This Page To load an image into this page, use the Browse button to select an image file on your computer. This loads the image into this page so your code can refer to it by its file name, such as "myimage.jpg" or whatever. This does not upload the image to some server or anything like that; the image is just sitting on your computer the whole time. When you reload this page, it all gets cleared. Browse: Files you have uploaded With one or more images loaded above, you can write code that uses them below. You can load one image for the foreground and another image for the background. The code should look like the following, using the actual image name within the quotes. image = new SimpleImage("myimage.jpg"); // image browsed earlier by name back = new SimpleImage("moon.jpg"); back.setSameSize(image); // often useful to do this // ... // code to work in image/back images // ... print(image); When you have code that prints an image that you want to keep, you can right-click the image printed on screen to save it locally. For me, this feature works in the latest Firefox and Chrome. The saved file is probably a .png image file, which is similar to .jpg, but tends to take up more bytes. Alternately, you can take a screenshot on your computer to grab a picture including your printed image. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% حتى في هذا القسم سأتحدث مباشرة على أصغر مستوى داخل الكمبيوتر في بت الفردية والبايت. لذلك ، قليلا في جهاز الكمبيوتر هو أصغر كمية مساحة التخزين التي يمكن أن يكون لديك ، مثل الذرة. لذلك قليلا فقط يخزن صفر أو أ واحدة. تلك هي الدولتان الوحيدتان اللتان يمكنهما القيام به. لذلك ربما سمعت التعبير ، حسناً ، في أجهزة الكمبيوتر ، كما تعلمون ، كل شيء عبارة عن أصفار وأخرى. هذا يشير إلى البتات. كل شيء في الكمبيوتر مبني على هذه المجموعات الكبيرة والأكبر من هذه البتات البسيطة التي هي مجرد صفر وواحد. لذلك في الأجهزة ، أي شيء يمكن ، قادر على تولي ولايتين مختلفتين وعندما يأخذ حالة واحدة يمكن البقاء في ذلك. هذه هي الطريقة التي يمكن أن تمثل قليلا في الأجهزة وهناك مجموعة من الطرق المختلفة للقيام بذلك. لقد فعلا مجرد دعامة. لقد بنيت هذا الشيء هنا. إذاً هذا مصنوع قليلاً من مضرب تنس به بعض البلاستيك. و الطريقة التي تعمل بها هي أن لديها حالتين مختلفتين. لذلك سأعمل فقط الحالة صفر الحالة ، وبعد ذلك يمكنني دفعه إلى الدولة الأخرى. البلاستيك يستقر ويبقى ، وسوف ندعو أن الدولة واحدة حتى أتمكن من التبديل مرة أخرى إلى صفر. صفر ، يستدير ، هناك واحد. لذلك ، هو مثال تافه ولكن في الصعب السكك الحديدية منه يظهر ، لدينا عدد قليل من دولتين مختلفتين ومستقر. عندما انت وضعها في حالة ، يبقى. هذا يكفي لتمثيل قليلا في الكمبيوتر ونحن رؤية أشكال مختلفة منه حتى مع الترانزستور ، والحالتان مختلفتان يتم ذلك عن طريق وجود مجموعات صغيرة من الإلكترونات. على القرص الصلب طبق تتم ولايتان مختلفتان من خلال وجود منطقة صغيرة في الشمال المغناطيسية أو المغناطيسية الجنوبية وبعد ذلك يمكن أن يعود وننظر ، كما تعلمون قل يا حسنًا ، سوف نقول ما إذا كان الشمال ، هذا واحد وإذا كان جنوبًا ، فهو صفر أو ايا كان. لذا ، الشيء ذاته فقط ، إنه صغير جدًا بحيث لا يكون جيدًا لأي شيء. انها فقط انت تعرف؟ صفر وواحد ، إذن ، ما سنفعله حقًا هو تجميع ثماني بتات لجعل بايت. والبايتة هي وحدة القياس الشائعة جدًا. لذلك ، إذا كان هو مكتوب سبيل المثال بايت ، وأنا نوع من التفكير في الأمر مثل هذا. اعجبني ستحصل على ثمانية أرقام لكن الأرقام ثنائية لذلك كل واحد فقط هو صفر أو واحد. وهكذا ، أي ثمانية ، أي بايت يمكن أن نفكر فيه فقط سوف يكون هذا نمط من ثمانية 0 أو 1 ل. كما ذكرت قبل بايت في العالم الحقيقي يمكنك أن تفكر في الأمر كفرز نوع حرف kinda لذلك فهو حقًا جميل صغير. يحمل ، يحمل القليل جدا ولكن يمكننا أن نعرف بناء تدابير أخرى خارج من ذلك. لذا فإن السؤال الذي أريد أن أنظر إليه هو. بالضبط كم يمكن أن تحمل بايت واحد؟ و انا أريد أن أصل الرياضيات لذلك. أنا الآن لن أحمل الجميع المسؤولية تفاصيل هذا ولكن أريد أن أذهب إلى الاشتقاق فقط حتى تتمكن من رؤيته. وبالتالي السؤال الذي سأستكشفه هو ، إذا كان لدي عدد من البتات ، فكم عدد الأنماط ، So in this section I'm going to talk right at the smallest level inside of the computer at individual bits and bytes. So, a bit in a computer is the smallest amount of storage that you can have, like an atom. So a bit just stores a zero or a one. Those are the only two states it can do. So you may have heard the expression, oh well, in computers, you know, it's all zeroes and ones. That's referring to bits. Everything in the computer is built up out of this larger and larger collections of these simple bits which is just zero and one. So In the hardware, Anything that can, is capable of taking on two different states and when it takes on one state it can stay in it. That's how you can represent a bit in hardware and there's a bunch of different ways of doing it. I've actually just as a prop. I built this bit here. So this is a bit made out of a tennis racket with some plastic in it. And the way this works is that it has two different states. So I'm gonna just call the state the zero state, and then I can push it to the other state. The plastic snaps and it stays, we'll call that the one state so I could switch it back to zero. Zero, turn around, there's one. So, it's a trivial example but at the hard rail of it shows, we have few have two different state and its stable. When you put it in a state, it stays. That's enough to represent a bit in the computer and we see different forms of it so with the transistor, the two different states are done by having little tiny groups of electrons. On the hard drive platter the two different states are done by having either a little area set to either North magnetism or South magnetism and later can come back and look, you know just say oh well, we'll say if it's North, that's a one and if it's South, it's zero or whatever. So, the bit just by itself, it's too small to be good for anything. It's just, you know? Zero and one, So, really what we're gonna do is to group eight bits to make a byte. And the byte is just this very common unit of measurement. So, if an example byte is written out, I sort of think about it like this. Like well, you're gonna have eight digits but the digits are binary so each one is just a zero or a one. And so, any eight, any byte we could think of is just gonna be this pattern of eight 0's or 1's. As I mentioned before a byte in the real world you can think of it as sorting kinda one type letter so it's really, it's pretty small. It holds, holds very little but we can you know build up other measures out of it. So the question I wanna look at is. Exactly how much can one byte hold? And I wanna work out the math for that. Now I'm not gonna hold everyone responsible for the details of this but I wanna go to the derivation just so you can see it. So the question I'm going to explore is, if I have a number of bits, how many patterns, كيف يمكن أن تجعل العديد من الأنماط المتميزة مع تلك البتات؟ وانا ذاهب في البداية فقط ضع في اعتبارك إما قطعة واحدة أو اثنتين أو ثلاثة أجزاء. لذلك ، لقد وضعت هذه في طاولة صغيرة. لذلك إذا كان لديّ قطعة واحدة ، سأقول ، هذا ما يمكنك فعله على حسابك رئيس. هناك نمطان فقط. إما أنه صفر أو واحد. لا يوجد نمط الوسط وهذا كل شيء ، اثنان هو كل ما يمكننا القيام به. لذلك من المفترض أن لدينا اثنين من بت لذلك سأتخيل وضع البتات بجانب بعضنا البعض لذلك هناك مثل اليسار قليلا واليمين وبعد ذلك يمكننا العمل على أنماط لذلك. حسنا، لنرى هناك نمط حيث كلتا البتات تساوي ثم هناك نمط حيث بت اليسار هو صفر والبت الصحيح هو واحد ثم الذهاب الآخر يمكننا الحصول على بت اليسار يكون واحد واليمين يكون صفرا ، وأخيرا هناك حالة حيث كليهما البتات واحدة حتى في جزئين يمكنني الحصول على أربعة أنماط. الآن ، لثلاث بت يحصل على أكثر تعقيدًا قليلاً ، لذا سأعمل على حل المشكلة المشي من خلال العديد من الأنماط التي سوف تجعل. لذلك لمدة ثلاثة بت ، و الخدعة ستكون ، لذلك ها هي الحالة ذات الثلاثة بت هنا. مجرد التفكير في ذلك أنا ، أنا تخيل لدي ثلاث بتات بجانب بعضها البعض ، مجرد النظر في اليسار أكثر قليلا. دعونا فقط عزل على اليسار أكثر قليلا. وهناك احتمالان فقط. إما أن أقصى اليسار هو صفر أو الأكثر بت هو واحد ، وهذا هو الوحيدان الاحتمالات. لذلك دعونا ننظر في القضية فقط ، من المفترض فقط أنها صفر. مجرد من المفترض أن يكون صفرا ، لذلك سوف تعطيني هذا الصف العلوي. حسنا إذا أنا فقط قفل غادر معظم بت في الصفر ، ثم لدي هذه البتات الأخريين على يمين منه. لكن في الواقع ، لقد توصلنا بالفعل إلى عدد الأنماط الممكنة باستخدام اثنتين من البتات قد تظهر مرة أخرى ، أربعة فقط ، وهذا مجرد أربعة أنماط. وحتى لو كنت قفل اليسار معظم بت في الصفر هناك ، ثم أحصل على أربعة أنماط كوز لدي صفر وبعد ذلك كل واحد من الأنماط الأربعة لاثنين من البتات حتى في هذا الصف المميز الذي يعطيني أربعة. هكذا كان الحال عندما يكون الجزء الأيسر الأكثر يساوي صفر. ما هي الحالة الأخرى؟ ال الحالة الأخرى هي أن معظم بت اليسار هو واحد ، وإذا كنت أغلقت بت أكثر اليسار في واحدة. أنت تعرف أنني حصلت على هذه الأنماط الأربعة مرة أخرى كما لو أنه لا يزال لدي قطعتان إلى اليمين وحتى أحصل في نسخة أخرى من الأنماط الأربعة التي يمكن أن يتم مع اثنين من البتات. لذلك لثلاث بتات ، ينجح في الواقع أن هناك ثمانية أنماط وأنا أفكر فيها كنوع من مثل جيد ، هناك أربعة مع غادر معظم بت صفر ثم هناك أربعة مرة أخرى مع اليسار بت أكثر كواحد. حتى إذا كنت ، بشكل عام ، يمكنك أن ترى هنا حتى طاولتي الصغيرة ، لكل صف ، على في الصف التالي ، فأنت تقوم بشكل أساسي بإضافة القليل إلى اليسار وهكذا فإن ما ستفعله هو ما عليك سوى مضاعفة عدد الأنماط التي لديك في الصف أعلاه. ولذا فقد ركضت من خلال الرياضيات هنا لذلك مع قليل واحد رأينا أنه كان هناك نمطان ، فقط صفر أو واحد. إذن عندما أذهب إلى جزئين ، أحصل على أربعة أنماط وثلاثة بتات ثمانية أنماط. لكن إذا نظرت فقط إلى الأرقام هنا ، يمكنك أن ترى مضاعفتها. وغني عن اثنين أو أربعة أو ثمانية أو ستة عشر ، لذلك في كل مرة أقوم بإضافة بت واحد الذي أفكر نوع من الخروج إلى اليسار ، فإنه يضاعف عدد الأنماط التي يمكنني صنعها. لذلك إذا نحن فقط اتبع هذا من خلال ، يذهب 32 ، 64 ، 128 ومع ثمانية بت هناك 256 أنماط مختلفة ممكن. وللبحار ثماني بتات وهذا هو حجم البايت ، لذلك يعمل بها. يمكن بايت واحد تخزين 256 أنماط مختلفة. رياضيا في اتضح أنه أسي لذلك مع n bits يمكنني أن أجعل اثنين إلى nth مختلفة الأنماط ، اثنان إلى القوة nth لذلك فإن الحالة التي أريد التركيز عليها هي بايت واحد. و هنا ما تحتاج إلى معرفته. لذلك ، بايت واحد هو مجموعة من ثمانية بت. ولقد ذهب نوع من من خلال الاشتقاق أنه مع ثمانية بتات ، هناك 256 نمطًا مختلفًا ممكنًا. hHow many distinct patterns can I make with those bits? And I'm gonna; first of all just consider either one bit, two bits, or three bits. So I, I've put these in a little table. So if I have one bit, I'm gonna say, this one you could do on your head. There's just two patterns. Either it's a zero or it's a one. There's no center pattern and that's it, two is all we can do. So supposed we've got two bits so I'm gonna imagine putting the two bits next to each other so there's like a left bit and a right bit and then we can work out the patterns for that. Well, let's see there's the pattern where both bits are zero then there's the pattern where the left bit is zero and the right bit is one and then going the other we can have the left bit be one and right bit be zero and then finally there's the case where both bits are one so at two bits I can get four patterns. Now, for three bits it gets a little more complicated so I'm gonna, I'm gonna sort of break the problem down and walk through how many patterns that's going to make. So for three bits, the trick is gonna be, so here's the three-bit case down here. Just consider so I'm, I'm imagining I have three bits next to each other, just consider the left most bit. Let's just isolate on the left most bit. And, there's only two possibilities. Either the left most bit is zero or the left most bit is one, that's the only two possibilities. So let's just consider the case, just supposed it's zero. Just supposed it's a zero, so that's gonna give me this top row. Well if I just lock the left most bit at zero, then I've got this other two bits at the right of it. But actually we already worked out how many patterns are possible with two bits that might reappear, just four, that's just four patterns. And so if I lock the left most bit at zero there's, then I get four patterns cuz I have zero and then each one of the four patterns for two bits so in this highlighted row that gives me four. So that was the case where the left most bit is zero. What's the other case? The other case is that the left most bit is one and if I lock the left most bit at one. You know I just got those four patterns again like I still have two bits to the right and so I get in a sense another copy of the four patterns that can be made with two bits. So for three bits it works out actually that there eight patterns and I'm thinking of them as kind of like well, there's the four with the left most bit of zero and then there is four again with the left most bit as one. So if you, in general, you can see it here even my little table, for each row, On the next row, you're basically adding a bit to the left and so what that's gonna do is just double the number of patterns that you have in the row above. And so I've run through the math here so with one bit we saw that there were two patterns, just a zero or one. So then when I go to two bits, I get four patterns and three bits, I get eight patterns. But if you just look at the numbers here you can see its doubling. It goes two, four, eight, sixteen so each time I add one bit which I'm thinking sort of going out to left, it doubles the number of patterns I can make. So if we just follow this through, it goes 32, 64, 128 and with eight bits there are 256 different patterns possible. And of cour se eight bits that's the size of a byte, so it works out. One byte can store 256 different patterns. Mathematically in turns out to be exponential so with n bits I can make two to the nth different patterns, Two to the nth power so the case I wanna focus on is one byte. And here's what you need to know. So, one byte is a group of eight bits. And I've sort of gone through the derivation that with eight bits, 256 different patterns are possible. لذلك ، أعتقد أن السؤال الطبيعي هو ، إلى أين ، حسنا ، ما هو الشيء الجيد؟ حقا ما أريد القيام به هو التفكير ، كيف يمكنني استخدام هذه الأنماط لتمثيل أعداد؟ لذا فإن الطريقة التي سأفكر فيها بالأرقام هي أن كل رقم سيحصل عليه 256 من الأنماط المختلفة ، وأنا لن أدخل في تفاصيل حول كيفية ذلك تم تعيينه ولكن كل رقم يحتاج إلى رقم خاص به ولا يمكنه مشاركة نمط مع البعض الآخر رقم. إذاً الطريقة التي أفكر فيها هي مجرد رصاصة. دعونا نعطي بعض النمط ل الرقم صفر. لذلك ، لدينا 256 نمطًا ، وسنمنح أحدها صفرًا ثم سنقدم نمطًا آخر إلى 1 ونمطًا آخر إلى 2 وآخر نمط إلى 3 وهلم جرا. وسنحاول فقط الاستمرار حتى نفد أنماط - رسم. لذلك دعونا نذهب إلى العمل ، فهل لدينا ما يصل إلى 254 ثم النمط الأخير ، نحن تبقى واحدة سنستخدمها للرقم 255 بحيث يكون 255 هو الحد الأقصى القابل للتمثيل الرقم في بايت واحد. أعتقد أنه سيكون هناك سؤال معقول ، حسنًا ، لقد حصلت على 255. لماذا أليس 256 لدينا 256 نمطًا مختلفًا والسبب في ذلك ليس 256 أننا نستخدم نمطًا واحدًا للرقم 0 ، لذا نستخدم هذا النموذج لأعلى ثم إذا كنت فقط عد عدد ، وعدد الأرقام لدي هنا. 255 ستحتاج تتطلب النمط الأخير ؛ رقم النمط 256. لذلك ، تبين إذا كنت تفكر في ما يمكن أن يكون المخزنة في بايت واحد كرقم ، تمثيل العداد هو أن بايت واحد سيتم تخزين الأرقام بين صفر إلى 255. لذا 255 هو الحد الأقصى. لذلك جاء هذا بالفعل في وقت سابق عندما كنا ننظر إلى رمز مثل pixel.setRed وما هو العدد الذي استغرقه؟ يأخذ Pixel.setRed رقماً في النطاق 0-255. لماذا ا؟ لماذا ا؟ والسبب هو يتم تخزين القيمة الحمراء للبكسل في الكمبيوتر في بايت واحد. وذلك بايت يمكن تخزين الأرقام في النطاق 0-255. انها فقط ، هذا كل شيء. لا يمكن تخزينها 300 أو -12 أو أيا كان. لهذا السبب. في هذا ، في هذا المخطط ، يأخذ setRed الأرقام 0-255. إنها تعكس حقيقة أن القيمة الحمراء - وهذا هو صحيح أيضًا بالنسبة للقيم الخضراء والأزرق - يتم تخزين كل واحدة من هذه القيم بواسطة واحدة بايت ثمانية بت ، ولهذا السبب النطاق هو بالضبط صفر إلى 255. إذن ، سر
Really what I wanna do is think about, how can I use those patterns to represent numbers? So the way I'm gonna think about numbers is each number is gonna get one of the 256 different patterns and I'm not gonna get into details of, of how they're assigned but each number needs its own and it can't share a pattern with some other number. So the way when I think about it, is just bullet. Let's give some pattern to number zero. So we, we've got 256 patterns, we'll give one of them to zero and then we'll give another pattern to 1 and another pattern to 2 and another pattern to 3 and so on. And we'll just try to keep going until we run out of patterns. So let's go to work, is we get up to 254 and then the last pattern, we have one left we'll use for the number 255 so 255 will be the maximum representable number in one byte. I think a reasonable question would be, okay I got 255. Why isn't it 256? We have 256 different patterns and the reason it's not 256 is that we use one pattern for number 0. So we use that one up and then if you just count up the number of, the number of numbers I have here. 255 is gonna require the last pattern; pattern number 256. So, turns out if you think of what can be stored in one byte as a number, the counter representation is that one byte will store numbers between zero up to 255. So 255 is the max. So this actually came up earlier when we were looking at code like pixel.setRed and what number did it take? Pixel.setRed takes a number in the range 0-255. Why? Why? And the reason is that the red value for pixel in the computer is stored in one byte. And that byte can store numbers in the range 0-255. It's just, that's it. It cannot store 300 or -12 or whatever. So that's why. In this, in this scheme, setRed takes the numbers 0-255. It actually reflects that the red value - and this is also true for the green and the blue values - each one of those is stored by one eight bit byte and so that's why the range is exactly zero to 255. So, the mystery of the 255. Now you know. حتى في هذا القسم سأتحدث مباشرة على أصغر مستوى داخل الكمبيوتر في بت الفردية والبايت. لذلك ، قليلا في جهاز الكمبيوتر هو أصغر كمية مساحة التخزين التي يمكن أن يكون لديك ، مثل الذرة. لذلك قليلا فقط يخزن صفر أو أ واحدة. تلك هي الدولتان الوحيدتان اللتان يمكنهما القيام به. لذلك ربما سمعت التعبير ، حسناً ، في أجهزة الكمبيوتر ، كما تعلمون ، كل شيء عبارة عن أصفار وأخرى. هذا يشير إلى البتات. كل شيء في الكمبيوتر مبني على هذه المجموعات الكبيرة والأكبر من هذه البتات البسيطة التي هي مجرد صفر وواحد. لذلك في الأجهزة ، أي شيء يمكن ، قادر على تولي ولايتين مختلفتين وعندما يأخذ حالة واحدة يمكن البقاء في ذلك. هذه هي الطريقة التي يمكن أن تمثل قليلا في الأجهزة وهناك مجموعة من الطرق المختلفة للقيام بذلك. لقد فعلا مجرد دعامة. لقد بنيت هذا الشيء هنا. إذاً هذا مصنوع قليلاً من مضرب تنس به بعض البلاستيك. و الطريقة التي تعمل بها هي أن لديها حالتين مختلفتين. لذلك سأعمل فقط الحالة صفر الحالة ، وبعد ذلك يمكنني دفعه إلى الدولة الأخرى. البلاستيك يستقر ويبقى ، وسوف ندعو أن الدولة واحدة حتى أتمكن من التبديل مرة أخرى إلى صفر. صفر ، يستدير ، هناك واحد. لذلك ، هو مثال تافه ولكن في الصعب السكك الحديدية منه يظهر ، لدينا عدد قليل من دولتين مختلفتين ومستقر. عندما انت وضعها في حالة ، يبقى. هذا يكفي لتمثيل قليلا في الكمبيوتر ونحن رؤية أشكال مختلفة منه حتى مع الترانزستور ، والحالتان مختلفتان يتم ذلك عن طريق وجود مجموعات صغيرة من الإلكترونات. على القرص الصلب طبق تتم ولايتان مختلفتان من خلال وجود منطقة صغيرة في الشمال المغناطيسية أو المغناطيسية الجنوبية وبعد ذلك يمكن أن يعود وننظر ، كما تعلمون قل يا حسنًا ، سوف نقول ما إذا كان الشمال ، هذا واحد وإذا كان جنوبًا ، فهو صفر أو ايا كان. لذا ، الشيء ذاته فقط ، إنه صغير جدًا بحيث لا يكون جيدًا لأي شيء. انها فقط انت تعرف؟ صفر وواحد ، إذن ، ما سنفعله حقًا هو تجميع ثماني بتات لجعل بايت. والبايتة هي وحدة القياس الشائعة جدًا. لذلك ، إذا كان هو مكتوب سبيل المثال بايت ، وأنا نوع من التفكير في الأمر مثل هذا. اعجبني ستحصل على ثمانية أرقام لكن الأرقام ثنائية لذلك كل واحد فقط هو صفر أو واحد. وهكذا ، أي ثمانية ، أي بايت يمكن أن نفكر فيه فقط سوف يكون هذا نمط من ثمانية 0 أو 1 ل. كما ذكرت قبل بايت في العالم الحقيقي يمكنك أن تفكر في الأمر كفرز نوع حرف kinda لذلك فهو حقًا جميل صغير. يحمل ، يحمل القليل جدا ولكن يمكننا أن نعرف بناء تدابير أخرى خارج من ذلك. لذا فإن السؤال الذي أريد أن أنظر إليه هو. بالضبط كم يمكن أن تحمل بايت واحد؟ و انا أريد أن أصل الرياضيات لذلك. أنا الآن لن أحمل الجميع المسؤولية تفاصيل هذا ولكن أريد أن أذهب إلى الاشتقاق فقط حتى تتمكن من رؤيته. وبالتالي السؤال الذي سأستكشفه هو ، إذا كان لدي عدد من البتات ، فكم عدد الأنماط ، So in this section I'm going to talk right at the smallest level inside of the computer at individual bits and bytes. So, a bit in a computer is the smallest amount of storage that you can have, like an atom. So a bit just stores a zero or a one. Those are the only two states it can do. So you may have heard the expression, oh well, in computers, you know, it's all zeroes and ones. That's referring to bits. Everything in the computer is built up out of this larger and larger collections of these simple bits which is just zero and one. So In the hardware, Anything that can, is capable of taking on two different states and when it takes on one state it can stay in it. That's how you can represent a bit in hardware and there's a bunch of different ways of doing it. I've actually just as a prop. I built this bit here. So this is a bit made out of a tennis racket with some plastic in it. And the way this works is that it has two different states. So I'm gonna just call the state the zero state, and then I can push it to the other state. The plastic snaps and it stays, we'll call that the one state so I could switch it back to zero. Zero, turn around, there's one. So, it's a trivial example but at the hard rail of it shows, we have few have two different state and its stable. When you put it in a state, it stays. That's enough to represent a bit in the computer and we see different forms of it so with the transistor, the two different states are done by having little tiny groups of electrons. On the hard drive platter the two different states are done by having either a little area set to either North magnetism or South magnetism and later can come back and look, you know just say oh well, we'll say if it's North, that's a one and if it's South, it's zero or whatever. So, the bit just by itself, it's too small to be good for anything. It's just, you know? Zero and one, So, really what we're gonna do is to group eight bits to make a byte. And the byte is just this very common unit of measurement. So, if an example byte is written out, I sort of think about it like this. Like well, you're gonna have eight digits but the digits are binary so each one is just a zero or a one. And so, any eight, any byte we could think of is just gonna be this pattern of eight 0's or 1's. As I mentioned before a byte in the real world you can think of it as sorting kinda one type letter so it's really, it's pretty small. It holds, holds very little but we can you know build up other measures out of it. So the question I wanna look at is. Exactly how much can one byte hold? And I wanna work out the math for that. Now I'm not gonna hold everyone responsible for the details of this but I wanna go to the derivation just so you can see it. So the question I'm going to explore is, if I have a number of bits, how many patterns, كيف يمكن أن تجعل العديد من الأنماط المتميزة مع تلك البتات؟ وانا ذاهب في البداية فقط ضع في اعتبارك إما قطعة واحدة أو اثنتين أو ثلاثة أجزاء. لذلك ، لقد وضعت هذه في طاولة صغيرة. لذلك إذا كان لديّ قطعة واحدة ، سأقول ، هذا ما يمكنك فعله على حسابك رئيس. هناك نمطان فقط. إما أنه صفر أو واحد. لا يوجد نمط الوسط وهذا كل شيء ، اثنان هو كل ما يمكننا القيام به. لذلك من المفترض أن لدينا اثنين من بت لذلك سأتخيل وضع البتات بجانب بعضنا البعض لذلك هناك مثل اليسار قليلا واليمين وبعد ذلك يمكننا العمل على أنماط لذلك. حسنا، لنرى هناك نمط حيث كلتا البتات تساوي ثم هناك نمط حيث بت اليسار هو صفر والبت الصحيح هو واحد ثم الذهاب الآخر يمكننا الحصول على بت اليسار يكون واحد واليمين يكون صفرا ، وأخيرا هناك حالة حيث كليهما البتات واحدة حتى في جزئين يمكنني الحصول على أربعة أنماط. الآن ، لثلاث بت يحصل على أكثر تعقيدًا قليلاً ، لذا سأعمل على حل المشكلة المشي من خلال العديد من الأنماط التي سوف تجعل. لذلك لمدة ثلاثة بت ، و الخدعة ستكون ، لذلك ها هي الحالة ذات الثلاثة بت هنا. مجرد التفكير في ذلك أنا ، أنا تخيل لدي ثلاث بتات بجانب بعضها البعض ، مجرد النظر في اليسار أكثر قليلا. دعونا فقط عزل على اليسار أكثر قليلا. وهناك احتمالان فقط. إما أن أقصى اليسار هو صفر أو الأكثر بت هو واحد ، وهذا هو الوحيدان الاحتمالات. لذلك دعونا ننظر في القضية فقط ، من المفترض فقط أنها صفر. مجرد من المفترض أن يكون صفرا ، لذلك سوف تعطيني هذا الصف العلوي. حسنا إذا أنا فقط قفل غادر معظم بت في الصفر ، ثم لدي هذه البتات الأخريين على يمين منه. لكن في الواقع ، لقد توصلنا بالفعل إلى عدد الأنماط الممكنة باستخدام اثنتين من البتات قد تظهر مرة أخرى ، أربعة فقط ، وهذا مجرد أربعة أنماط. وحتى لو كنت قفل اليسار معظم بت في الصفر هناك ، ثم أحصل على أربعة أنماط كوز لدي صفر وبعد ذلك كل واحد من الأنماط الأربعة لاثنين من البتات حتى في هذا الصف المميز الذي يعطيني أربعة. هكذا كان الحال عندما يكون الجزء الأيسر الأكثر يساوي صفر. ما هي الحالة الأخرى؟ ال الحالة الأخرى هي أن معظم بت اليسار هو واحد ، وإذا كنت أغلقت بت أكثر اليسار في واحدة. أنت تعرف أنني حصلت على هذه الأنماط الأربعة مرة أخرى كما لو أنه لا يزال لدي قطعتان إلى اليمين وحتى أحصل في نسخة أخرى من الأنماط الأربعة التي يمكن أن يتم مع اثنين من البتات. لذلك لثلاث بتات ، ينجح في الواقع أن هناك ثمانية أنماط وأنا أفكر فيها كنوع من مثل جيد ، هناك أربعة مع غادر معظم بت صفر ثم هناك أربعة مرة أخرى مع اليسار بت أكثر كواحد. حتى إذا كنت ، بشكل عام ، يمكنك أن ترى هنا حتى طاولتي الصغيرة ، لكل صف ، على في الصف التالي ، فأنت تقوم بشكل أساسي بإضافة القليل إلى اليسار وهكذا فإن ما ستفعله هو ما عليك سوى مضاعفة عدد الأنماط التي لديك في الصف أعلاه. ولذا فقد ركضت من خلال الرياضيات هنا لذلك مع قليل واحد رأينا أنه كان هناك نمطان ، فقط صفر أو واحد. إذن عندما أذهب إلى جزئين ، أحصل على أربعة أنماط وثلاثة بتات ثمانية أنماط. لكن إذا نظرت فقط إلى الأرقام هنا ، يمكنك أن ترى مضاعفتها. وغني عن اثنين أو أربعة أو ثمانية أو ستة عشر ، لذلك في كل مرة أقوم بإضافة بت واحد الذي أفكر نوع من الخروج إلى اليسار ، فإنه يضاعف عدد الأنماط التي يمكنني صنعها. لذلك إذا نحن فقط اتبع هذا من خلال ، يذهب 32 ، 64 ، 128 ومع ثمانية بت هناك 256 أنماط مختلفة ممكن. وللبحار ثماني بتات وهذا هو حجم البايت ، لذلك يعمل بها. يمكن بايت واحد تخزين 256 أنماط مختلفة. رياضيا في اتضح أنه أسي لذلك مع n bits يمكنني أن أجعل اثنين إلى nth مختلفة الأنماط ، اثنان إلى القوة nth لذلك فإن الحالة التي أريد التركيز عليها هي بايت واحد. و هنا ما تحتاج إلى معرفته. لذلك ، بايت واحد هو مجموعة من ثمانية بت. ولقد ذهب نوع من من خلال الاشتقاق أنه مع ثمانية بتات ، هناك 256 نمطًا مختلفًا ممكنًا. hHow many distinct patterns can I make with those bits? And I'm gonna; first of all just consider either one bit, two bits, or three bits. So I, I've put these in a little table. So if I have one bit, I'm gonna say, this one you could do on your head. There's just two patterns. Either it's a zero or it's a one. There's no center pattern and that's it, two is all we can do. So supposed we've got two bits so I'm gonna imagine putting the two bits next to each other so there's like a left bit and a right bit and then we can work out the patterns for that. Well, let's see there's the pattern where both bits are zero then there's the pattern where the left bit is zero and the right bit is one and then going the other we can have the left bit be one and right bit be zero and then finally there's the case where both bits are one so at two bits I can get four patterns. Now, for three bits it gets a little more complicated so I'm gonna, I'm gonna sort of break the problem down and walk through how many patterns that's going to make. So for three bits, the trick is gonna be, so here's the three-bit case down here. Just consider so I'm, I'm imagining I have three bits next to each other, just consider the left most bit. Let's just isolate on the left most bit. And, there's only two possibilities. Either the left most bit is zero or the left most bit is one, that's the only two possibilities. So let's just consider the case, just supposed it's zero. Just supposed it's a zero, so that's gonna give me this top row. Well if I just lock the left most bit at zero, then I've got this other two bits at the right of it. But actually we already worked out how many patterns are possible with two bits that might reappear, just four, that's just four patterns. And so if I lock the left most bit at zero there's, then I get four patterns cuz I have zero and then each one of the four patterns for two bits so in this highlighted row that gives me four. So that was the case where the left most bit is zero. What's the other case? The other case is that the left most bit is one and if I lock the left most bit at one. You know I just got those four patterns again like I still have two bits to the right and so I get in a sense another copy of the four patterns that can be made with two bits. So for three bits it works out actually that there eight patterns and I'm thinking of them as kind of like well, there's the four with the left most bit of zero and then there is four again with the left most bit as one. So if you, in general, you can see it here even my little table, for each row, On the next row, you're basically adding a bit to the left and so what that's gonna do is just double the number of patterns that you have in the row above. And so I've run through the math here so with one bit we saw that there were two patterns, just a zero or one. So then when I go to two bits, I get four patterns and three bits, I get eight patterns. But if you just look at the numbers here you can see its doubling. It goes two, four, eight, sixteen so each time I add one bit which I'm thinking sort of going out to left, it doubles the number of patterns I can make. So if we just follow this through, it goes 32, 64, 128 and with eight bits there are 256 different patterns possible. And of cour se eight bits that's the size of a byte, so it works out. One byte can store 256 different patterns. Mathematically in turns out to be exponential so with n bits I can make two to the nth different patterns, Two to the nth power so the case I wanna focus on is one byte. And here's what you need to know. So, one byte is a group of eight bits. And I've sort of gone through the derivation that with eight bits, 256 different patterns are possible. لذلك ، أعتقد أن السؤال الطبيعي هو ، إلى أين ، حسنا ، ما هو الشيء الجيد؟ حقا ما أريد القيام به هو التفكير ، كيف يمكنني استخدام هذه الأنماط لتمثيل أعداد؟ لذا فإن الطريقة التي سأفكر فيها بالأرقام هي أن كل رقم سيحصل عليه 256 من الأنماط المختلفة ، وأنا لن أدخل في تفاصيل حول كيفية ذلك تم تعيينه ولكن كل رقم يحتاج إلى رقم خاص به ولا يمكنه مشاركة نمط مع البعض الآخر رقم. إذاً الطريقة التي أفكر فيها هي مجرد رصاصة. دعونا نعطي بعض النمط ل الرقم صفر. لذلك ، لدينا 256 نمطًا ، وسنمنح أحدها صفرًا ثم سنقدم نمطًا آخر إلى 1 ونمطًا آخر إلى 2 وآخر نمط إلى 3 وهلم جرا. وسنحاول فقط الاستمرار حتى نفد أنماط - رسم. لذلك دعونا نذهب إلى العمل ، فهل لدينا ما يصل إلى 254 ثم النمط الأخير ، نحن تبقى واحدة سنستخدمها للرقم 255 بحيث يكون 255 هو الحد الأقصى القابل للتمثيل الرقم في بايت واحد. أعتقد أنه سيكون هناك سؤال معقول ، حسنًا ، لقد حصلت على 255. لماذا أليس 256 لدينا 256 نمطًا مختلفًا والسبب في ذلك ليس 256 أننا نستخدم نمطًا واحدًا للرقم 0 ، لذا نستخدم هذا النموذج لأعلى ثم إذا كنت فقط عد عدد ، وعدد الأرقام لدي هنا. 255 ستحتاج تتطلب النمط الأخير ؛ رقم النمط 256. لذلك ، تبين إذا كنت تفكر في ما يمكن أن يكون المخزنة في بايت واحد كرقم ، تمثيل العداد هو أن بايت واحد سيتم تخزين الأرقام بين صفر إلى 255. لذا 255 هو الحد الأقصى. لذلك جاء هذا بالفعل في وقت سابق عندما كنا ننظر إلى رمز مثل pixel.setRed وما هو العدد الذي استغرقه؟ يأخذ Pixel.setRed رقماً في النطاق 0-255. لماذا ا؟ لماذا ا؟ والسبب هو يتم تخزين القيمة الحمراء للبكسل في الكمبيوتر في بايت واحد. وذلك بايت يمكن تخزين الأرقام في النطاق 0-255. انها فقط ، هذا كل شيء. لا يمكن تخزينها 300 أو -12 أو أيا كان. لهذا السبب. في هذا ، في هذا المخطط ، يأخذ setRed الأرقام 0-255. إنها تعكس حقيقة أن القيمة الحمراء - وهذا هو صحيح أيضًا بالنسبة للقيم الخضراء والأزرق - يتم تخزين كل واحدة من هذه القيم بواسطة واحدة بايت ثمانية بت ، ولهذا السبب النطاق هو بالضبط صفر إلى 255. إذن ، سر
Really what I wanna do is think about, how can I use those patterns to represent numbers? So the way I'm gonna think about numbers is each number is gonna get one of the 256 different patterns and I'm not gonna get into details of, of how they're assigned but each number needs its own and it can't share a pattern with some other number. So the way when I think about it, is just bullet. Let's give some pattern to number zero. So we, we've got 256 patterns, we'll give one of them to zero and then we'll give another pattern to 1 and another pattern to 2 and another pattern to 3 and so on. And we'll just try to keep going until we run out of patterns. So let's go to work, is we get up to 254 and then the last pattern, we have one left we'll use for the number 255 so 255 will be the maximum representable number in one byte. I think a reasonable question would be, okay I got 255. Why isn't it 256? We have 256 different patterns and the reason it's not 256 is that we use one pattern for number 0. So we use that one up and then if you just count up the number of, the number of numbers I have here. 255 is gonna require the last pattern; pattern number 256. So, turns out if you think of what can be stored in one byte as a number, the counter representation is that one byte will store numbers between zero up to 255. So 255 is the max. So this actually came up earlier when we were looking at code like pixel.setRed and what number did it take? Pixel.setRed takes a number in the range 0-255. Why? Why? And the reason is that the red value for pixel in the computer is stored in one byte. And that byte can store numbers in the range 0-255. It's just, that's it. It cannot store 300 or -12 or whatever. So that's why. In this, in this scheme, setRed takes the numbers 0-255. It actually reflects that the red value - and this is also true for the green and the blue values - each one of those is stored by one eight bit byte and so that's why the range is exactly zero to 255. So, the mystery of the 255. Now you know. |