1 00:00:00,939 --> 00:00:03,285 Ok, daar gaan we. 2 00:00:03,285 --> 00:00:04,702 Dit is een bijzonder moment, 3 00:00:04,702 --> 00:00:08,799 want we gaan nu echt regels code schrijven. 4 00:00:08,799 --> 00:00:10,799 Maar wat is een regel code eigenlijk? 5 00:00:10,799 --> 00:00:12,550 Het is een opdracht aan de computer 6 00:00:12,550 --> 00:00:14,612 Met welke zullen we beginnen? 7 00:00:14,612 --> 00:00:17,647 We beginnen met "teken een rechthoek". 8 00:00:18,017 --> 00:00:21,876 Hoe laat je de computer dit doen? 9 00:00:21,876 --> 00:00:24,039 De computer spreekt een andere taal 10 00:00:25,978 --> 00:00:30,219 dus je gebruikt andere andere woorden. 11 00:00:30,219 --> 00:00:35,772 In dit geval schrijf je "rect". 12 00:00:36,650 --> 00:00:38,999 rect wordt ook wel een "functie" genoemd. 13 00:00:38,999 --> 00:00:44,191 De functie van rect is rechthoeken tekenen. 14 00:00:47,634 --> 00:00:49,635 We moeten nu nog iets specifieker worden 15 00:00:49,635 --> 00:00:50,915 Hoe hoog en hoe breed, 16 00:00:50,915 --> 00:00:54,276 en waar op het scherm 17 00:00:54,276 --> 00:00:58,126 willen we de rechthoek precies plaatsen? 18 00:00:58,126 --> 00:01:04,525 dit zijn dingen die de computer 19 00:01:04,525 --> 00:01:08,672 heel precies wil weten. 20 00:01:08,672 --> 00:01:11,212 Laten we beginnen met de plek 21 00:01:11,555 --> 00:01:13,249 op het scherm. Hoe kun je dingen 22 00:01:13,249 --> 00:01:16,279 daar eigenlijk op plaatsen? 23 00:01:16,279 --> 00:01:17,931 Het scherm voor je neus 24 00:01:17,931 --> 00:01:21,558 is zelf ook een rechthoek. 25 00:01:21,558 --> 00:01:23,089 Net als bij schilderen noemen we 26 00:01:23,401 --> 00:01:29,638 dit oppervlak het "canvas". 27 00:01:31,281 --> 00:01:33,754 Net als bij schaken is er een systeem 28 00:01:33,754 --> 00:01:37,014 van coordinaten. We kunnen bijvoorbeeld 29 00:01:37,014 --> 00:01:40,676 zeggen dat de linker bovenhoek 30 00:01:40,676 --> 00:01:46,532 op punt 16,23 moet beginnen. 31 00:01:47,032 --> 00:01:52,299 Je geeft dingen een plek 32 00:01:52,299 --> 00:01:56,172 op de horizontale (x) of verticale (y) as. 33 00:01:56,172 --> 00:02:01,080 OK, dit is 0, 1 ,2 ,3 ,4, 5, 6, 7, 8, 9 34 00:02:01,080 --> 00:02:02,609 Dus deze zou bij "pixel" 9 beginnen. 35 00:02:02,609 --> 00:02:05,141 Wat bedoel ik met pixel ? 36 00:02:05,141 --> 00:02:09,121 Zoals we in het dagelijks leven centimers 37 00:02:09,121 --> 00:02:12,346 of kilometers hebben, zo meet je afstand op 38 00:02:12,346 --> 00:02:16,348 computerscherm in pixels. 39 00:02:16,348 --> 00:02:20,030 Elke pixel is een gekleurd puntje op het 40 00:02:20,030 --> 00:02:24,517 beeldscherm. Dit venster heeft een breedte 41 00:02:24,517 --> 00:02:29,701 en hoogte in pixels. In deze cursus zal 42 00:02:29,701 --> 00:02:33,838 het venster 500 bij 400 pixels zijn. 43 00:02:33,838 --> 00:02:37,562 Dus als het venster 500 pixels breed is, 44 00:02:37,562 --> 00:02:41,565 hoeveel pixels is het tot het midden? 250! 45 00:02:41,565 --> 00:02:44,828 En waar zit dan verticaal het midden? 46 00:02:44,828 --> 00:02:50,050 Inderdaad, op 200 pixels! 47 00:02:50,050 --> 00:02:53,210 Door aan de rect functie coordinaten 48 00:02:53,210 --> 00:02:56,178 toe te voegen, vertellen we de computer 49 00:02:56,178 --> 00:03:00,052 hoe we de rechthoek willen. 50 00:03:00,052 --> 00:03:02,491 Coordinaten plaatsen we tussen haakjes, 51 00:03:02,491 --> 00:03:04,117 en elke regel eindigen we 52 00:03:05,743 --> 00:03:07,370 met een punt-komma. Dat ziet er 53 00:03:07,370 --> 00:03:12,039 dan zo uit. 54 00:03:12,039 --> 00:03:15,192 In het midden plaatsen we dedetails: 55 00:03:15,192 --> 00:03:17,018 de coordinaten, de breedte en hoogte. 56 00:03:17,018 --> 00:03:21,148 De coordinaten wijzen de 57 00:03:21,148 --> 00:03:25,125 linker-bovenhoek van de rechthoek aan. 58 00:03:25,125 --> 00:03:30,004 De X en Y positie: x = 250, y = 200. 59 00:03:30,004 --> 00:03:34,226 250, 200 60 00:03:34,226 --> 00:03:39,273 Ook de breedte en hoogte geven we aan. 61 00:03:39,273 --> 00:03:40,955 Eerst de breedte. 62 00:03:40,955 --> 00:03:45,678 Laten we 'm 150 bred en 100 hoog maken. 63 00:03:45,678 --> 00:03:55,076 We hebben nu vier getallen ingevuld. 64 00:03:55,540 --> 00:03:57,237 Dit is een bijzonder moment: 65 00:03:57,237 --> 00:04:00,590 je eerste regel computercode ooit 66 00:04:00,590 --> 00:04:05,750 staat nu op het scherm! 67 00:04:05,750 --> 00:04:10,205 Het is een functie met vier "argumenten". 68 00:04:10,205 --> 00:04:11,234 Waar is de rechthoek? 69 00:04:11,234 --> 00:04:14,967 70 00:04:14,967 --> 00:04:17,545 71 00:04:17,545 --> 00:04:20,141 72 00:04:20,141 --> 00:04:23,607 73 00:04:23,607 --> 00:04:27,189 74 00:04:27,189 --> 00:04:29,064 75 00:04:29,064 --> 00:04:32,083 76 00:04:32,083 --> 00:04:34,779 77 00:04:34,779 --> 00:04:36,517 78 00:04:36,517 --> 00:04:37,550 79 00:04:37,550 --> 00:04:39,367 80 00:04:39,367 --> 00:04:42,113 81 00:04:42,113 --> 00:04:44,494 82 00:04:44,494 --> 00:04:50,060 83 00:04:50,060 --> 00:04:51,399 84 00:04:51,399 --> 00:04:55,893 85 00:04:55,893 --> 00:04:58,068 86 00:04:58,068 --> 00:04:59,836 87 00:04:59,836 --> 00:05:04,087 88 00:05:04,087 --> 00:05:07,207 89 00:05:07,207 --> 00:05:09,995 90 00:05:09,995 --> 00:05:12,949 91 00:05:12,949 --> 00:05:16,624 92 00:05:16,624 --> 00:05:19,577 93 00:05:19,577 --> 00:05:22,053 94 00:05:22,053 --> 00:05:23,247 95 00:05:23,247 --> 00:05:25,758 96 00:05:25,758 --> 00:05:27,188 97 00:05:27,188 --> 00:05:29,786 98 00:05:29,786 --> 00:05:33,856 99 00:05:33,856 --> 00:05:36,299 100 00:05:36,299 --> 00:05:39,235 101 00:05:39,235 --> 00:05:41,658 102 00:05:41,658 --> 00:05:45,250 103 00:05:45,250 --> 00:05:48,769 104 00:05:48,769 --> 00:05:51,477 105 00:05:51,477 --> 00:05:54,207 106 00:05:54,611 --> 00:05:57,799 107 00:05:58,096 --> 00:06:02,363 108 00:06:02,363 --> 00:06:07,095 109 00:06:07,343 --> 00:06:08,675 110 00:06:08,675 --> 00:06:11,019 111 00:06:15,948 --> 00:06:17,855 112 00:06:18,262 --> 00:06:21,890 113 00:06:21,890 --> 00:06:25,703 114 00:06:25,703 --> 00:06:28,150 115 00:06:28,150 --> 00:06:29,614 116 00:06:29,614 --> 00:06:32,321 117 00:06:32,321 --> 00:06:35,247 118 00:06:35,247 --> 00:06:37,100 119 00:06:37,100 --> 00:06:39,258 120 00:06:39,258 --> 00:06:40,886 121 00:06:40,886 --> 00:06:44,858 122 00:06:44,858 --> 00:06:48,494 123 00:06:48,494 --> 00:06:50,778 124 00:06:50,778 --> 00:06:54,751 125 00:06:54,751 --> 00:06:58,322 126 00:06:58,322 --> 00:07:00,323 127 00:07:00,323 --> 00:07:03,239 128 00:07:04,087 --> 00:07:09,176 129 00:07:09,176 --> 00:07:12,112 130 00:07:12,112 --> 00:07:14,812 131 00:07:14,812 --> 00:07:20,965 132 00:07:21,714 --> 00:07:22,874 133 00:07:22,874 --> 00:07:27,102 134 00:07:27,102 --> 00:07:32,081 135 00:07:32,081 --> 00:07:36,234 136 00:07:36,584 --> 00:07:39,876 137 00:07:40,470 --> 00:07:44,785 138 00:07:44,785 --> 00:07:50,214 139 00:07:50,522 --> 00:07:52,651 140 00:07:52,901 --> 00:07:57,541 141 00:07:57,541 --> 00:08:02,694 142 00:08:02,694 --> 00:08:08,510 143 00:08:08,510 --> 00:08:15,788 144 00:08:15,788 --> 00:08:19,309 145 00:08:19,309 --> 00:08:21,429 146 00:08:21,429 --> 00:08:24,295 147 00:08:24,295 --> 00:08:29,059 148 00:08:29,059 --> 00:08:30,320 149 00:08:30,320 --> 00:08:31,582 150 00:08:31,582 --> 00:08:33,610 151 00:08:33,610 --> 00:08:35,063 152 00:08:35,063 --> 00:08:38,688 153 00:08:38,688 --> 00:08:42,438 154 00:08:42,438 --> 00:08:46,969 155 00:08:46,969 --> 00:08:51,501 156 00:08:51,501 --> 00:08:54,128 157 00:08:54,128 --> 00:08:57,823 158 00:08:57,823 --> 00:09:00,805 159 00:09:00,805 --> 00:09:04,503 160 00:09:04,503 --> 00:09:07,601 161 00:09:07,601 --> 00:09:10,822 162 00:09:10,822 --> 00:09:14,646 163 00:09:14,646 --> 00:09:17,360 164 00:09:17,360 --> 00:09:20,578 165 00:09:20,578 --> 00:09:22,868 166 00:09:22,868 --> 00:09:23,991 167 00:09:23,991 --> 00:09:28,266 168 00:09:28,266 --> 00:09:32,720 169 00:09:32,720 --> 00:09:34,726 170 00:09:34,726 --> 00:09:37,893 171 00:09:37,893 --> 00:09:40,150 172 00:09:40,150 --> 00:09:42,397 173 00:09:42,397 --> 00:09:45,879 174 00:09:45,879 --> 00:09:48,982 175 00:09:48,982 --> 00:09:54,233 176 00:09:54,233 --> 00:09:55,925