<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LOGO Archives - KarnLab</title>
	<atom:link href="https://karnlab.com/tag/logo/feed/" rel="self" type="application/rss+xml" />
	<link>https://karnlab.com/tag/logo/</link>
	<description>Blog รีวิว หนังสือ เขียนโปรแกรม นานาสาระ</description>
	<lastBuildDate>Mon, 24 Dec 2018 08:38:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://karnlab.com/wp-content/uploads/2017/12/Logo-150x150.png</url>
	<title>LOGO Archives - KarnLab</title>
	<link>https://karnlab.com/tag/logo/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 20 – เคโระปี้</title>
		<link>https://karnlab.com/logo-tutorial-ep20-keroppi/</link>
					<comments>https://karnlab.com/logo-tutorial-ep20-keroppi/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 12:48:10 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[Keroppi]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<category><![CDATA[เคโระปี้]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1317</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปเคโระปี้ (Keroppi) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &#62;_&#60; คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep20-keroppi/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 20 – เคโระปี้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปเคโระปี้ (Keroppi) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &gt;_&lt;</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>หลายตอนที่ผ่านมาเราวาดรูปทั่วไปกันมาเยอะแล้ว ตอนนี้ขอวาดตัวการ์ตูนตามใจผู้เขียนบ้างนะครับ</p>
<p>ข้างล่างนี้คือรูปต้นแบบที่เราต้องการวาดครับ (แต่จะวาดได้เหมือนแค่ไหนนั้น ต้องคอยติดตามครับ)</p>
<figure id="attachment_1280" aria-describedby="caption-attachment-1280" style="width: 310px" class="wp-caption alignnone"><img fetchpriority="high" decoding="async" class="size-full wp-image-1280" src="https://karnlab.com/wp-content/uploads/2018/10/Keroppi.png" alt="Keroppi" width="310" height="310" /><figcaption id="caption-attachment-1280" class="wp-caption-text">Keroppi</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="http://hellokitty.wikia.com/wiki/Keroppi">http://hellokitty.wikia.com/wiki/Keroppi</a></p>
<p>&nbsp;</p>
<p>ก่อนอื่นเราจะเตรียมฟังก์ชันเพื่อให้เราวาดรูปได้ง่ายขึ้นกันก่อนครับ ได้แก่</p>
<ol>
<li>ฟังก์ชัน setpencolor_default ใช้สำหรับเปลี่ยนสีปากการเป็นสีดำ</li>
<li>ฟังก์ชัน paint ใช้สำหรับระบายสี</li>
<li>ฟังก์ชัน comment ใช้สำหรับอธิบายการทำงานของโค้ด</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO comment :message<br />
END</p>
<p>TO setpencolor_default<br />
setpencolor &#8220;#424242<br />
END</p>
<p>TO paint :color<br />
pu rt 45 fd 5 pd<br />
setpencolor :color fill<br />
pu bk 5 lt 45 pd<br />
setpencolor_default<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เริ่มต้นด้วยกำหนดขนาดของปากกาและสีที่จะใช้ครับ</p>
<table>
<tbody>
<tr>
<td width="697">cs<br />
setpensize 3<br />
setpencolor_default</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>จากนั้นวาดส่วนหัวเคโระปี้และตา</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head_1<br />
repeat 30 [ fd 1 rt 1 ]<br />
repeat 30 [ fd 2 rt 1 ]</p>
<p>comment &#8220;eye_1<br />
lt 90<br />
repeat 360 [ fd 0.8 rt 1 ]<br />
pu rt 90 fd 40 lt 90 pd<br />
repeat 360 [ fd 0.4 rt 1 ]<br />
paint &#8220;#424242<br />
pu rt 90 bk 40 lt 90 pd<br />
rt 90</td>
</tr>
</tbody>
</table>
<figure id="attachment_1281" aria-describedby="caption-attachment-1281" style="width: 378px" class="wp-caption alignnone"><img decoding="async" class="size-full wp-image-1281" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP20-Keroppi-1.jpg" alt="LOGO EP20 - Keroppi 1" width="378" height="246" /><figcaption id="caption-attachment-1281" class="wp-caption-text">LOGO EP20 &#8211; Keroppi 1</figcaption></figure>
<p>&nbsp;</p>
<p>วาดตาและหัวส่วนที่เหลือ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;eye_2<br />
pu<br />
repeat 30 [ fd 3 rt 1 ]<br />
repeat 30 [ fd 3 rt 1 ]<br />
pd<br />
rt 90<br />
repeat 360 [ fd 0.8 rt 1 ]<br />
pu rt 90 fd 40 lt 90 pd<br />
repeat 360 [ fd 0.4 rt 1 ]<br />
paint &#8220;#424242<br />
pu rt 90 bk 40 lt 90 pd<br />
lt 90</p>
<p>comment &#8220;head_2<br />
repeat 30 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 1 rt 1 ]</p>
<p>repeat 30 [ fd 1 rt 1 ]<br />
repeat 30 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 3 rt 1 ]</td>
</tr>
</tbody>
</table>
<figure id="attachment_1282" aria-describedby="caption-attachment-1282" style="width: 386px" class="wp-caption alignnone"><img decoding="async" class="size-full wp-image-1282" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP20-Keroppi-2.jpg" alt="LOGO EP20 - Keroppi 2" width="386" height="326" /><figcaption id="caption-attachment-1282" class="wp-caption-text">LOGO EP20 &#8211; Keroppi 2</figcaption></figure>
<p>&nbsp;</p>
<p>จากนั้นเรามาวาดใบหน้าของเคโระปี้กันก่อนครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;face<br />
pu rt 90 fd 20 pd<br />
lt 45<br />
fd 50 bk 50<br />
rt 90<br />
fd 50 bk 50<br />
lt 45<br />
pu bk 20 lt 90 pd</td>
</tr>
</tbody>
</table>
<figure id="attachment_1283" aria-describedby="caption-attachment-1283" style="width: 372px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1283" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP20-Keroppi-3.jpg" alt="LOGO EP20 - Keroppi 3" width="372" height="316" /><figcaption id="caption-attachment-1283" class="wp-caption-text">LOGO EP20 &#8211; Keroppi 3</figcaption></figure>
<p>&nbsp;</p>
<p>วาดส่วนหัวที่เหลือ แล้วระบายสีครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head_3<br />
repeat 30 [ fd 3 rt 1 ]<br />
repeat 30 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 1 rt 1 ]<br />
paint &#8220;#CFD92B</td>
</tr>
</tbody>
</table>
<figure id="attachment_1284" aria-describedby="caption-attachment-1284" style="width: 378px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1284" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP20-Keroppi-4.jpg" alt="LOGO EP20 - Keroppi 4" width="378" height="303" /><figcaption id="caption-attachment-1284" class="wp-caption-text">LOGO EP20 &#8211; Keroppi 4</figcaption></figure>
<p>&nbsp;</p>
<p>สุดท้าย อย่าลืมแก้มของเคโระปี้ครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;cheeks<br />
pu rt 90 fd 20 lt 90 pd<br />
repeat 360 [ fd 0.4 rt 1 ]<br />
paint &#8220;#E24E5E<br />
pu rt 90 fd 180 lt 90 pd<br />
repeat 360 [ fd 0.4 rt 1 ]<br />
paint &#8220;#E24E5E</td>
</tr>
</tbody>
</table>
<figure id="attachment_1285" aria-describedby="caption-attachment-1285" style="width: 369px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1285" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP20-Keroppi-5.jpg" alt="LOGO EP20 - Keroppi 5" width="369" height="310" /><figcaption id="caption-attachment-1285" class="wp-caption-text">LOGO EP20 &#8211; Keroppi 5</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับรูปเคโระปี้ คิดว่าเหมือนรูปต้นฉบับไหมครับ?</p>
<p>Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP20.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP20.txt</a></p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep20-keroppi/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 20 – เคโระปี้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep20-keroppi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 19 – คิตตี้</title>
		<link>https://karnlab.com/logo-tutorial-ep19-kitty/</link>
					<comments>https://karnlab.com/logo-tutorial-ep19-kitty/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 12:43:34 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[Kitty]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[คิตตี้]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1312</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปคิตตี้ (Kitty) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &#62;_&#60; คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep19-kitty/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 19 – คิตตี้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปคิตตี้ (Kitty) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &gt;_&lt;</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>หลายตอนที่ผ่านมาเราวาดรูปทั่วไปกันมาเยอะแล้ว ตอนนี้ขอวาดตัวการ์ตูนตามใจผู้เขียนบ้างนะครับ</p>
<p>ข้างล่างนี้คือรูปต้นแบบที่เราต้องการวาดครับ (แต่จะวาดได้เหมือนแค่ไหนนั้น ต้องคอยติดตามครับ)</p>
<figure id="attachment_1272" aria-describedby="caption-attachment-1272" style="width: 376px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1272" src="https://karnlab.com/wp-content/uploads/2018/10/Hello-Kitty.jpg" alt="Hello Kitty" width="376" height="479" /><figcaption id="caption-attachment-1272" class="wp-caption-text">Hello Kitty</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="http://hellokitty.wikia.com/wiki/Hello_Kitty">http://hellokitty.wikia.com/wiki/Hello_Kitty</a></p>
<p>&nbsp;</p>
<p>ก่อนอื่นเราจะเตรียมฟังก์ชันเพื่อให้เราวาดรูปได้ง่ายขึ้นกันก่อนครับ ได้แก่</p>
<ol>
<li>ฟังก์ชัน setpencolor_default ใช้สำหรับเปลี่ยนสีปากการเป็นสีดำ</li>
<li>ฟังก์ชัน paint ใช้สำหรับระบายสี</li>
<li>ฟังก์ชัน comment ใช้สำหรับอธิบายการทำงานของโค้ด</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO comment :message<br />
END</p>
<p>TO setpencolor_default<br />
setpencolor &#8220;#424242<br />
END</p>
<p>TO paint :color<br />
pu rt 90 fd 5 pd<br />
setpencolor :color fill<br />
pu bk 5 lt 90 pd<br />
setpencolor_default<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เริ่มต้นด้วยกำหนดขนาดของปากกาและสีที่จะใช้ครับ</p>
<table>
<tbody>
<tr>
<td width="697">cs<br />
setpensize 3<br />
setpencolor_default</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>จากนั้นวาดส่วนหัวและหูแมวของน้องคิดตี้</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head_1<br />
repeat 30 [ fd 1 rt 1 ]<br />
repeat 15 [ fd 2 rt 1 ]<br />
lt 45 fd 100 rt 135 fd 90<br />
bk 90 lt 135 bk 100 rt 45<br />
pu<br />
repeat 15 [ fd 2 rt 1 ]<br />
repeat 15 [ fd 3 rt 1 ]<br />
pd<br />
repeat 15 [ fd 3 rt 1 ]</td>
</tr>
</tbody>
</table>
<figure id="attachment_1273" aria-describedby="caption-attachment-1273" style="width: 273px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1273" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-1.jpg" alt="LOGO EP19 - Kitty 1" width="273" height="233" /><figcaption id="caption-attachment-1273" class="wp-caption-text">LOGO EP19 &#8211; Kitty 1</figcaption></figure>
<p>&nbsp;</p>
<p>ส่วนนี้ถ้าเราวาดด้วยมือ มันง่ายมากเลยครับ แต่พอมาเขียนเป็นโปรแกรมแล้ว มันไม่ง่ายเลย T^T</p>
<p>วาดส่วนหัวและหูแมวที่เหลือของน้องคิดตี้กันต่อครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head_2<br />
repeat 15 [ fd 3 rt 1 ]<br />
lt 50 fd 100 rt 135 fd 90<br />
bk 90 lt 135 bk 100 rt 50<br />
pu fd 40 lt 70 pd<br />
pu rt 70 bk 40 pd<br />
pu<br />
repeat 15 [ fd 3 rt 1 ]<br />
repeat 15 [ fd 2 rt 1 ]<br />
pd<br />
repeat 15 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 1 rt 1 ]</td>
</tr>
</tbody>
</table>
<figure id="attachment_1274" aria-describedby="caption-attachment-1274" style="width: 375px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1274" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-2.jpg" alt="LOGO EP19 - Kitty 2" width="375" height="258" /><figcaption id="caption-attachment-1274" class="wp-caption-text">LOGO EP19 &#8211; Kitty 2</figcaption></figure>
<p>&nbsp;</p>
<p>แต่น้องคิดตี้มีโบว์สีแดงด้วยนี่หน่า!? งั้นเรามาเพิ่มโบว์ให้น้องคิดตี้กันครับ (เพิ่มฟังก์ชัน bow และแก้ไขโค้ดเมื่อกี้เล็กน้อย)</p>
<table>
<tbody>
<tr>
<td width="697">TO bow<br />
rt 60 fd 75<br />
rt 120 fd 75<br />
rt 120 fd 150<br />
lt 120 fd 75<br />
lt 120 fd 75<br />
lt 60<br />
paint &#8220;#EC193A<br />
rt 180 paint &#8220;#EC193A<br />
pu rt 90 fd 40 pd paint &#8220;#EC193A<br />
pu bk 40 lt 90 rt 180 pd<br />
END</p>
<p>comment &#8220;head_2<br />
repeat 15 [ fd 3 rt 1 ]<br />
lt 50 fd 100 rt 135 fd 90<br />
bk 90 lt 135 bk 100 rt 50<br />
pu fd 40 lt 70 pd<br />
<strong>bow</strong><br />
pu rt 70 bk 40 pd<br />
pu<br />
repeat 15 [ fd 3 rt 1 ]<br />
repeat 15 [ fd 2 rt 1 ]<br />
pd<br />
repeat 15 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 1 rt 1 ]</td>
</tr>
</tbody>
</table>
<figure id="attachment_1275" aria-describedby="caption-attachment-1275" style="width: 405px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1275" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-3.jpg" alt="LOGO EP19 - Kitty 3" width="405" height="263" /><figcaption id="caption-attachment-1275" class="wp-caption-text">LOGO EP19 &#8211; Kitty 3</figcaption></figure>
<p>&nbsp;</p>
<p>วาดใบหน้าส่วนที่เหลือ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head_3<br />
repeat 30 [ fd 1 rt 1 ]<br />
repeat 30 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 3 rt 1 ]<br />
repeat 30 [ fd 3 rt 1 ]<br />
repeat 30 [ fd 2 rt 1 ]<br />
repeat 30 [ fd 1 rt 1 ]</td>
</tr>
</tbody>
</table>
<figure id="attachment_1276" aria-describedby="caption-attachment-1276" style="width: 398px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1276" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-4.jpg" alt="LOGO EP19 - Kitty 4" width="398" height="334" /><figcaption id="caption-attachment-1276" class="wp-caption-text">LOGO EP19 &#8211; Kitty 4</figcaption></figure>
<p>&nbsp;</p>
<p>เพิ่มหนวดแมวให้น้องคิตตี้</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;whiskers_1<br />
pu rt 90 fd 150 pd<br />
pu fd 100 pd<br />
fd 50 bk 50<br />
lt 30 fd 50 bk 50<br />
rt 60 fd 50 bk 50<br />
lt 30<br />
pu bk 100 pd<br />
pu bk 150 lt 90 pd</p>
<p>comment &#8220;whiskers_2<br />
pu rt 90 fd 20 pd<br />
rt 180<br />
fd 50 bk 50<br />
lt 30 fd 50 bk 50<br />
rt 60 fd 50 bk 50<br />
lt 30<br />
rt 180<br />
pu bk 20 lt 90 pd</td>
</tr>
</tbody>
</table>
<figure id="attachment_1277" aria-describedby="caption-attachment-1277" style="width: 404px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1277" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-5.jpg" alt="LOGO EP19 - Kitty 5" width="404" height="322" /><figcaption id="caption-attachment-1277" class="wp-caption-text">LOGO EP19 &#8211; Kitty 5</figcaption></figure>
<p>&nbsp;</p>
<p>สุดท้ายวาดใบหน้าให้น้องคิตตี้ครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;face<br />
pu rt 90 fd 125 pd<br />
lt 90<br />
repeat 360 [ fd 0.2 rt 1 ]<br />
paint &#8220;#FFD601<br />
pu fd 30 lt 90 fd 45 rt 90 pd<br />
repeat 360 [ fd 0.2 rt 1 ]<br />
paint &#8220;#424242<br />
pu rt 90 fd 90 lt 90 pd<br />
repeat 360 [ fd 0.2 rt 1 ]<br />
paint &#8220;#424242</td>
</tr>
</tbody>
</table>
<figure id="attachment_1278" aria-describedby="caption-attachment-1278" style="width: 418px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1278" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP19-Kitty-6.jpg" alt="LOGO EP19 - Kitty 6" width="418" height="316" /><figcaption id="caption-attachment-1278" class="wp-caption-text">LOGO EP19 &#8211; Kitty 6</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับรูปคิตตี้ คิดว่าเหมือนรูปต้นฉบับไหมครับ?</p>
<p>Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP19.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP19.txt</a></p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep19-kitty/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 19 – คิตตี้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep19-kitty/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 18 – โดราเอมอน</title>
		<link>https://karnlab.com/logo-tutorial-ep18-doraemon/</link>
					<comments>https://karnlab.com/logo-tutorial-ep18-doraemon/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 12:38:03 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[Doraemon]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<category><![CDATA[โดราเอมอน]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1306</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปโดราเอมอน (Doraemon) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &#62;_&#60; คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep18-doraemon/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 18 – โดราเอมอน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปโดราเอมอน (Doraemon) ด้วยภาษาโลโก้กันครับ (เย้ๆๆ) โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ รูปนี้อาจจะยากสักหน่อย แต่ถ้าเราอดทนและพยายาม ก็ไม่มีอะไรยากเกินความสามารถของเราหรอกครับ &gt;_&lt;</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>หลายตอนที่ผ่านมาเราวาดรูปทั่วไปกันมาเยอะแล้ว ตอนนี้ขอวาดตัวการ์ตูนตามใจผู้เขียนบ้างนะครับ</p>
<p>ข้างล่างนี้คือรูปต้นแบบที่เราต้องการวาดครับ (แต่จะวาดได้เหมือนแค่ไหนนั้น ต้องคอยติดตามครับ)</p>
<figure id="attachment_1266" aria-describedby="caption-attachment-1266" style="width: 800px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1266" src="https://karnlab.com/wp-content/uploads/2018/10/Doraemon.jpg" alt="Doraemon" width="800" height="448" /><figcaption id="caption-attachment-1266" class="wp-caption-text">Doraemon</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="http://doraemon.wikia.com">http://doraemon.wikia.com</a></p>
<p>ก่อนอื่นเราจะเตรียมฟังก์ชันเพื่อให้เราวาดรูปได้ง่ายขึ้นกันก่อนครับ ได้แก่</p>
<ol>
<li>ฟังก์ชัน setpencolor_default ใช้สำหรับเปลี่ยนสีปากการเป็นสีดำ</li>
<li>ฟังก์ชัน paint ใช้สำหรับระบายสี</li>
<li>ฟังก์ชัน comment ใช้สำหรับอธิบายการทำงานของโค้ด</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO comment :message<br />
END</p>
<p>TO setpencolor_default<br />
setpencolor &#8220;#424242<br />
END</p>
<p>TO paint :color<br />
pu fd 15 pd<br />
setpencolor :color fill<br />
pu bk 15 pd<br />
setpencolor_default<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เริ่มต้นด้วยกำหนดขนาดของปากกาและสีที่จะใช้ครับ</p>
<table>
<tbody>
<tr>
<td width="697">cs<br />
setpensize 3<br />
setpencolor_default</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>จากนั้นวาดส่วนหัวโดราเอมอน</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;head<br />
arc 360 120<br />
paint &#8220;#00A8D8<br />
pu bk 20 pd<br />
arc 360 100<br />
paint &#8220;#FFFFFF</td>
</tr>
</tbody>
</table>
<figure id="attachment_1267" aria-describedby="caption-attachment-1267" style="width: 327px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1267" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP18-Doraemon-1.jpg" alt="LOGO EP18 - Doraemon 1" width="327" height="306" /><figcaption id="caption-attachment-1267" class="wp-caption-text">LOGO EP18 &#8211; Doraemon 1</figcaption></figure>
<p>&nbsp;</p>
<p>วาดใบหน้าของโดราเอมอน</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;face<br />
pu fd 50 pd<br />
arc 360 17<br />
paint &#8220;#D20024<br />
pu bk 15 pd<br />
bk 50<br />
rt 120 arc 120 60 lt 120<br />
bk 60</td>
</tr>
</tbody>
</table>
<figure id="attachment_1268" aria-describedby="caption-attachment-1268" style="width: 327px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1268" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP18-Doraemon-2.jpg" alt="LOGO EP18 - Doraemon 2" width="327" height="310" /><figcaption id="caption-attachment-1268" class="wp-caption-text">LOGO EP18 &#8211; Doraemon 2</figcaption></figure>
<p>&nbsp;</p>
<p>วาดหนวดของโดราเอมอน</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;whiskers_1<br />
pu fd 75 pd<br />
rt 70 pu fd 30 pd fd 60<br />
pu bk 90 pd<br />
rt 20 pu fd 30 pd fd 60<br />
pu bk 90 pd<br />
rt 20 pu fd 30 pd fd 60<br />
pu bk 90 pd</p>
<p>comment &#8220;whiskers_2<br />
rt 140 pu fd 30 pd fd 60<br />
pu bk 90 pd<br />
rt 20 pu fd 30 pd fd 60<br />
pu bk 90 pd<br />
rt 20 pu fd 30 pd fd 60<br />
pu bk 90 pd<br />
rt 70</td>
</tr>
</tbody>
</table>
<figure id="attachment_1269" aria-describedby="caption-attachment-1269" style="width: 341px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1269" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP18-Doraemon-3.jpg" alt="LOGO EP18 - Doraemon 3" width="341" height="324" /><figcaption id="caption-attachment-1269" class="wp-caption-text">LOGO EP18 &#8211; Doraemon 3</figcaption></figure>
<p>&nbsp;</p>
<p>ต่อไปเราจะวาดตาของโดราเอมอนครับ ซึ่งส่วนนี้วาดยากพอสมควร (แถมหาตำแหน่งวาดตายากด้วย) จึงต้องเขียนเป็นฟังก์ชันแยกมาต่างหาก</p>
<table>
<tbody>
<tr>
<td width="697">TO eye<br />
lt 90<br />
repeat 2 [<br />
repeat 30 [ fd 0.25 rt 1 ]<br />
repeat 30 [ fd 0.50 rt 1 ]<br />
repeat 30 [ fd 0.75 rt 1 ]<br />
repeat 30 [ fd 0.75 rt 1 ]<br />
repeat 30 [ fd 0.50 rt 1 ]<br />
repeat 30 [ fd 0.25 rt 1 ]<br />
]<br />
rt 90 pu fd 15 pd paint &#8220;#FFFFFF<br />
pu lt 90 pd<br />
repeat 2 [<br />
repeat 30 [ fd 0.1 rt 1 ]<br />
repeat 30 [ fd 0.2 rt 1 ]<br />
repeat 30 [ fd 0.3 rt 1 ]<br />
repeat 30 [ fd 0.3 rt 1 ]<br />
repeat 30 [ fd 0.2 rt 1 ]<br />
repeat 30 [ fd 0.1 rt 1 ]<br />
]<br />
rt 90 paint &#8220;#424242<br />
pu bk 15 lt 90 pd<br />
rt 90<br />
END</p>
<p>comment &#8220;eyes<br />
pu fd 70 lt 90 fd 30 rt 90 pd<br />
eye<br />
pu rt 90 fd 60 lt 90 pd<br />
eye</td>
</tr>
</tbody>
</table>
<figure id="attachment_1270" aria-describedby="caption-attachment-1270" style="width: 340px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1270" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP18-Doraemon-4.jpg" alt="LOGO EP18 - Doraemon 4" width="340" height="319" /><figcaption id="caption-attachment-1270" class="wp-caption-text">LOGO EP18 &#8211; Doraemon 4</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับรูปโดราเอมอน คิดว่าเหมือนรูปต้นฉบับไหมครับ?</p>
<p>Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP18.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP18.txt</a></p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep18-doraemon/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 18 – โดราเอมอน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep18-doraemon/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 17 – จักรยาน</title>
		<link>https://karnlab.com/logo-tutorial-ep17-bike/</link>
					<comments>https://karnlab.com/logo-tutorial-ep17-bike/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 12:03:33 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[จักรยาน]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1301</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปจักรยาน ด้วยภาษาโลโก้กันครับ โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ โดยเราจะวาดรูปไปทีละองค์ประกอบ (component) จนสำเร็จเป็นรูปที่เราต้องการครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง forward [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep17-bike/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 17 – จักรยาน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปจักรยาน ด้วยภาษาโลโก้กันครับ โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ โดยเราจะวาดรูปไปทีละองค์ประกอบ (component) จนสำเร็จเป็นรูปที่เราต้องการครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เราจะมาดูรูปต้นแบบที่เราจะวาดกันก่อนครับ ซึ่งก็คือจักรยานสี่น้ำเงินยี่ห้อหนึ่ง จะสังเกตได้ว่าจักรยานมีรายละเอียดเยอะพอสมควร แต่เราจะวาดเฉพาะส่วนที่สำคัญ ที่เมื่อใครๆ มาเห็นรูปของเราก็ต้องดูออกว่าเป็นจักรยานครับ</p>
<figure id="attachment_1265" aria-describedby="caption-attachment-1265" style="width: 1000px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1265" src="https://karnlab.com/wp-content/uploads/2018/10/Bicycle-Prototype.jpg" alt="Bicycle Prototype" width="1000" height="597" /><figcaption id="caption-attachment-1265" class="wp-caption-text">Bicycle Prototype</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="https://www.mec.ca">https://www.mec.ca</a></p>
<p>&nbsp;</p>
<p>เรามาเริ่มเขียนโปรแกรมกันเลยครับ โดยตั้งค่าขนาดปากกา และกำหนดสีที่จะใช้กันก่อน</p>
<table>
<tbody>
<tr>
<td width="697">TO comment :message<br />
END</p>
<p>cs<br />
setpensize 5<br />
setpencolor &#8220;#303f9f</td>
</tr>
</tbody>
</table>
<p>(ฟังก์ชัน comment ไม่ได้ใช้วาดรูปอะไร แต่เป็น dummy function เพื่อให้เราสามารถเพิ่มคำอธิบายเข้าไปในโค้ดได้ครับ)</p>
<p>&nbsp;</p>
<p>วาดโครงจักรยาน (1)</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;body_1<br />
rt 30 fd 100<br />
rt 60 fd 100<br />
rt 120 fd 100<br />
rt 60 fd 100</td>
</tr>
</tbody>
</table>
<figure id="attachment_1258" aria-describedby="caption-attachment-1258" style="width: 334px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1258" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-1.jpg" alt="LOGO EP17 - Bicycle 1" width="334" height="247" /><figcaption id="caption-attachment-1258" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 1</figcaption></figure>
<p>&nbsp;</p>
<p>วาดโครงจักรยาน (2)</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;body_2<br />
bk 100<br />
rt 60 fd 125<br />
lt 60 fd 25<br />
rt 90 fd 15<br />
rt 90 fd 50<br />
rt 90 fd 15<br />
rt 90 fd 25</td>
</tr>
</tbody>
</table>
<figure id="attachment_1259" aria-describedby="caption-attachment-1259" style="width: 325px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1259" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-2.jpg" alt="LOGO EP17 - Bicycle 2" width="325" height="258" /><figcaption id="caption-attachment-1259" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 2</figcaption></figure>
<p>&nbsp;</p>
<p>วาดโครงจักรยาน (3)</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;body_3<br />
rt 60 bk 125<br />
pu lt 60 bk 100 pd<br />
rt 60 fd 145<br />
arc 360 10</td>
</tr>
</tbody>
</table>
<figure id="attachment_1260" aria-describedby="caption-attachment-1260" style="width: 391px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1260" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-3.jpg" alt="LOGO EP17 - Bicycle 3" width="391" height="265" /><figcaption id="caption-attachment-1260" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 3</figcaption></figure>
<p>&nbsp;</p>
<p>วาดล้อ (1)</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;wheel_1<br />
bk 145<br />
setpencolor &#8220;#424242<br />
arc 360 50</td>
</tr>
</tbody>
</table>
<figure id="attachment_1261" aria-describedby="caption-attachment-1261" style="width: 376px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1261" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-4.jpg" alt="LOGO EP17 - Bicycle 4" width="376" height="277" /><figcaption id="caption-attachment-1261" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 4</figcaption></figure>
<p>&nbsp;</p>
<p>วาดล้อ (2)</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;wheel_2<br />
pu lt 60 fd 200 pd<br />
arc 360 50</td>
</tr>
</tbody>
</table>
<figure id="attachment_1262" aria-describedby="caption-attachment-1262" style="width: 403px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1262" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-5.jpg" alt="LOGO EP17 - Bicycle 5" width="403" height="274" /><figcaption id="caption-attachment-1262" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 5</figcaption></figure>
<p>&nbsp;</p>
<p>วาดเกียร์</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;wheel_3<br />
bk 100<br />
arc 360 25</td>
</tr>
</tbody>
</table>
<figure id="attachment_1263" aria-describedby="caption-attachment-1263" style="width: 397px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1263" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP17-Bicycle-6.jpg" alt="LOGO EP17 - Bicycle 6" width="397" height="263" /><figcaption id="caption-attachment-1263" class="wp-caption-text">LOGO EP17 &#8211; Bicycle 6</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ รูปจักรยาน ถ้าเราลองลดความซับซ้อนของรูปภาพ แล้ววาดแค่ส่วนสำคัญของภาพ เราก็จะได้รูปภาพที่เราต้องการเร็วขึ้นครับ (render เร็วขึ้น)</p>
<p>Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP17.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP17.txt</a></p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep17-bike/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 17 – จักรยาน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep17-bike/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 16 – รถยนต์</title>
		<link>https://karnlab.com/logo-tutorial-ep16-car/</link>
					<comments>https://karnlab.com/logo-tutorial-ep16-car/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 11:56:46 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[รถยนต์]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1296</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปรถยนต์ ด้วยภาษาโลโก้กันครับ โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ ระหว่างวาดรูปอาจจะมีข้อผิดพลาดบ้าง แต่เราจะแก้ไขข้อผิดพลาดนั้นได้อย่างไร มาติดตามกันดูได้เลยครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง forward [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep16-car/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 16 – รถยนต์</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปรถยนต์ ด้วยภาษาโลโก้กันครับ โดยในตอนนี้เราจะดูแบบที่ต้องการวาดก่อน แล้วค่อยๆ วาดรูปไปพร้อมๆ กันครับ ระหว่างวาดรูปอาจจะมีข้อผิดพลาดบ้าง แต่เราจะแก้ไขข้อผิดพลาดนั้นได้อย่างไร มาติดตามกันดูได้เลยครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เราจะมาดูรูปต้นแบบที่เราจะวาดกันก่อนครับ ซึ่งก็คือ Mini Cooper สีแดง เดี๋ยวเราจะมาลองวาดกันดูเลยครับ</p>
<figure id="attachment_1248" aria-describedby="caption-attachment-1248" style="width: 726px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1248" src="https://karnlab.com/wp-content/uploads/2018/10/Mini-Cooper-Red-Car.jpg" alt="Mini Cooper Red Car" width="726" height="545" /><figcaption id="caption-attachment-1248" class="wp-caption-text">Mini Cooper Red Car</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="https://bay2car.com/">https://bay2car.com/</a></p>
<p>&nbsp;</p>
<p>ก่อนอื่นเราจะเตรียมฟังก์ชันที่จะทำให้เราวาดรูปได้ง่ายขึ้นกันก่อนครับ</p>
<ol>
<li>ฟังก์ชัน setpencolor_default ใช้สำหรับเปลี่ยนสีปากการเป็นสีดำ</li>
<li>ฟังก์ชัน paint ใช้สำหรับระบายสี</li>
<li>ฟังก์ชัน comment ใช้สำหรับอธิบายการทำงานของโค้ด</li>
</ol>
<p>ฟังก์ชัน comment นี้น่าสนใจครับ ต้องอธิบายก่อนว่า ภาษาเขียนโปรแกรมโดยทั่วไปจะมีไวยกรณ์ (syntax) comment เพื่ออธิบายการทำงานของโค้ดเป็นภาษามนุษย์ ทำให้เวลาเรากลับมาอ่านโค้ดในภายหลัง เราก็จะเข้าใจได้ง่ายขึ้นว่าโค้ดส่วนนี้ทำหน้าที่อะไร</p>
<p>แต่เนื่องจากภาษาโลโก้ไม่มี syntax comment ดังนั้น เราก็เลยสร้างฟังก์ชัน comment เพื่อใช้เขียนอธิบายโค้ดครับ โดยในฟังก์ชันนี้ไม่ต้องทำอะไรครับ (ถ้ายังไม่เข้าใจ เดี๋ยวจะเห็นประโยชน์ของฟังก์ชันนี้ในตัวอย่างถัดไปครับ)</p>
<table>
<tbody>
<tr>
<td width="697">TO setpencolor_default<br />
setpencolor &#8220;#9E9E9E<br />
END</p>
<p>TO paint :color<br />
pu rt 45 fd 10 pd<br />
setpencolor :color fill<br />
pu bk 10 lt 45 pd<br />
setpencolor_default<br />
END</p>
<p>TO comment :message<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>โอเคครับ เราจะมาเริ่มวาดรถยนต์กันเลยครับ</p>
<table>
<tbody>
<tr>
<td width="697">cs<br />
setpencolor_default<br />
pu setxy -200 -100 pd</p>
<p>comment &#8220;body<br />
fd 75<br />
rt 30 fd 100<br />
rt 60 fd 200<br />
rt 60 fd 100<br />
lt 60 fd 50<br />
rt 90 fd 75<br />
rt 90 fd 350<br />
rt 90<br />
paint &#8220;#d32f2f</td>
</tr>
</tbody>
</table>
<figure id="attachment_1249" aria-describedby="caption-attachment-1249" style="width: 459px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1249" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-1.jpg" alt="LOGO EP16 - Car 1" width="459" height="262" /><figcaption id="caption-attachment-1249" class="wp-caption-text">LOGO EP16 &#8211; Car 1</figcaption></figure>
<p>* จะสังเกตว่า คำสั่ง comment “body ไม่ได้ทำหน้าที่วาดรูปอะไรเลยครับ แต่มันจะช่วยให้เข้าใจได้ง่ายขึ้นว่า โค้ดดังต่อไปนี้คือการวาดตัวรถยนต์ (body)</p>
<p>&nbsp;</p>
<p>จากนั้นเราจะวาดล้อรถยนต์กันครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;wheel_1<br />
pu rt 90 fd 120 rt 90 pd<br />
repeat 360 [ fd 0.75 rt 1 ]<br />
paint &#8220;#212121<br />
rt 90 fd 15 lt 90<br />
repeat 360 [ fd 0.5 rt 1 ]<br />
paint &#8220;#9E9E9E<br />
rt 90 bk 15 lt 90</td>
</tr>
</tbody>
</table>
<figure id="attachment_1250" aria-describedby="caption-attachment-1250" style="width: 442px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1250" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-2.jpg" alt="LOGO EP16 - Car 2" width="442" height="273" /><figcaption id="caption-attachment-1250" class="wp-caption-text">LOGO EP16 &#8211; Car 2</figcaption></figure>
<p>&nbsp;</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;wheel_2<br />
pu lt 90 fd 180 rt 90 pd<br />
repeat 360 [ fd 0.75 rt 1 ]<br />
paint &#8220;#212121<br />
rt 90 fd 15 lt 90<br />
repeat 360 [ fd 0.5 rt 1 ]<br />
paint &#8220;#9E9E9E<br />
rt 90 bk 15 lt 90</td>
</tr>
</tbody>
</table>
<figure id="attachment_1251" aria-describedby="caption-attachment-1251" style="width: 444px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1251" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-3.jpg" alt="LOGO EP16 - Car 3" width="444" height="275" /><figcaption id="caption-attachment-1251" class="wp-caption-text">LOGO EP16 &#8211; Car 3</figcaption></figure>
<p>&nbsp;</p>
<p>ต่อไปเราจะมาส่วนของหน้าต่างกันครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;window_1<br />
pu lt 90 bk 300 lt 90 pd<br />
pu fd 20 rt 90 fd 20 lt 90 pd<br />
pu fd 55 pd<br />
rt 30 fd 80<br />
rt 60 fd 100<br />
rt 90 fd 60<br />
rt 90 fd 120<br />
rt 120<br />
paint &#8220;#00bcd4</td>
</tr>
</tbody>
</table>
<figure id="attachment_1252" aria-describedby="caption-attachment-1252" style="width: 442px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1252" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-4.jpg" alt="LOGO EP16 - Car 4" width="442" height="269" /><figcaption id="caption-attachment-1252" class="wp-caption-text">LOGO EP16 &#8211; Car 4</figcaption></figure>
<p>&nbsp;</p>
<p>เอ๊ะ! เหมือนว่ารูปภาพที่ได้จะมีปัญหา เนื่องจากสัดส่วนของหน้าต่างไม่พอดี ลองแก้ไขโค้ดส่วนของหน้าต่างกันใหม่ครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;window_1<br />
pu lt 90 bk 300 lt 90 pd<br />
pu fd 20 rt 90 fd 20 lt 90 pd<br />
pu fd 55 pd<br />
rt 30 fd 80<br />
<strong>rt 60 fd 80</strong><br />
<strong>rt 90 fd 65</strong><br />
rt 90 fd 120<br />
rt 120<br />
paint &#8220;#00bcd4</td>
</tr>
</tbody>
</table>
<figure id="attachment_1253" aria-describedby="caption-attachment-1253" style="width: 443px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1253" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-5.jpg" alt="LOGO EP16 - Car 5" width="443" height="275" /><figcaption id="caption-attachment-1253" class="wp-caption-text">LOGO EP16 &#8211; Car 5</figcaption></figure>
<p>&nbsp;</p>
<p>เนื่องจากเราค่อยๆ เขียนโค้ด และทยอย run เพื่อดูรูปภาพไปทีและส่วน ดังนั้น เมื่อเกิดปัญหา เราจึงทราบว่าปัญหาเกิดจากจุดไหน และสามารถแก้ไขได้อย่างรวดเร็วครับ (ฝากถึงน้องๆ เช่นกันว่าเวลาเขียนโปรแกรมใหญ่ๆ ค่อยๆ code ค่อยๆ run นะครับ จะได้หา bug ได้ง่าย อย่าเขียน code ยาวๆ แล้ว run ทีเดียว มันจะหา bug ยาก)</p>
<p>ต่อไปเราจะวาดหน้าต่างที่เหลืออีกหนึ่งบานครับ</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;window_2<br />
pu rt 60 fd 140 lt 90 pd<br />
fd 65<br />
rt 90 fd 80<br />
rt 60 fd 80<br />
rt 120 fd 120<br />
rt 90<br />
paint &#8220;#00bcd4</td>
</tr>
</tbody>
</table>
<figure id="attachment_1254" aria-describedby="caption-attachment-1254" style="width: 442px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1254" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-6.jpg" alt="LOGO EP16 - Car 6" width="442" height="282" /><figcaption id="caption-attachment-1254" class="wp-caption-text">LOGO EP16 &#8211; Car 6</figcaption></figure>
<p>&nbsp;</p>
<p>เอ๊ะ! รูปภาพที่ได้มีปัญหาอีกแล้ว แม้ดูเหมือนว่ารูปของเราไม่น่าจะมีอะไรผิดพลาด ถ้าเราสังเกตดีๆ จะพบว่าหน้าต่างที่เพิ่งเพิ่มเข้าไป สี่เหลี่ยมยังปิดไม่สนิท ดังนั้น ถ้าเราแก้ไขตัวเลขอีกนิดก็น่าจะพอดีแล้ว</p>
<table>
<tbody>
<tr>
<td width="697">comment &#8220;window_2<br />
pu rt 60 fd 140 lt 90 pd<br />
fd 65<br />
rt 90 fd 80<br />
rt 60 fd 75<br />
rt 120 fd 120<br />
rt 90<br />
paint &#8220;#00bcd4</td>
</tr>
</tbody>
</table>
<figure id="attachment_1255" aria-describedby="caption-attachment-1255" style="width: 440px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1255" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP16-Car-7.jpg" alt="LOGO EP16 - Car 7" width="440" height="277" /><figcaption id="caption-attachment-1255" class="wp-caption-text">LOGO EP16 &#8211; Car 7</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับรูปรถยนต์ที่เราต้องการ Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP16.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP16.txt</a></p>
<p>เป็นอย่างไรกันบ้างครับสำหรับการวาดรูปรถยนต์ จะสังเกตได้ว่าถ้าเราวาดรูปโดยค่อยๆ วาด ค่อยๆ รัน เวลาเกิดปัญหา จะทำให้เราสามารถพบจุดที่มีปัญหา และแก้ไขได้อย่างรวดเร็วครับ</p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep16-car/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 16 – รถยนต์</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep16-car/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 15 – รถไฟ</title>
		<link>https://karnlab.com/logo-tutorial-ep15-train/</link>
					<comments>https://karnlab.com/logo-tutorial-ep15-train/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 11:46:42 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[รถไฟ]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1287</guid>

					<description><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปรถไฟ ด้วยภาษาโลโก้กันครับ โดยในตอนนี้ก่อนที่จะวาดรูป เราจะวางแผนก่อนว่ารูปของเรามีองค์ประกอบ (component) อะไรบ้าง จากนั้นก็วาดแต่ละ component ให้เสร็จ แล้วนำทั้งหมดมาประกอบเป็นรูปภาพที่ต้องการครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep15-train/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 15 – รถไฟ</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับ วันนี้เราจะมาวาดรูปรถไฟ ด้วยภาษาโลโก้กันครับ โดยในตอนนี้ก่อนที่จะวาดรูป เราจะวางแผนก่อนว่ารูปของเรามีองค์ประกอบ (component) อะไรบ้าง จากนั้นก็วาดแต่ละ component ให้เสร็จ แล้วนำทั้งหมดมาประกอบเป็นรูปภาพที่ต้องการครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เราจะมาดูแบบที่เราจะวาดกันก่อนครับ เราจะเห็นได้ว่ารถไฟจะมีส่วนประกอบหลัก 2 ส่วน คือ หัวรถไฟ และ ตู้รถไฟ ในที่นี้ขอเรียกง่ายๆ ว่า Head และ Body นะครับ</p>
<figure id="attachment_1237" aria-describedby="caption-attachment-1237" style="width: 800px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1237" src="https://karnlab.com/wp-content/uploads/2018/10/Train-with-Cargo.jpg" alt="Train with Cargo" width="800" height="535" /><figcaption id="caption-attachment-1237" class="wp-caption-text">Train with Cargo</figcaption></figure>
<p>รูปภาพจาก &#8211; <a href="https://standardmedia.co.ke/">https://standardmedia.co.ke/</a></p>
<p>&nbsp;</p>
<p>โดยรถไฟที่เราจะวาดกันจะมีองค์ประกอบ (component) คือ หัวรถไฟ อยู่ทางขวามือ และ ตู้รถไฟ อีก 3 ตู้ ดังรูปด้านล่างครับ</p>
<figure id="attachment_1238" aria-describedby="caption-attachment-1238" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1238" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-1.jpg" alt="LOGO EP15 - Train 1" width="1366" height="307" /><figcaption id="caption-attachment-1238" class="wp-caption-text">LOGO EP15 &#8211; Train 1</figcaption></figure>
<p>แนวทางในการวาดรถไฟของเราคือ</p>
<ol>
<li>เตรียมฟังก์ชันที่จำเป็นก่อน</li>
<li>สร้างฟังก์ชัน Body สำหรับวาด ตู้รถไฟ</li>
<li>สร้างฟังก์ชัน Head สำหรับวาด หัวรถไฟ</li>
<li>นำฟังก์ชัน Head และ Body มาประกอบกันเป็นขบวนรถไฟ</li>
</ol>
<p>&nbsp;</p>
<h2><strong>เริ่มต้นเราจะเตรียมฟังก์ชันที่จำเป็นก่อน </strong></h2>
<ol>
<li>เราจะเตรียมฟังก์ชันวาดรูปร่างพื้นฐานกันก่อน ได้แก่ สี่เหลี่ยมผืนผ้า (rectangle) สี่เหลี่ยมจัตุรัส (square) วงกลม (circle)</li>
</ol>
<table>
<tbody>
<tr>
<td width="312">TO rectangle <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :y<br />
fd <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> rt 90<br />
fd :y rt 90<br />
fd <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> rt 90<br />
fd :y rt 90<br />
ENDTO square <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
repeat 4 [ fd <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> rt 90 ]<br />
ENDTO circle <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
repeat 360 [ fd  <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f621.png" alt="😡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> rt 1 ]<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<ol start="2">
<li>นอกจากนี้ เราจะเตรียมฟังก์ชันสำหรับลงสี โดยฟังก์ชัน setpencolor_default ไว้สำหรับเปลี่ยนสีปากกาเป็นสีดำ และ ฟังก์ชัน paint ไว้สำหรับลงสีที่ต้องการครับ</li>
</ol>
<table>
<tbody>
<tr>
<td width="312">TO setpencolor_default<br />
setpencolor &#8220;#9E9E9E<br />
END</p>
<p>TO paint :color<br />
pu rt 45 fd 10 pd<br />
setpencolor :color fill<br />
pu bk 10 lt 45 pd<br />
setpencolor_default<br />
END</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2><strong>สร้างฟังก์ชัน Body สำหรับวาดตู้รถไฟ</strong></h2>
<ol>
<li>เริ่มต้นการสร้างฟังก์ชัน Body ด้วยการวาดรูปสี่เหลี่ยมผืนผ้าก่อนเลย</li>
</ol>
<table>
<tbody>
<tr>
<td width="312">TO body<br />
rt 90<br />
rectangle 200 100<br />
END</p>
<p>cs body</td>
</tr>
</tbody>
</table>
<figure id="attachment_1239" aria-describedby="caption-attachment-1239" style="width: 359px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1239" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-2.jpg" alt="LOGO EP15 - Train 2" width="359" height="242" /><figcaption id="caption-attachment-1239" class="wp-caption-text">LOGO EP15 &#8211; Train 2</figcaption></figure>
<p>&nbsp;</p>
<ol start="2">
<li>ใส่รายละเอียดตู้สินค้าเข้าไปเล็กน้อย</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO body<br />
rt 90<br />
rectangle 200 100<br />
<strong>  repeat 9 [ fd 20 rt 90 fd 75 bk 75 lt 90 ]</strong><br />
<strong>  pu bk 180 pd</strong><br />
END</p>
<p>cs body</td>
</tr>
</tbody>
</table>
<figure id="attachment_1240" aria-describedby="caption-attachment-1240" style="width: 341px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1240" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-3.jpg" alt="LOGO EP15 - Train 3" width="341" height="217" /><figcaption id="caption-attachment-1240" class="wp-caption-text">LOGO EP15 &#8211; Train 3</figcaption></figure>
<p>&nbsp;</p>
<ol start="3">
<li>เพิ่มล้อเข้าไปให้กับตู้บรรทุกสินค้า</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO body<br />
rt 90<br />
rectangle 200 100<br />
repeat 9 [ fd 20 rt 90 fd 75 bk 75 lt 90 ]<br />
pu bk 180 pd<br />
<strong>  rt 90</strong><br />
<strong>  pu fd 100 lt 90 fd 50 pd</strong><br />
<strong>  circle 0.1</strong><br />
<strong>  pu fd 100 pd</strong><br />
<strong>  circle 0.1</strong><br />
<strong>  lt 90</strong><br />
END</td>
</tr>
</tbody>
</table>
<figure id="attachment_1241" aria-describedby="caption-attachment-1241" style="width: 351px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1241" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-4.jpg" alt="LOGO EP15 - Train 4" width="351" height="219" /><figcaption id="caption-attachment-1241" class="wp-caption-text">LOGO EP15 &#8211; Train 4</figcaption></figure>
<p>&nbsp;</p>
<ol start="4">
<li>เพื่อความสวยงาม เราจะระบายสีให้กับตู้สินค้ากันหน่อยครับ</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO body<br />
rt 90<br />
rectangle 200 100<br />
<strong>  paint &#8220;#388e3c</strong><br />
repeat 9 [ fd 20 rt 90 fd 75 bk 75 lt 90 ]<br />
pu bk 180 pd<br />
rt 90<br />
pu fd 100 lt 90 fd 50 pd<br />
circle 0.1<br />
pu fd 100 pd<br />
circle 0.1<br />
lt 90<br />
END</td>
</tr>
</tbody>
</table>
<figure id="attachment_1242" aria-describedby="caption-attachment-1242" style="width: 363px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1242" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-5.jpg" alt="LOGO EP15 - Train 5" width="363" height="244" /><figcaption id="caption-attachment-1242" class="wp-caption-text">LOGO EP15 &#8211; Train 5</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับฟังก์ชัน Body ต่อไปเราจะ…</p>
<h2><strong>สร้างฟังก์ชัน Head สำหรับวาดหัวรถไฟ</strong></h2>
<ol>
<li>เริ่มต้นการสร้างฟังก์ชัน Head ด้วยการวาดรูปสี่เหลี่ยมผืนผ้าก่อนเลย แต่ที่มุมขวาบนจะมีส่วนโค้งนิดหน่อยครับ</li>
</ol>
<table>
<tbody>
<tr>
<td width="312">TO head<br />
rt 90<br />
fd 150<br />
repeat 90 [ fd 0.9 rt 1 ]<br />
fd 50 rt 90<br />
fd 200 rt 90<br />
fd 100 rt 90<br />
END</p>
<p>cs head</td>
</tr>
</tbody>
</table>
<figure id="attachment_1243" aria-describedby="caption-attachment-1243" style="width: 366px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1243" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-6.jpg" alt="LOGO EP15 - Train 6" width="366" height="220" /><figcaption id="caption-attachment-1243" class="wp-caption-text">LOGO EP15 &#8211; Train 6</figcaption></figure>
<p>&nbsp;</p>
<ol start="2">
<li>เพิ่มหน้าต่างให้กับหัวรถไฟกันหน่อย</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO head<br />
rt 90<br />
fd 150<br />
repeat 90 [ fd 0.9 rt 1 ]<br />
fd 50 rt 90<br />
fd 200 rt 90<br />
fd 100 rt 90</p>
<p>pu fd 20 rt 90 fd 20 lt 90 pd<br />
square 30<br />
pu fd 60 pd<br />
square 30<br />
pu fd 60 pd<br />
square 30<br />
END</p>
<p>cs head</td>
</tr>
</tbody>
</table>
<figure id="attachment_1244" aria-describedby="caption-attachment-1244" style="width: 372px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1244" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-7.jpg" alt="LOGO EP15 - Train 7" width="372" height="224" /><figcaption id="caption-attachment-1244" class="wp-caption-text">LOGO EP15 &#8211; Train 7</figcaption></figure>
<p>&nbsp;</p>
<ol start="3">
<li>เพิ่มล้อให้กับหัวรถไฟครับ</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO head<br />
rt 90<br />
fd 150<br />
repeat 90 [ fd 0.9 rt 1 ]<br />
fd 50 rt 90<br />
fd 200 rt 90<br />
fd 100 rt 90</p>
<p>pu fd 20 rt 90 fd 20 lt 90 pd<br />
square 30<br />
pu fd 60 pd<br />
square 30<br />
pu fd 60 pd<br />
square 30</p>
<p>pu bk 150 lt 90 fd 20 pd<br />
rt 180<br />
pu fd 100 lt 90 fd 50 pd<br />
circle 0.1<br />
pu fd 100 pd<br />
circle 0.1<br />
lt 90<br />
END</p>
<p>cs head</td>
</tr>
</tbody>
</table>
<figure id="attachment_1245" aria-describedby="caption-attachment-1245" style="width: 362px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1245" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-8.jpg" alt="LOGO EP15 - Train 8" width="362" height="224" /><figcaption id="caption-attachment-1245" class="wp-caption-text">LOGO EP15 &#8211; Train 8</figcaption></figure>
<p>&nbsp;</p>
<ol start="4">
<li>เพิ่มสีสันเพื่อความสวยงามครับ</li>
</ol>
<table>
<tbody>
<tr>
<td width="697">TO head<br />
rt 90<br />
fd 150<br />
repeat 90 [ fd 0.9 rt 1 ]<br />
fd 50 rt 90<br />
fd 200 rt 90<br />
fd 100 rt 90<br />
<strong>  paint &#8220;#ffa000</strong></p>
<p>pu fd 20 rt 90 fd 20 lt 90 pd<br />
square 30<br />
<strong>  paint &#8220;#00bcd4</strong><br />
pu fd 60 pd<br />
square 30<br />
<strong>  paint &#8220;#00bcd4</strong><br />
pu fd 60 pd<br />
square 30<br />
<strong>  paint &#8220;#00bcd4</strong></p>
<p>pu bk 150 lt 90 fd 20 pd<br />
rt 180<br />
pu fd 100 lt 90 fd 50 pd<br />
circle 0.1<br />
pu fd 100 pd<br />
circle 0.1<br />
lt 90<br />
END</p>
<p>cs head</td>
</tr>
</tbody>
</table>
<figure id="attachment_1246" aria-describedby="caption-attachment-1246" style="width: 373px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1246" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train-9.jpg" alt="LOGO EP15 - Train 9" width="373" height="218" /><figcaption id="caption-attachment-1246" class="wp-caption-text">LOGO EP15 &#8211; Train 9</figcaption></figure>
<p>&nbsp;</p>
<p>เสร็จแล้วครับ สำหรับฟังก์ชัน Head เมื่อเราได้องค์ประกอบทั้งตู้รถไฟและหัวรถไฟแล้ว เราก็จะนำมา…</p>
<h2><strong>ประกอบกันเป็นขบวนรถไฟ</strong></h2>
<table>
<tbody>
<tr>
<td width="697">TO train<br />
setpencolor_default<br />
pu setxy -440 0 pd<br />
body<br />
pu setxy -220 0 pd<br />
body<br />
pu setxy 0 0 pd<br />
body<br />
pu setxy 220 0 pd<br />
head<br />
END</p>
<p>cs train</td>
</tr>
</tbody>
</table>
<figure id="attachment_1247" aria-describedby="caption-attachment-1247" style="width: 937px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1247" src="https://karnlab.com/wp-content/uploads/2018/10/LOGO-EP15-Train.jpg" alt="LOGO EP15 - Train" width="937" height="257" /><figcaption id="caption-attachment-1247" class="wp-caption-text">LOGO EP15 &#8211; Train</figcaption></figure>
<p>&nbsp;</p>
<p>สำหรับ Code ทั้งหมด สามารถเข้าไปดูได้ที่นี่ครับ <a href="https://github.com/doctorkarn/logo-lang/blob/master/EP15.txt">https://github.com/doctorkarn/logo-lang/blob/master/EP15.txt</a></p>
<p>เป็นอย่างไรกันบ้างครับสำหรับการวาดรูปรถไฟ จะสังเกตได้ว่าถ้าเราวาดรูปโดยเริ่มจากองค์ประกอบเล็กๆ ก่อน แล้วค่อยนำมารวมกัน เพื่อให้กลายเป็นภาพที่ซับซ้อน ก็จะทำให้เราสามารถวาดรูปยากๆ ได้ง่ายขึ้นครับ</p>
<p>สามารถติดตาม “วาดรูปด้วยภาษาโลโก้” ตอนอื่นๆ ได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep15-train/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 15 – รถไฟ</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep15-train/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 14 – ลายผ้า</title>
		<link>https://karnlab.com/logo-tutorial-ep14-textile/</link>
					<comments>https://karnlab.com/logo-tutorial-ep14-textile/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Sat, 11 Aug 2018 10:02:02 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[ลายผ้า]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1163</guid>

					<description><![CDATA[<p>ในตอนนี้เราจะมาวาดลายผ้าด้วยภาษาโลโก้กันครับ โดยเราแค่วาดเส้นธรรมดาๆ แล้วคะเนระยะห่างให้พอดีกับหน้าจอ เราก็จะได้ลายผ้าสวยๆ ครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง forward = เดินหน้า backward = ถอยหลัง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep14-textile/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 14 – ลายผ้า</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>ในตอนนี้เราจะมาวาดลายผ้าด้วยภาษาโลโก้กันครับ โดยเราแค่วาดเส้นธรรมดาๆ แล้วคะเนระยะห่างให้พอดีกับหน้าจอ เราก็จะได้ลายผ้าสวยๆ ครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>*** การวาดรูปลายผ้า ขนาดหน้าจอ (Resolution) ของคอมพิวเตอร์ที่น้องๆ ใช้ มีความสำคัญมากนะครับ โดยโปรแกรมในบทนี้ทดสอบกับหน้าจอขนาด 1366 x 768 นะครับ หากน้องๆ ต้องการวาดลวดลายผ้าให้เต็มจอ ต้องปรับขนาดให้เหมาะกับหน้าจอคอมพิวเตอร์ที่ต้องๆ ใช้นะครับ</p>
<p>&nbsp;</p>
<p>โปรแกรมที่ 14-1</p>
<figure id="attachment_1151" aria-describedby="caption-attachment-1151" style="width: 962px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1151" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-1.png" alt="LOGO EP14 - Textile 1" width="962" height="608" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-1.png 962w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-1-300x190.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-1-768x485.png 768w" sizes="auto, (max-width: 962px) 100vw, 962px" /><figcaption id="caption-attachment-1151" class="wp-caption-text">LOGO EP14 &#8211; Textile 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#795548<br />
setpencolor &#8220;#FFEB3B<br />
setpensize 3<br />
END</p>
<p>setup<br />
pu setxy -470 -220 pd<br />
repeat 28 [<br />
rt 30 fd 510<br />
pu bk 510<br />
rt 60 fd 34<br />
lt 90 pd<br />
]<br />
pu setxy -470 220 pd<br />
repeat 28 [<br />
rt 150 fd 510<br />
pu bk 510<br />
lt 60 fd 34<br />
lt 90 pd<br />
]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>คำสั่ง pu setxy -470 -220 pd คือ การย้ายตำแหน่งเต่าโลโก้ ไปที่มุมซ้ายล่างของหน้าจอ</li>
<li>repeat 28 คือ การทำซ้ำ 28 ครั้ง</li>
<li>rt 30 fd 510 คือ การวาดเส้นตรง (เอียงและยาว)</li>
<li>pu bk 510 คือ การยกปากกากลับมาที่เดิม</li>
<li>rt 60 fd 34 lt 90 pd คือ การยกปากกาไปที่ตำแหน่งถัดไป</li>
<li>&#8230;..</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 14-2A</p>
<figure id="attachment_1152" aria-describedby="caption-attachment-1152" style="width: 966px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1152" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2A.png" alt="LOGO EP14 - Textile 2A" width="966" height="610" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2A.png 966w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2A-300x189.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2A-768x485.png 768w" sizes="auto, (max-width: 966px) 100vw, 966px" /><figcaption id="caption-attachment-1152" class="wp-caption-text">LOGO EP14 &#8211; Textile 2A</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#FFF9C4<br />
setpencolor &#8220;#4FC3F7<br />
setpensize 3<br />
END</p>
<p>TO h_line<br />
repeat 19 [<br />
fd 1000<br />
pu rt 90 fd 50 lt 90 pd<br />
]<br />
END</p>
<p>TO v_line<br />
repeat 9 [<br />
fd 1200<br />
pu rt 90 fd 50 lt 90 pd<br />
]<br />
END</p>
<p>setup<br />
pu setxy -450 0 pd<br />
h_line<br />
rt 90<br />
pu setxy -450 200 pd<br />
v_line</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>คำสั่ง pu setxy -450 0 pd คือ การย้ายตำแหน่งเต่าโลโก้ไปที่มุมซ้าย</li>
<li>ฟังก์ชัน h_line มีหน้าที่วาดเส้นยาวแนวตั้ง (19 ครั้ง)
<ul>
<li>แต่ละครั้งจะวาดเส้นตรง และย้ายเต่าโลโก้ไปที่ตำแหน่งถัดไป</li>
</ul>
</li>
<li>ฟังก์ชัน v_line มีหน้าที่วาดเส้นยาวแนวนอน (9 ครั้ง)
<ul>
<li>แต่ละครั้งจะวาดเส้นตรง และย้ายเต่าโลโก้ไปที่ตำแหน่งถัดไป</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 14-2B</p>
<figure id="attachment_1153" aria-describedby="caption-attachment-1153" style="width: 963px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1153" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2B.png" alt="LOGO EP14 - Textile 2B" width="963" height="609" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2B.png 963w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2B-300x190.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-2B-768x486.png 768w" sizes="auto, (max-width: 963px) 100vw, 963px" /><figcaption id="caption-attachment-1153" class="wp-caption-text">LOGO EP14 &#8211; Textile 2B</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#FFF9C4<br />
setpensize 3<br />
END</p>
<p>TO h_line :s<br />
if ( :s &lt; 1 ) [ stop ]<br />
if ( :s % 2 = 0 ) [ setpencolor &#8220;#F06292 ]<br />
if ( :s % 2 = 1 ) [ setpencolor &#8220;#4FC3F7 ]<br />
fd 1000<br />
pu rt 90 fd 50 lt 90 pd<br />
h_line :s-1<br />
END</p>
<p>TO v_line :s<br />
if ( :s &lt; 1 ) [ stop ]<br />
if ( :s % 2 = 0 ) [ setpencolor &#8220;#F06292 ]<br />
if ( :s % 2 = 1 ) [ setpencolor &#8220;#4FC3F7 ]<br />
fd 1200<br />
pu rt 90 fd 50 lt 90 pd<br />
v_line :s-1<br />
END</p>
<p>setup<br />
pu setxy -450 0 pd<br />
h_line 19<br />
rt 90<br />
pu setxy -450 200 pd<br />
v_line 9</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>คำสั่ง pu setxy -450 0 pd คือ การย้ายตำแหน่งเต่าโลโก้ไปที่มุมซ้าย</li>
<li>ฟังก์ชัน h_line มีหน้าที่วาดเส้นยาวแนวตั้ง (19 ครั้ง)
<ul>
<li>แต่ละครั้งจะวาดเส้นตรง และย้ายเต่าโลโก้ไปที่ตำแหน่งถัดไป</li>
<li>เพิ่มเติม คือ เราจะวาดเส้นด้วยสีฟ้าและสีชมพูสลับกัน ดังนั้น เราจึงประยุกต์ใช้ Recursive Function มาใช้งานครับ</li>
<li>โดยตัวแปร :s ทำหน้าที่เป็นตัวนับ
<ul>
<li>ถ้า :s เป็นเลขคู่ ( :s หาร 2 เหลือเศษ 0 ) ตั้งค่าสีชมพู</li>
<li>ถ้า :s เป็นเลขคี่ ( :s หาร 2 เหลือเศษ 1 ) ตั้งค่าสีฟ้า</li>
</ul>
</li>
<li>และถ้าตัวแปร :s มีค่าเป็น 0 (น้อยกว่า 1) หยุดการทำงาน</li>
</ul>
</li>
<li>ฟังก์ชัน v_line มีหน้าที่วาดเส้นยาวแนวนอน (9 ครั้ง)
<ul>
<li>แต่ละครั้งจะวาดเส้นตรง โดยใช้สีฟ้าและสีชมพูสลับกัน และย้ายเต่าโลโก้ไปที่ตำแหน่งถัดไป</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 14-3</p>
<figure id="attachment_1154" aria-describedby="caption-attachment-1154" style="width: 962px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1154" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-3.png" alt="LOGO EP14 - Textile 3" width="962" height="607" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-3.png 962w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-3-300x189.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP14-Textile-3-768x485.png 768w" sizes="auto, (max-width: 962px) 100vw, 962px" /><figcaption id="caption-attachment-1154" class="wp-caption-text">LOGO EP14 &#8211; Textile 3</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#FFF9C4<br />
setpencolor &#8220;#8D6E63<br />
setpensize 3<br />
END</p>
<p>setup<br />
pu setxy -460 0 pd<br />
repeat 10 [<br />
fd 1000<br />
pu rt 90 fd 20 lt 90 pd<br />
fd 1000<br />
pu rt 90 fd 80 lt 90 pd<br />
]</p>
<p>rt 90<br />
pu setxy -450 210 pd<br />
repeat 5 [<br />
fd 1200<br />
pu rt 90 fd 20 lt 90 pd<br />
fd 1200<br />
pu rt 90 fd 80 lt 90 pd<br />
]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>คำสั่ง pu setxy -460 0 pd คือ การย้ายตำแหน่งเต่าโลโก้ไปที่มุมซ้าย</li>
<li>repeat 10 คือ การทำซ้ำ 10 ครั้ง</li>
<li>fd 1000 pu rt 90 fd 20 lt 90 pd<br />
fd 1000 pu rt 90 fd 80 lt 90 pd<br />
คือ การวาดเส้นตรง 2 เส้น (ที่อยู่ใกล้กัน) จากนั้นย้ายตำแหน่งเต่าโลโก้</li>
</ul>
<ul>
<li>&#8230;..</li>
</ul>
<p>&nbsp;</p>
<p>และนี่คือเรื่องราวของเทคนิคการวาดรูปจากหมุนที่นำมาฝากกันในวันนี้ครับ สามารถติดตามตอนต่อไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep14-textile/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 14 – ลายผ้า</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep14-textile/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 13 – หมุนหมุน</title>
		<link>https://karnlab.com/logo-tutorial-ep13-spinning/</link>
					<comments>https://karnlab.com/logo-tutorial-ep13-spinning/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Fri, 10 Aug 2018 16:06:21 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[หมุน]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1155</guid>

					<description><![CDATA[<p>ในตอนนี้เราจะมาเรียนรู้เทคนิคการวาดรูปแบบหนึ่ง นั่นคือ การหมุน โดยเราจะวาดรูปเรขาคณิตพื้นฐาน จากนั้นหมุนเต่าโลโก้ แล้ววาดรูปนั้นอีกครั้ง ทำเช่นนี้ไปเรื่อยๆ เราจะได้รูปภาพใหม่ที่น่าสนใจครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง forward = เดินหน้า [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep13-spinning/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 13 – หมุนหมุน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>ในตอนนี้เราจะมาเรียนรู้เทคนิคการวาดรูปแบบหนึ่ง นั่นคือ การหมุน โดยเราจะวาดรูปเรขาคณิตพื้นฐาน จากนั้นหมุนเต่าโลโก้ แล้ววาดรูปนั้นอีกครั้ง ทำเช่นนี้ไปเรื่อยๆ เราจะได้รูปภาพใหม่ที่น่าสนใจครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>เริ่มต้นด้วยการหมุนเส้นตรงรูปแบบต่างๆ เราจะได้รูปดอกไม้ไฟที่น่าสนใจครับ</p>
<p>โปรแกรมที่ 13-1</p>
<figure id="attachment_1144" aria-describedby="caption-attachment-1144" style="width: 941px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1144" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-1.png" alt="LOGO EP13 - Spinning Line 1" width="941" height="445" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-1.png 941w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-1-300x142.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-1-768x363.png 768w" sizes="auto, (max-width: 941px) 100vw, 941px" /><figcaption id="caption-attachment-1144" class="wp-caption-text">LOGO EP13 &#8211; Spinning Line 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#212121<br />
setpencolor &#8220;#EF9A9A<br />
setpensize 5<br />
END</p>
<p>TO line_1<br />
fd 200 bk 200<br />
END</p>
<p>setup<br />
repeat 18 [ line_1 rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน line_1 ใช้สำหรับวาดเส้นตรง</li>
<li>repeat 18 [ line_1 rt 20 ] คือ การวาดเส้น แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-2</p>
<figure id="attachment_1145" aria-describedby="caption-attachment-1145" style="width: 943px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1145" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-2.png" alt="LOGO EP13 - Spinning Line 2" width="943" height="443" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-2.png 943w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-2-300x141.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-2-768x361.png 768w" sizes="auto, (max-width: 943px) 100vw, 943px" /><figcaption id="caption-attachment-1145" class="wp-caption-text">LOGO EP13 &#8211; Spinning Line 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#212121<br />
setpencolor &#8220;#CE93D8<br />
setpensize 5<br />
END</p>
<p>TO line_2<br />
pu fd 100 pd fd 100<br />
pu bk 200 pd<br />
END</p>
<p>setup<br />
repeat 36 [ line_2 rt 10 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน line_2 ใช้สำหรับวาดเส้นตรง</li>
<li>repeat 36 [ line_2 rt 10 ] คือ การวาดเส้น แล้วหมุนขวา 10 องศา ทำแบบนี้ทั้งหมด 36 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-3</p>
<figure id="attachment_1146" aria-describedby="caption-attachment-1146" style="width: 944px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1146" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-3.png" alt="LOGO EP13 - Spinning Line 3" width="944" height="445" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-3.png 944w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-3-300x141.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Line-3-768x362.png 768w" sizes="auto, (max-width: 944px) 100vw, 944px" /><figcaption id="caption-attachment-1146" class="wp-caption-text">LOGO EP13 &#8211; Spinning Line 3</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#212121<br />
setpencolor &#8220;#9FA8DA<br />
setpensize 5<br />
END</p>
<p>TO line_3<br />
pu fd 50 pd fd 50<br />
pu fd 50 pd fd 50<br />
pu bk 200 pd<br />
END</p>
<p>setup<br />
repeat 72 [ line_3 rt 5 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน line_3 ใช้สำหรับวาดเส้นตรง</li>
<li>repeat 72 [ line_3 rt 5 ] คือ การวาดเส้น แล้วหมุนขวา 5 องศา ทำแบบนี้ทั้งหมด 72 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>ถ้าเราสังเกตคำสั่งดังต่อไปนี้ให้ดี</p>
<ul>
<li>repeat 18 [ line_1 rt 20 ]</li>
<li>repeat 36 [ line_2 rt 10 ]</li>
<li>repeat 72 [ line_3 rt 5 ]</li>
</ul>
<p>เราจะพบว่าการหมุนให้ครบ 1 รอบ มีหลักการง่ายๆ คือ จำนวนครั้ง x องศาที่หมุน = 360 องศา</p>
<ul>
<li>18 x 20 = 360</li>
<li>36 x 10 = 360</li>
<li>72 x 5 = 360</li>
</ul>
<p>&nbsp;</p>
<p>จากนั้นเรามาลองหมุนภาพเรขาคณิต เราจะได้รูปทรงที่น่าสนใจครับ</p>
<p>โปรแกรมที่ 13-5</p>
<figure id="attachment_1149" aria-describedby="caption-attachment-1149" style="width: 941px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1149" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Square.png" alt="LOGO EP13 - Spinning Square" width="941" height="445" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Square.png 941w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Square-300x142.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Square-768x363.png 768w" sizes="auto, (max-width: 941px) 100vw, 941px" /><figcaption id="caption-attachment-1149" class="wp-caption-text">LOGO EP13 &#8211; Spinning Square</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#F5F5F5<br />
setpencolor &#8220;#009688<br />
setpensize 5<br />
END</p>
<p>TO square<br />
repeat 4 [ fd 150 rt 90 ]<br />
END</p>
<p>setup<br />
repeat 18 [ square rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน square ใช้สำหรับวาดสี่เหลี่ยมจัตุรัส</li>
<li>repeat 18 [ square rt 20 ] คือ วาดสี่เหลี่ยมจัตุรัส แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-6</p>
<figure id="attachment_1143" aria-describedby="caption-attachment-1143" style="width: 939px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1143" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Hexagon.png" alt="LOGO EP13 - Spinning Hexagon" width="939" height="441" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Hexagon.png 939w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Hexagon-300x141.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Hexagon-768x361.png 768w" sizes="auto, (max-width: 939px) 100vw, 939px" /><figcaption id="caption-attachment-1143" class="wp-caption-text">LOGO EP13 &#8211; Spinning Hexagon</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#F5F5F5<br />
setpencolor &#8220;#8BC34A<br />
setpensize 5<br />
END</p>
<p>TO hexagon<br />
repeat 6 [ fd 100 rt 60 ]<br />
END</p>
<p>setup<br />
repeat 18 [ hexagon rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน hexagon ใช้สำหรับวาดหกเหลี่ยม</li>
<li>repeat 18 [ hexagon rt 20 ] คือ วาดหกเหลี่ยม แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-7</p>
<figure id="attachment_1147" aria-describedby="caption-attachment-1147" style="width: 941px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1147" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Octagon.png" alt="LOGO EP13 - Spinning Octagon" width="941" height="442" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Octagon.png 941w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Octagon-300x141.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Octagon-768x361.png 768w" sizes="auto, (max-width: 941px) 100vw, 941px" /><figcaption id="caption-attachment-1147" class="wp-caption-text">LOGO EP13 &#8211; Spinning Octagon</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#F5F5F5<br />
setpencolor &#8220;#FFEB3B<br />
setpensize 5<br />
END</p>
<p>TO octagon<br />
repeat 8 [ fd 75 rt 45 ]<br />
END</p>
<p>setup<br />
repeat 18 [ octagon rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน octagon ใช้สำหรับวาดแปดเหลี่ยม</li>
<li>repeat 18 [ octagon rt 20 ] คือ วาดแปดเหลี่ยม แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-8</p>
<figure id="attachment_1148" aria-describedby="caption-attachment-1148" style="width: 942px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1148" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Polygon.png" alt="LOGO EP13 - Spinning Polygon" width="942" height="446" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Polygon.png 942w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Polygon-300x142.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Polygon-768x364.png 768w" sizes="auto, (max-width: 942px) 100vw, 942px" /><figcaption id="caption-attachment-1148" class="wp-caption-text">LOGO EP13 &#8211; Spinning Polygon</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#F5F5F5<br />
setpencolor &#8220;#FF9800<br />
setpensize 5<br />
END</p>
<p>TO polygon<br />
repeat 12 [ fd 50 rt 30 ]<br />
END</p>
<p>setup<br />
repeat 18 [ polygon rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน polygon ใช้สำหรับวาดสิบสองเหลี่ยม</li>
<li>repeat 18 [ polygon rt 20 ] คือ วาดสิบสองเหลี่ยม แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>โปรแกรมที่ 13-9</p>
<figure id="attachment_1142" aria-describedby="caption-attachment-1142" style="width: 942px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1142" src="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Circle.png" alt="LOGO EP13 - Spinning Circle" width="942" height="443" srcset="https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Circle.png 942w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Circle-300x141.png 300w, https://karnlab.com/wp-content/uploads/2018/08/LOGO-EP13-Spinning-Circle-768x361.png 768w" sizes="auto, (max-width: 942px) 100vw, 942px" /><figcaption id="caption-attachment-1142" class="wp-caption-text">LOGO EP13 &#8211; Spinning Circle</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO setup<br />
cs ht<br />
setscreencolor &#8220;#F5F5F5<br />
setpencolor &#8220;#795548<br />
setpensize 5<br />
END</p>
<p>TO circle<br />
repeat 360 [ fd 1.5 rt 1 ]<br />
END</p>
<p>setup<br />
repeat 18 [ circle rt 20 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>ฟังก์ชัน setup ใช้สำหรับกำหนดสีของพื้นหลัง สีของปากกา และขนาดของปากกา</li>
<li>ฟังก์ชัน circle ใช้สำหรับวาดวงกลม</li>
<li>repeat 18 [ circle rt 20 ] คือ วาดวงกลม แล้วหมุนขวา 20 องศา ทำแบบนี้ทั้งหมด 18 ครั้ง</li>
</ul>
<p>&nbsp;</p>
<p>และนี่คือเรื่องราวของเทคนิคการวาดรูปจากหมุนที่นำมาฝากกันในวันนี้ครับ สามารถติดตามตอนต่อไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep13-spinning/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 13 – หมุนหมุน</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep13-spinning/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 12 – เคลื่อนไหว</title>
		<link>https://karnlab.com/logo-tutorial-ep12-animation/</link>
					<comments>https://karnlab.com/logo-tutorial-ep12-animation/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Sat, 21 Jul 2018 08:40:37 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<category><![CDATA[เคลื่อนไหว]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1134</guid>

					<description><![CDATA[<p>จากตอนที่แล้ว เราวาดรูปกันมาเยอะมาก และแน่นอนว่า เราก็ต้องลบรูปภาพที่เราวาดด้วยคำสั่ง CS หรือ Clean เยอะมาก ถ้าเราวาดรูปแล้วลบ วาดรูปแล้วลบ วาดรูปแล้วลบ &#8230;.. จะเกิดอะไรขึ้น? (เนื้อหาตอนนี้ค่อนข้างยาก ถ้าน้องๆ อ่านแล้วยังไม่เข้าใจ สามารถข้ามไปได้โดยไม่ต้องกังวลครับ เพราะเรื่องนี้ไม่มีผลกับเรื่องอื่นๆ แต่ถ้าน้องๆ อยากทำความเข้าใจ [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep12-animation/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 12 – เคลื่อนไหว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>จากตอนที่แล้ว เราวาดรูปกันมาเยอะมาก และแน่นอนว่า เราก็ต้องลบรูปภาพที่เราวาดด้วยคำสั่ง CS หรือ Clean เยอะมาก ถ้าเราวาดรูปแล้วลบ วาดรูปแล้วลบ วาดรูปแล้วลบ &#8230;.. จะเกิดอะไรขึ้น?</p>
<p>(เนื้อหาตอนนี้ค่อนข้างยาก ถ้าน้องๆ อ่านแล้วยังไม่เข้าใจ สามารถข้ามไปได้โดยไม่ต้องกังวลครับ เพราะเรื่องนี้ไม่มีผลกับเรื่องอื่นๆ แต่ถ้าน้องๆ อยากทำความเข้าใจ ลองเขียนทบทวนทำความเข้าใจเองก่อน แล้วค่อยกลับมาอ่านใหม่นะครับ)</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
<tr>
<td width="198">wait หน่วยเวลา</td>
<td width="227">wait = หยุดการทำงาน</td>
<td width="227">wait 5</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>ถ้าเราวาดรูปแล้วลบอย่างรวดเร็ว เราจะเห็นเป็นภาพเคลื่อนไหว การสร้างภาพเคลื่อนไหวไม่ใช่ความสามารถโดยตรงของภาษาโลโก้ แต่เราประยุกต์ใช้การวาดรูปและลบรูป เพื่อให้เกิดเป็นภาพแบบใหม่ๆ ขึ้นมา ต่อไปเราจะมาลองสร้างภาพเคลื่อนไหวแบบง่ายๆ กันครับ <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>โปรแกรมที่ 12-1 วงกลมเคลื่อนที่</p>
<figure id="attachment_1124" aria-describedby="caption-attachment-1124" style="width: 600px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1124" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP12-Animation-1.gif" alt="LOGO EP12 - Animation 1" width="600" height="409" /><figcaption id="caption-attachment-1124" class="wp-caption-text">LOGO EP12 &#8211; Animation 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO filled_circle<br />
repeat 360 [ fd 1 rt 1 ]<br />
rt 90 pu fd 10 pd fill<br />
pu bk 10 pd lt 90<br />
END</p>
<p>TO animate_circle<br />
repeat 40 [<br />
pu fd 10 pd<br />
filled_circle<br />
wait 5<br />
clean<br />
]<br />
END</p>
<p>setpencolor &#8220;#F0A2AF<br />
rt 90<br />
pu bk 200 pd<br />
animate_circle</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_circle
<ul>
<li>เคลื่อนที่เต่าโลโก้ไปข้างหน้า 10 pixel</li>
<li>วาดรูปวงกลม (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>(ทำซ้ำแบบนี้ 40 ครั้ง)</li>
</ul>
</li>
</ul>
<p>น้องๆ จะสังเกตได้ว่า คำสั่ง หยุดเวลา และ ลบรูปภาพเดิม (เพื่อวาดรูปใหม่) มีส่วนสำคัญในการวาดภาพเคลื่อนไหวครับ หากเราหยุดเวลามากเกินไป ภาพที่ได้จะกระตุก แต่ถ้าเราหยุดเวลาน้อยเกินไป ภาพจะเคลื่อนที่เร็วมาก (หรือ CPU/GPU จะประมวลผลไม่ทัน)</p>
<p>&nbsp;</p>
<p>ต่อไปจะมาวาดรูปดาวที่เคลื่อนที่ด้วยความเร็วไม่คงที่กันครับ (คำสั่งนี้มีการประยุกต์ใช้ Recursive Function จากตอนที่ 11)</p>
<p>โปรแกรมที่ 12-2 ดาวเคลื่อนที่</p>
<figure id="attachment_1125" aria-describedby="caption-attachment-1125" style="width: 600px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1125" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP12-Animation-2.gif" alt="LOGO EP12 - Animation 2" width="600" height="409" /><figcaption id="caption-attachment-1125" class="wp-caption-text">LOGO EP12 &#8211; Animation 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO filled_star<br />
repeat 5 [ fd 75 rt 144 fd 75 lt 72 ]<br />
rt 45 pu fd 10 pd fill pu bk 10 pd lt 45<br />
END</p>
<p>TO animate_star :s<br />
if (0.2*:s*:s) &gt; 150 [ stop ]<br />
pu fd 50 &#8211; 0.2*:s*:s pd<br />
filled_star<br />
wait 5<br />
clean<br />
animate_star :s+1<br />
END</p>
<p>setpencolor &#8220;yellow<br />
rt 90<br />
pu bk 200 pd<br />
animate_star 1</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_star 1
<ul>
<li>ความเร็ว = 2 x 1 x 1 = 0.2 ซึ่งน้อยกว่า 150</li>
<li>เคลื่อนที่เต่าโลโก้ไปข้างหน้า 50 – 0.2 = 49.8 pixel</li>
<li>วาดรูปดาว 5 แฉก (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>เรียกใช้คำสั่ง animate_star 2</li>
</ul>
</li>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_star 2
<ul>
<li>ความเร็ว = 2 x 2 x 2 = 0.8 ซึ่งน้อยกว่า 150</li>
<li>เคลื่อนที่เต่าโลโก้ไปข้างหน้า 50 – 0.8 = 49.2 pixel</li>
<li>วาดรูปดาว 5 แฉก (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>เรียกใช้คำสั่ง animate_star 3</li>
</ul>
</li>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_star 3
<ul>
<li>ความเร็ว = 2 x 3 x 3 = 1.8 ซึ่งน้อยกว่า 150</li>
<li>เคลื่อนที่เต่าโลโก้ไปข้างหน้า 50 – 1.8 = 42 pixel</li>
<li>วาดรูปดาว 5 แฉก (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>เรียกใช้คำสั่ง animate_star 4</li>
</ul>
</li>
<li>( ทำเช่นนี้ไปเรื่อยๆ )</li>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_star 20
<ul>
<li>ความเร็ว = 2 x 20 x 20 = 80 ซึ่งน้อยกว่า 150</li>
<li>เคลื่อนที่เต่าโลโก้ไปข้างหน้า 50 – 80 = -30 pixel (= ถอยหลัง 30 pixel)</li>
<li>วาดรูปดาว 5 แฉก (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>เรียกใช้คำสั่ง animate_star 21</li>
</ul>
</li>
<li>( ทำเช่นนี้ไปเรื่อยๆ จนกระทั่ง )</li>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_star 28
<ul>
<li>ความเร็ว = 2 x 28 x 28 = 156.8 ซึ่งมากกว่า 150</li>
<li>จบการทำงาน</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p>สำหรับรูปสุดท้ายที่เราจะวาดกัน ได้แรงบันดาลใจมาจากอนิเมะครับ</p>
<p>โปรแกรมที่ 12-3 เมื่อยามซากุระร่วงโรย</p>
<figure id="attachment_1123" aria-describedby="caption-attachment-1123" style="width: 600px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1123" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP12-Animation-3.gif" alt="LOGO EP12 - Animation 3" width="600" height="410" /><figcaption id="caption-attachment-1123" class="wp-caption-text">LOGO EP12 &#8211; Animation 3</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO leaf<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
END</p>
<p>TO flower<br />
repeat 5 [<br />
leaf<br />
rt 45 pu fd 10 pd fill bk 10 lt 45<br />
rt 72<br />
]<br />
END</p>
<p>TO animate_flower :s<br />
if :s &lt; -10 [ stop ]<br />
pu setxy 0 (:s * 10) rt (:s * 10) pd<br />
lt 45 flower rt 45<br />
wait 5<br />
cs<br />
animate_flower :s-1<br />
END</p>
<p>setpencolor &#8220;#F9BC9D<br />
animate_flower 20</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>เมื่อโปรแกรมเรียกใช้คำสั่ง animate_flower 20
<ul>
<li>เคลื่อนย้ายตำแหน่งเต่าโลโก้ไปที่ (0, 200) และหมุนขวา 200 องศา</li>
<li>วาดรูปดอกไม้ (พร้อมระบายสี)</li>
<li><strong>หยุดรอ 5 หน่วยเวลา</strong></li>
<li><strong>ลบรูปภาพ</strong></li>
<li>เรียกใช้คำสั่ง animate_flower 19</li>
</ul>
</li>
<li>( เป็นเช่นนี้ไปเรื่อยๆ จนกระทั่ง animate_flower -10 จึงจบการทำงาน )</li>
</ul>
<p>&nbsp;</p>
<p>และนี่คือเรื่องราวของ Animation ทั้งหมดที่นำมาฝากกันในวันนี้ครับ สามารถติดตามตอนต่อไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep12-animation/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 12 – เคลื่อนไหว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep12-animation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 11 – เริ่มใหม่อีกครั้ง</title>
		<link>https://karnlab.com/logo-tutorial-ep11-recursive/</link>
					<comments>https://karnlab.com/logo-tutorial-ep11-recursive/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Sat, 21 Jul 2018 07:41:00 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1126</guid>

					<description><![CDATA[<p>จากตอนที่แล้ว เราใช้ฟังก์ชันกันมาก็หลายครั้ง ถ้าเราเรียกใช้ฟังก์ชัน แล้วฟังก์ชันนั้นเรียกใช้งานฟังก์ชันอื่น ก็ถือเป็นเรื่องปกติ แต่น้องๆ เคยคิดไหมครับว่า ถ้าเราเรียกใช้ฟังก์ชัน แล้วฟังก์ชันนั้นเรียกใช้งานฟังก์ชันตัวเอง จะเกิดอะไรขึ้น? (เนื้อหาตอนนี้ค่อนข้างยาก ถ้าน้องๆ อ่านแล้วยังไม่เข้าใจ สามารถข้ามไปได้โดยไม่ต้องกังวลครับ เพราะเรื่องนี้ไม่มีผลกับเรื่องอื่นๆ แต่ถ้าน้องๆ อยากทำความเข้าใจ ลองเขียนทบทวนทำความเข้าใจเองก่อน แล้วค่อยกลับมาอ่านใหม่นะครับ) คำสั่งที่น้องๆ [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep11-recursive/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 11 – เริ่มใหม่อีกครั้ง</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>จากตอนที่แล้ว เราใช้ฟังก์ชันกันมาก็หลายครั้ง ถ้าเราเรียกใช้ฟังก์ชัน แล้วฟังก์ชันนั้นเรียกใช้งานฟังก์ชันอื่น ก็ถือเป็นเรื่องปกติ แต่น้องๆ เคยคิดไหมครับว่า ถ้าเราเรียกใช้ฟังก์ชัน แล้วฟังก์ชันนั้นเรียกใช้งานฟังก์ชันตัวเอง จะเกิดอะไรขึ้น?</p>
<p>(เนื้อหาตอนนี้ค่อนข้างยาก ถ้าน้องๆ อ่านแล้วยังไม่เข้าใจ สามารถข้ามไปได้โดยไม่ต้องกังวลครับ เพราะเรื่องนี้ไม่มีผลกับเรื่องอื่นๆ แต่ถ้าน้องๆ อยากทำความเข้าใจ ลองเขียนทบทวนทำความเข้าใจเองก่อน แล้วค่อยกลับมาอ่านใหม่นะครับ)</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>น้องๆ น่าจะเคยเห็น รูปถ่ายที่มีคนถ่ายรูปกับรูปถ่ายของตัวเอง ซึ่งในนั้นก็จะมี รูปถ่ายที่มีคนถ่ายรูปกับรูปถ่ายของตัวเอง ซึ่งในนั้นก็จะมี รูปถ่ายที่มีคนถ่ายรูปกับรูปถ่ายของตัวเอง &#8230;.. โอ๊ย! พูดง่ายๆ คือ รูปแบบด้านล่างนี้ละครับ</p>
<figure id="attachment_1112" aria-describedby="caption-attachment-1112" style="width: 800px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-large wp-image-1112" src="https://karnlab.com/wp-content/uploads/2018/07/Recursive-Picture-1024x768.jpg" alt="Recursive Picture" width="800" height="600" srcset="https://karnlab.com/wp-content/uploads/2018/07/Recursive-Picture-1024x768.jpg 1024w, https://karnlab.com/wp-content/uploads/2018/07/Recursive-Picture-300x225.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/Recursive-Picture-768x576.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/Recursive-Picture.jpg 1032w" sizes="auto, (max-width: 800px) 100vw, 800px" /><figcaption id="caption-attachment-1112" class="wp-caption-text">Recursive Picture</figcaption></figure>
<p>ซึ่งเราสามารถเทียบเหตุการณ์นี้กับโปรแกรมวาดรูปดังต่อไปนี้ครับ</p>
<figure id="attachment_1115" aria-describedby="caption-attachment-1115" style="width: 970px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1115" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-1.jpg" alt="LOGO EP11 - Recursive 1" width="970" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-1.jpg 970w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-1-300x205.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-1-768x524.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-1-130x90.jpg 130w" sizes="auto, (max-width: 970px) 100vw, 970px" /><figcaption id="caption-attachment-1115" class="wp-caption-text">LOGO EP11 &#8211; Recursive 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO square_r :s<br />
repeat 4 [ fd :s rt 90 ]<br />
square_r :s/2<br />
END<br />
square_r 200</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-1</p>
<p>การทำงานของโปรแกรมนี้ นอกจากจะวาดรูปสี่เหลี่ยมแล้ว มันจะวาดรูปสี่เหลี่ยมที่เล็กกว่า โดยการเรียกใช้ฟังก์ชันตัวเองครับ อธิบายโดยละเอียดคือ</p>
<ul>
<li>คำสั่ง square_r 200 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 200 pixel – จากนั้นเรียกใช้ square_r 100</li>
<li>คำสั่ง square_r 100 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 100 pixel – จากนั้นเรียกใช้ square_r 50</li>
<li>คำสั่ง square_r 50 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 50 pixel – จากนั้นเรียกใช้ square_r 25</li>
<li>คำสั่ง square_r 25 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 25 pixel – จากนั้นเรียกใช้ square_r 5</li>
<li>คำสั่ง square_r 5 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 12.5 pixel – จากนั้นเรียกใช้ square_r 6.25</li>
<li>คำสั่ง square_r 25 – จะวาดรูปสี่เหลี่ยมจัตุรัสขนาด 6.25 pixel – จากนั้นเรียกใช้ square_r 3.125</li>
<li>( เป็นเช่นนี้ไปเรื่อยๆ )</li>
</ul>
<p>&nbsp;</p>
<p>เราเรียกฟังก์ชันที่เรียกใช้ฟังก์ชันตัวเองว่า Recursive Function ครับ (Recursive แปลว่า ซ้ำๆ)</p>
<p>แต่ปัญหาของโปรแกรมข้างต้น คือ มันจะทำงานไปเรื่อยๆ โดยไม่จบการทำงานครับ !!!</p>
<p>ถ้าเราเรียกใช้งานฟังก์ชันที่มีการเรียกใช้ฟังก์ชันตัวเอง โดยไม่มีเงื่อนไขจบการทำงาน ฟังก์ชันนั้นก็จะทำงานไปเรื่อยๆ โดยไม่มีวันสิ้นสุด</p>
<p>ดังนั้น สิ่งที่สำคัญมากสำหรับฟังก์ชันที่เรียกใช้งานตัวเองก็คือ เงื่อนไขจบการทำงานครับ (Exit Condition)</p>
<p>&nbsp;</p>
<p>เราจะมาปรับปรุงโปรแกรม 11-1 โดยเพิ่มเงื่อนไขจบการทำงานเข้าไปครับ</p>
<figure id="attachment_1116" aria-describedby="caption-attachment-1116" style="width: 970px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1116" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-2.jpg" alt="LOGO EP11 - Recursive 2" width="970" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-2.jpg 970w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-2-300x205.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-2-768x524.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-2-130x90.jpg 130w" sizes="auto, (max-width: 970px) 100vw, 970px" /><figcaption id="caption-attachment-1116" class="wp-caption-text">LOGO EP11 &#8211; Recursive 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO square_r :s<br />
if ( :s &lt; 10 ) [ stop ]<br />
repeat 4 [ fd :s rt 90 ]<br />
square_r :s/2<br />
END<br />
square_r 200</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-2</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง square_r 200 – พบว่าขนาด 200 มากกว่า 10 – วาดรูปสี่เหลี่ยมจัตุรัสขนาด 200 pixel – จากนั้นเรียกใช้ square_r 100</li>
<li>คำสั่ง square_r 100 – พบว่าขนาด 100 มากกว่า 10 – วาดรูปสี่เหลี่ยมจัตุรัสขนาด 100 pixel – จากนั้นเรียกใช้ square_r 50</li>
<li>คำสั่ง square_r 50 – พบว่าขนาด 50 มากกว่า 10 – วาดรูปสี่เหลี่ยมจัตุรัสขนาด 50 pixel – จากนั้นเรียกใช้ square_r 25</li>
<li>คำสั่ง square_r 25 – พบว่าขนาด 25 มากกว่า 10 – วาดรูปสี่เหลี่ยมจัตุรัสขนาด 25 pixel – จากนั้นเรียกใช้ square_r 5</li>
<li>คำสั่ง square_r 5 – พบว่าขนาด 12.5 มากกว่า 10 – วาดรูปสี่เหลี่ยมจัตุรัสขนาด 12.5 pixel – จากนั้นเรียกใช้ square_r 6.25</li>
<li>คำสั่ง square_r 25 – พบว่าขนาด 6.25 น้อยกว่า 10 – จึงจบการทำงาน</li>
</ul>
<p>&nbsp;</p>
<p>ต่อไปเราจะมาดูตัวอย่างโปรแกรมที่ประยุกต์ใช้การทำงานของฟังก์ชัน Recursive กันครับ</p>
<figure id="attachment_1113" aria-describedby="caption-attachment-1113" style="width: 972px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1113" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-1.jpg" alt="LOGO EP11 - Helix 1" width="972" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-1.jpg 972w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-1-300x204.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-1-768x523.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-1-130x90.jpg 130w" sizes="auto, (max-width: 972px) 100vw, 972px" /><figcaption id="caption-attachment-1113" class="wp-caption-text">LOGO EP11 &#8211; Helix 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO helix_1 :s<br />
if :s &lt; 10 [ stop ]<br />
fd :s rt 90<br />
helix_1 :s &#8211; 10<br />
END<br />
cs setxy 0 -100<br />
helix_1 200</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-3</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง helix_1 200 – พบว่า :s มีค่า 200 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 200 pixel หันขวา 90 องศา – เรียกใช้ helix_1 190</li>
<li>คำสั่ง helix_1 190 – พบว่า :s มีค่า 190 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 190 pixel หันขวา 90 องศา – เรียกใช้ helix_1 180</li>
<li>คำสั่ง helix_1 180 – พบว่า :s มีค่า 180 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 180 pixel หันขวา 90 องศา – เรียกใช้ helix_1 170</li>
<li>( ทำเช่นนี้ไปเรื่อยๆ )</li>
<li>คำสั่ง helix_1 30 – พบว่า :s มีค่า 30 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 30 pixel หันขวา 90 องศา – เรียกใช้ helix_1 20</li>
<li>คำสั่ง helix_1 20 – พบว่า :s มีค่า 20 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 20 pixel หันขวา 90 องศา – เรียกใช้ helix_1 10</li>
<li>คำสั่ง helix_1 10 – พบว่า :s มีค่า 10 ซึ่งไม่มากกว่า 10 – จบการทำงาน</li>
</ul>
<p>&nbsp;</p>
<figure id="attachment_1114" aria-describedby="caption-attachment-1114" style="width: 971px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1114" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-2.jpg" alt="LOGO EP11 - Helix 2" width="971" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-2.jpg 971w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-2-300x205.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-2-768x524.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Helix-2-130x90.jpg 130w" sizes="auto, (max-width: 971px) 100vw, 971px" /><figcaption id="caption-attachment-1114" class="wp-caption-text">LOGO EP11 &#8211; Helix 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO helix_2 :s<br />
if :s &lt; 10 [ stop ]<br />
fd :s rt 30<br />
helix_2 :s * 0.95<br />
END<br />
cs setxy 0 -100<br />
helix_2 100</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-4</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง helix_2 100 – พบว่า :s มีค่า 100 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 100 pixel หันขวา 30 องศา – เรียกใช้ helix_2 95</li>
<li>คำสั่ง helix_2 95 – พบว่า :s มีค่า 95 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 95 pixel หันขวา 30 องศา – เรียกใช้ helix_2 90.25</li>
<li>คำสั่ง helix_2 90.25 – พบว่า :s มีค่า 25 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 90.25 pixel หันขวา 30 องศา – เรียกใช้ helix_2 85.74</li>
<li>( ทำเช่นนี้ไปเรื่อยๆ )</li>
<li>คำสั่ง helix_2 11.02 – พบว่า :s มีค่า 30 ซึ่งมากกว่า 02 – วาดเส้นตรง ยาว 11.02 pixel หันขวา 30 องศา – เรียกใช้ helix_2 10.47</li>
<li>คำสั่ง helix_2 10.47 – พบว่า :s มีค่า 20 ซึ่งมากกว่า 47 – วาดเส้นตรง ยาว 10.47 pixel หันขวา 30 องศา – เรียกใช้ helix_2 9.94</li>
<li>คำสั่ง helix_2 9.94 – พบว่า :s มีค่า 94 ซึ่งไม่มากกว่า 10 – จบการทำงาน</li>
</ul>
<p>&nbsp;</p>
<p>ต่อไปเราจะมาวาดรูปใยแมงมุมกันครับ</p>
<figure id="attachment_1119" aria-describedby="caption-attachment-1119" style="width: 972px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1119" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Spiderweb.jpg" alt="LOGO EP11 - Spiderweb" width="972" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Spiderweb.jpg 972w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Spiderweb-300x204.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Spiderweb-768x523.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Spiderweb-130x90.jpg 130w" sizes="auto, (max-width: 972px) 100vw, 972px" /><figcaption id="caption-attachment-1119" class="wp-caption-text">LOGO EP11 &#8211; Spiderweb</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO spiderweb :s<br />
if :s &lt; 10 [ stop ]<br />
fd :s rt 45<br />
spiderweb :s * 0.98<br />
END<br />
cs<br />
spiderweb 100</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-5</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง spiderweb 100 – พบว่า :s มีค่า 100 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 100 pixel หันขวา 45 องศา – เรียกใช้ spiderweb 98</li>
<li>คำสั่ง spiderweb 98 – พบว่า :s มีค่า 98 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 98 pixel หันขวา 45 องศา – เรียกใช้ spiderweb 96</li>
<li>คำสั่ง spiderweb 96 – พบว่า :s มีค่า 96 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 96 pixel หันขวา 45 องศา – เรียกใช้ spiderweb 94</li>
<li>( ทำเช่นนี้ไปเรื่อยๆ )</li>
<li>คำสั่ง spiderweb 10.4 – พบว่า :s มีค่า 4 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 10.4 pixel หันขวา 45 องศา – เรียกใช้ spiderweb 10.2</li>
<li>คำสั่ง spiderweb 10.2 – พบว่า :s มีค่า 2 ซึ่งมากกว่า 10 – วาดเส้นตรง ยาว 10.2 pixel หันขวา 45 องศา – เรียกใช้ spiderweb 9.99</li>
<li>คำสั่ง spiderweb 9.99 – พบว่า :s มีค่า 10 ซึ่งไม่มากกว่า 10 – จบการทำงาน</li>
</ul>
<p>&nbsp;</p>
<p>สุดท้ายเราจะประยุกต์ใช้เทคนิค Recursive ในการวาดรูปต้นไม้กันครับ</p>
<figure id="attachment_1120" aria-describedby="caption-attachment-1120" style="width: 970px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1120" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-1.jpg" alt="LOGO EP11 - Tree 1" width="970" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-1.jpg 970w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-1-300x205.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-1-768x524.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-1-130x90.jpg 130w" sizes="auto, (max-width: 970px) 100vw, 970px" /><figcaption id="caption-attachment-1120" class="wp-caption-text">LOGO EP11 &#8211; Tree 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO my_tree :s<br />
if :s &lt; 10 [ fd :s bk :s stop ]<br />
fd :s / 2<br />
lt 30 my_tree :s /2 rt 30<br />
rt 30 my_tree :s /2 lt 30<br />
fd :s / 2<br />
bk :s<br />
END<br />
cs<br />
my_tree 200</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-6</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง my_tree 200 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 100 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 100 – หันขวา 30 องศา</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 100 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 100 pixel</li>
<li>ถอยหลัง 200 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 100 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 50 – หันขวา 30 องศา</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 50 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>ถอยหลัง 100 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 50 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 25 – หันขวา 30 องศา</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 25 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>ถอยหลัง 50 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 25 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 12 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 12 – หันขวา 30 องศา</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 12 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 12 pixel</li>
<li>ถอยหลัง 25 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 12 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 6 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 6 – หันขวา 30 องศา</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 6 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 6 pixel</li>
<li>ถอยหลัง 12 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 6 – พบว่า :s มีค่า 6 ซึ่งน้อยกว่า 10 – จบการทำงาน</li>
</ul>
<p>เราสามารถวาดแผนภาพแสดงการทำงานได้ดังนี้ครับ (รูปด้านล่างเป็นแค่การทำงานส่วนหนึ่งของโปรแกรมเท่านั้น)</p>
<figure id="attachment_1117" aria-describedby="caption-attachment-1117" style="width: 800px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-large wp-image-1117" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-1-1024x445.jpg" alt="LOGO EP11 - Recursive Tree 1" width="800" height="348" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-1-1024x445.jpg 1024w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-1-300x130.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-1-768x333.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-1.jpg 1366w" sizes="auto, (max-width: 800px) 100vw, 800px" /><figcaption id="caption-attachment-1117" class="wp-caption-text">LOGO EP11 &#8211; Recursive Tree 1</figcaption></figure>
<p>&nbsp;</p>
<p>น้องๆ อาจจะสงสัยว่าทำไมต้นไม้รูปด้านบนดูแปลกๆ เรามาดูต้นไม้รูปด้านล่างกันบ้างครับ</p>
<figure id="attachment_1121" aria-describedby="caption-attachment-1121" style="width: 970px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-1121" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-2.jpg" alt="LOGO EP11 - Tree 2" width="970" height="662" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-2.jpg 970w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-2-300x205.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-2-768x524.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Tree-2-130x90.jpg 130w" sizes="auto, (max-width: 970px) 100vw, 970px" /><figcaption id="caption-attachment-1121" class="wp-caption-text">LOGO EP11 &#8211; Tree 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO my_tree :s<br />
if :s &lt; 10 [ fd :s bk :s stop ]<br />
fd :s / 4<br />
lt 30 my_tree :s *2/3 rt 30<br />
fd :s / 4<br />
rt 30 my_tree :s *1/2 lt 30<br />
fd :s / 4<br />
lt 30 my_tree :s *1/3 rt 30<br />
fd :s / 4<br />
bk :s<br />
END<br />
cs<br />
my_tree 200</td>
</tr>
</tbody>
</table>
<p>โปรแกรมที่ 11-7</p>
<p>อธิบายการทำงานของโปรแกรม</p>
<ul>
<li>คำสั่ง my_tree 200 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 133 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 100 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 67 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 50 pixel</li>
<li>ถอยหลัง 200 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 100 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 66 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 50 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 33 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 25 pixel</li>
<li>ถอยหลัง 100 pixel</li>
</ul>
</li>
<li>คำสั่ง my_tree 50 – พบว่า :s มีค่ามากกว่า 10
<ul>
<li>วาดเส้นตรง ยาว 12.5 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 33 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 12.5 pixel</li>
<li>หันขวา 30 องศา – เรียกใช้ my_tree 25 – หันซ้าย 30 องศา</li>
<li>วาดเส้นตรง ยาว 12.5 pixel</li>
<li>หันซ้าย 30 องศา – เรียกใช้ my_tree 17 – หันขวา 30 องศา</li>
<li>วาดเส้นตรง ยาว 12.5 pixel</li>
<li>ถอยหลัง 50 pixel</li>
</ul>
</li>
<li>( เป็นเช่นนี้ไปเรื่อยๆ )</li>
</ul>
<p>เราสามารถวาดแผนภาพแสดงการทำงานได้ดังนี้ครับ (รูปด้านล่างเป็นแค่การทำงานส่วนหนึ่งของโปรแกรมเท่านั้น)</p>
<figure id="attachment_1118" aria-describedby="caption-attachment-1118" style="width: 800px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-large wp-image-1118" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-2-1024x283.jpg" alt="LOGO EP11 - Recursive Tree 2" width="800" height="221" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-2-1024x283.jpg 1024w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-2-300x83.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-2-768x212.jpg 768w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP11-Recursive-Tree-2.jpg 1366w" sizes="auto, (max-width: 800px) 100vw, 800px" /><figcaption id="caption-attachment-1118" class="wp-caption-text">LOGO EP11 &#8211; Recursive Tree 2</figcaption></figure>
<p>&nbsp;</p>
<p>และนี่คือเรื่องราวของ Recursive Function ทั้งหมดที่นำมาฝากกันในวันนี้ครับ สามารถติดตามตอนต่อไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep11-recursive/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 11 – เริ่มใหม่อีกครั้ง</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep11-recursive/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 10 – รูปดาว</title>
		<link>https://karnlab.com/logo-tutorial-ep10-star/</link>
					<comments>https://karnlab.com/logo-tutorial-ep10-star/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Sun, 15 Jul 2018 16:08:52 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ดาว]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=945</guid>

					<description><![CDATA[<p>วันนี้เราจะมาวาดรูปกันเลยครับ รูปที่เราจะวาดกันในวันนี้ คือ รูปดาว (มีหลายแบบ) หากน้องๆ ไม่เข้าใจคำสั่งไหน ให้ลองกลับไปอ่านตอนเก่าๆ ของ tutorial นี้ดูนะครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep10-star/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 10 – รูปดาว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>วันนี้เราจะมาวาดรูปกันเลยครับ รูปที่เราจะวาดกันในวันนี้ คือ รูปดาว (มีหลายแบบ) หากน้องๆ ไม่เข้าใจคำสั่งไหน ให้ลองกลับไปอ่านตอนเก่าๆ ของ tutorial นี้ดูนะครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 1</strong></p>
<figure id="attachment_929" aria-describedby="caption-attachment-929" style="width: 829px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-929" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-1.jpg" alt="LOGO EP10 - Star 1" width="829" height="369" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-1.jpg 829w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-1-300x134.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-1-768x342.jpg 768w" sizes="auto, (max-width: 829px) 100vw, 829px" /><figcaption id="caption-attachment-929" class="wp-caption-text">LOGO EP10 &#8211; Star 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">rt 18<br />
repeat 5 [ fd 200 rt 144 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>rt 18<br />
คือ เปลี่ยนองศาเต่าโลโก้</li>
<li>fd 200 rt 144<br />
คือ การวาดเส้นตรง</li>
<li>repeat 5 [ fd 200 rt 144 ]<br />
คือ การวาดเส้นตรง 5 ครั้ง (จนกลายเป็นรูปดาว)</li>
</ul>
<p>* เราสามารถซ่อนเต่าโลโก้ ด้วยคำสั่ง ht และแสดงเต่าโลโก้ ด้วยคำสั่ง st</p>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 2</strong></p>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-930" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-2.jpg" alt="LOGO EP10 - Star 2" width="822" height="361" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-2.jpg 822w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-2-300x132.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-2-768x337.jpg 768w" sizes="auto, (max-width: 822px) 100vw, 822px" /></p>
<table>
<tbody>
<tr>
<td width="387">rt 30 repeat 3 [ fd 200 rt 120 ] lt 30<br />
pu fd 120 pd<br />
rt 90 repeat 3 [ fd 200 rt 120 ] lt 90</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>repeat 3 [ fd 200 rt 120 ]<br />
คือ การวาดรูปสามเหลี่ยม</li>
<li>pu fd 120 pd<br />
คือ การย้ายตำแหน่งเต่าโลโก้</li>
</ul>
<ul>
<li>เมื่อเราวาดสามเหลี่ยมสองรูป จะเกิดเป็นรูปดาวแบบนี้</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 3</strong></p>
<figure id="attachment_931" aria-describedby="caption-attachment-931" style="width: 795px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-931" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-3.jpg" alt="LOGO EP10 - Star 3" width="795" height="380" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-3.jpg 795w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-3-300x143.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-3-768x367.jpg 768w" sizes="auto, (max-width: 795px) 100vw, 795px" /><figcaption id="caption-attachment-931" class="wp-caption-text">LOGO EP10 &#8211; Star 3</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">pu fd 100 pd rt 18<br />
repeat 5 [ fd 100 rt 144 fd 100 lt 72 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>pu fd 100 pd<br />
คือ การย้ายตำแหน่งเต่าโลโก้</li>
<li>fd 100 rt 144 fd 100 lt 72<br />
คือ การวาดแฉกของดาว</li>
<li>repeat 5 [ fd 100 rt 144 fd 100 lt 72 ]<br />
คือ การวาดแฉกดาว 5 ครั้ง (กลายเป็นรูปดาว)</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 4</strong></p>
<figure id="attachment_932" aria-describedby="caption-attachment-932" style="width: 707px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-932" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-4.jpg" alt="LOGO EP10 - Star 4" width="707" height="349" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-4.jpg 707w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-4-300x148.jpg 300w" sizes="auto, (max-width: 707px) 100vw, 707px" /><figcaption id="caption-attachment-932" class="wp-caption-text">LOGO EP10 &#8211; Star 4</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">pu fd 75 pd rt 30<br />
repeat 6 [ fd 75 rt 120 fd 75 lt 60 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>pu fd 75 pd<br />
คือ การย้ายตำแหน่งเต่าโลโก้</li>
<li>fd 75 rt 120 fd 75 lt 60<br />
คือ การวาดแฉกของดาว</li>
<li>repeat 6 [ fd 75 rt 120 fd 75 lt 60 ]<br />
คือ การวาดแฉกดาว 6 ครั้ง (กลายเป็นรูปดาว)</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 5</strong></p>
<figure id="attachment_933" aria-describedby="caption-attachment-933" style="width: 774px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-933" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-5.jpg" alt="LOGO EP10 - Star 5" width="774" height="398" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-5.jpg 774w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-5-300x154.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-5-768x395.jpg 768w" sizes="auto, (max-width: 774px) 100vw, 774px" /><figcaption id="caption-attachment-933" class="wp-caption-text">LOGO EP10 &#8211; Star 5</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">pu fd 100 pd<br />
repeat 8 [<br />
rt 15 fd 100 rt 150 fd 100<br />
lt 75 lt 45<br />
]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>คล้ายกับรูปดาว แบบที่ 3 และ 4</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 6</strong></p>
<figure id="attachment_934" aria-describedby="caption-attachment-934" style="width: 750px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-934" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Green.jpg" alt="LOGO EP10 - Star Green" width="750" height="400" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Green.jpg 750w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Green-300x160.jpg 300w" sizes="auto, (max-width: 750px) 100vw, 750px" /><figcaption id="caption-attachment-934" class="wp-caption-text">LOGO EP10 &#8211; Star Green</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">setscreencolor 0<br />
setpencolor 2<br />
setpensize 3rt 15 repeat 2 [ fd 150 rt 150 fd 150 rt 30 ]<br />
rt 75 pu fd 40 lt 90 fd 40 rt 90 pd<br />
rt 15 repeat 2 [ fd 150 rt 150 fd 150 rt 30 ]<br />
lt 15 pu fd 27 rt 90 fd 65 rt 45 pd<br />
rt 15 repeat 2 [ fd 150 rt 150 fd 150 rt 30 ]<br />
rt 75 pu fd 40 lt 90 fd 40 rt 90 pd<br />
rt 15 repeat 2 [ fd 150 rt 150 fd 150 rt 30 ]</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong>รูปดาว แบบที่ 7</strong></p>
<figure id="attachment_951" aria-describedby="caption-attachment-951" style="width: 732px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-951" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Yellow-1.jpg" alt="LOGO EP10 - Star Yellow" width="732" height="406" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Yellow-1.jpg 732w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP10-Star-Yellow-1-300x166.jpg 300w" sizes="auto, (max-width: 732px) 100vw, 732px" /><figcaption id="caption-attachment-951" class="wp-caption-text">LOGO EP10 &#8211; Star Yellow</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">setscreencolor &#8220;#D1EEFE<br />
setpencolor &#8220;gray<br />
setpensize 1pu setxy 0 50 pd rt 18<br />
repeat 5 [ fd 100 rt 144 fd 100 lt 72 ]<br />
pu setxy 0 0 pd lt 18<br />
setpencolor &#8220;yellow<br />
fillsetpencolor &#8220;black<br />
pu setxy 10 20 pd<br />
arc 360 10 fill<br />
pu setxy 50 20 pd<br />
arc 360 10 fill</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>และนี่คือรูปดาวทั้งหมดที่นำมาฝากกันในวันนี้ครับ สามารถติดตามต่อตอนไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep10-star/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 10 – รูปดาว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep10-star/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>วาดรูปด้วยภาษาโลโก้ : ตอนที่ 9 – รูปดอกไม้</title>
		<link>https://karnlab.com/logo-tutorial-ep9-flower/</link>
					<comments>https://karnlab.com/logo-tutorial-ep9-flower/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Sun, 15 Jul 2018 16:02:26 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[LOGO]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ดอกไม้]]></category>
		<category><![CDATA[ภาษาโลโก้]]></category>
		<category><![CDATA[วาดรูป]]></category>
		<category><![CDATA[เขียนโปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=938</guid>

					<description><![CDATA[<p>วันนี้เราจะมาวาดรูปกันเลยครับ รูปที่เราจะวาดกันในวันนี้ คือ รูปดอกไม้ (มีหลายแบบ) หากน้องๆ ไม่เข้าใจคำสั่งไหน ให้ลองกลับไปอ่านตอนเก่าๆ ของ tutorial นี้ดูนะครับ คำสั่งที่น้องๆ จะเจอในบทนี้ คำสั่ง ความสามารถ ตัวอย่าง fd ระยะทาง bk ระยะทาง [&#8230;]</p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep9-flower/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 9 – รูปดอกไม้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>วันนี้เราจะมาวาดรูปกันเลยครับ รูปที่เราจะวาดกันในวันนี้ คือ รูปดอกไม้ (มีหลายแบบ) หากน้องๆ ไม่เข้าใจคำสั่งไหน ให้ลองกลับไปอ่านตอนเก่าๆ ของ tutorial นี้ดูนะครับ</p>
<p>คำสั่งที่น้องๆ จะเจอในบทนี้</p>
<table>
<tbody>
<tr>
<td width="198"><strong>คำสั่ง</strong></td>
<td width="227"><strong>ความสามารถ</strong></td>
<td width="227"><strong>ตัวอย่าง</strong></td>
</tr>
<tr>
<td width="198">fd ระยะทาง<br />
bk ระยะทาง</td>
<td width="227">forward = เดินหน้า<br />
backward = ถอยหลัง</td>
<td width="227">fd 100 = เดินหน้า 100 pixel<br />
bk 50 = ถอยหลัง 50 pixel</td>
</tr>
<tr>
<td width="198">rt องศา<br />
lt องศา</td>
<td width="227">right turn = หมุนขวา<br />
left turn = หมุนซ้าย</td>
<td width="227">rt 90 = หมุนไปทางขวา 90 องศา<br />
lt 45 = หมุนไปทางซ้าย 45 องศา</td>
</tr>
<tr>
<td width="198">repeat จำนวนครั้ง [ คำสั่ง ]</td>
<td width="227">repeat = ทำคำสั่งต่อไปนี้ ซ้ำ n ครั้ง</td>
<td width="227">repeat 3 [ fd 100 rt 120 ]<br />
repeat 4 [ fd 100 rt 90 ]<br />
repeat 6 [ fd 100 rt 60 ]</td>
</tr>
<tr>
<td width="198">TO ชื่อฟังก์ชัน :ตัวแปร<br />
คำสั่ง<br />
END</td>
<td width="227">function = สร้างชุดคำสั่ง</td>
<td width="227">TO square :size<br />
repeat 4 [ fd :size rt 90 ]<br />
END</td>
</tr>
<tr>
<td width="198">cs<br />
clean</td>
<td width="227">clear screen = ล้างหน้าจอ<br />
clean = ล้างหน้าจอ</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">pu<br />
pd</td>
<td width="227">pen up = ยกปากกา<br />
pen down = วางปากกา</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">ht<br />
st</td>
<td width="227">hide turtle = ซ่อนเต่าโลโก้<br />
show turtle = แสดงเต่าโลโก้</td>
<td width="227"></td>
</tr>
<tr>
<td width="198">setxy พิกัดx พิกัดy</td>
<td width="227">set (x,y) = กำหนดตำแหน่งเต่าโลโก้</td>
<td width="227">setxy 200 100</td>
</tr>
<tr>
<td width="198">setpensize ขนาด<br />
setpencolor รหัสสี<br />
fill<br />
setscreencolor รหัสสี</td>
<td width="227">set pen size = กำหนดขนาดปากกา<br />
set pen color = กำหนดสีปากกา<br />
fill = ระบายสี<br />
set screen color = กำหนดสีพื้นหลัง</td>
<td width="227">setpensize 5<br />
setpencolor 10<br />
fill<br />
setscreencolor 10</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 1</strong></p>
<figure id="attachment_937" aria-describedby="caption-attachment-937" style="width: 904px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-937" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-1.jpg" alt="LOGO EP9 - Flower 1" width="904" height="406" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-1.jpg 904w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-1-300x135.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-1-768x345.jpg 768w" sizes="auto, (max-width: 904px) 100vw, 904px" /><figcaption id="caption-attachment-937" class="wp-caption-text">LOGO EP9 &#8211; Flower 1</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">fd 150<br />
repeat 4 [<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 180<br />
]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>fd 150<br />
คือ วาดก้านดอกไม้</li>
<li>repeat 90 [ fd 1 rt 1 ]<br />
คือ การวาดรูปครึ่งวงกลม</li>
<li>repeat 90 [ fd 1 rt 1 ] rt 90 repeat 90 [ fd 1 rt 1 ]<br />
คือ การวาดกลีบดอกไม้</li>
</ul>
<p>* เราสามารถซ่อนเต่าโลโก้ ด้วยคำสั่ง ht และแสดงเต่าโลโก้ ด้วยคำสั่ง st</p>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 2</strong></p>
<figure id="attachment_926" aria-describedby="caption-attachment-926" style="width: 881px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-926" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-2.jpg" alt="LOGO EP9 - Flower 2" width="881" height="390" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-2.jpg 881w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-2-300x133.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-2-768x340.jpg 768w" sizes="auto, (max-width: 881px) 100vw, 881px" /><figcaption id="caption-attachment-926" class="wp-caption-text">LOGO EP9 &#8211; Flower 2</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">fd 150<br />
repeat 8 [<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 135<br />
]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>fd 150<br />
คือ วาดก้านดอกไม้</li>
<li>repeat 90 [ fd 1 rt 1 ]<br />
คือ การวาดรูปครึ่งวงกลม</li>
<li>repeat 90 [ fd 1 rt 1 ] rt 90 repeat 90 [ fd 1 rt 1 ]<br />
คือ การวาดกลีบดอกไม้</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 3</strong></p>
<p>* สำหรับรูปนี้ เราจะเขียนฟังก์ชัน leaf เพื่อให้เราเขียนคำสั่งวาดกลีบดอกไม้ได้ง่ายขึ้นครับ</p>
<figure id="attachment_927" aria-describedby="caption-attachment-927" style="width: 892px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-927" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-3.jpg" alt="LOGO EP9 - Flower 3" width="892" height="390" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-3.jpg 892w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-3-300x131.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-3-768x336.jpg 768w" sizes="auto, (max-width: 892px) 100vw, 892px" /><figcaption id="caption-attachment-927" class="wp-caption-text">LOGO EP9 &#8211; Flower 3</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO leaf<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
ENDfd 150 lt 45<br />
repeat 6 [ leaf rt 60 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>fd 150<br />
คือ วาดก้านดอกไม้</li>
<li>leaf<br />
คือ การวาดกลีบดอกไม้</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 4</strong></p>
<figure id="attachment_928" aria-describedby="caption-attachment-928" style="width: 869px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-928" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-4.jpg" alt="LOGO EP9 - Flower 4" width="869" height="374" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-4.jpg 869w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-4-300x129.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-4-768x331.jpg 768w" sizes="auto, (max-width: 869px) 100vw, 869px" /><figcaption id="caption-attachment-928" class="wp-caption-text">LOGO EP9 &#8211; Flower 4</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO leaf<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
ENDlt 105<br />
repeat 5 [ leaf rt 30 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>lt 105<br />
คือ การปรับองศา</li>
<li>leaf<br />
คือ การวาดกลีบดอกไม้</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 5</strong></p>
<figure id="attachment_936" aria-describedby="caption-attachment-936" style="width: 931px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-936" src="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-Colorful.jpg" alt="LOGO EP9 - Flower Colorful" width="931" height="433" srcset="https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-Colorful.jpg 931w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-Colorful-300x140.jpg 300w, https://karnlab.com/wp-content/uploads/2018/07/LOGO-EP9-Flower-Colorful-768x357.jpg 768w" sizes="auto, (max-width: 931px) 100vw, 931px" /><figcaption id="caption-attachment-936" class="wp-caption-text">LOGO EP9 &#8211; Flower Colorful</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO leaf<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1 rt 1 ]<br />
rt 90<br />
ENDTO leaf_fill<br />
rt 45 pu fd 10 pd fill bk 10 lt 45<br />
ENDsetscreencolor &#8220;#D1EEFE</p>
<p>setpencolor &#8220;#F9BC9D<br />
pu setxy -200 0 pd lt 45<br />
repeat 5 [ leaf leaf_fill rt 72 ]</p>
<p>setpencolor &#8220;#F0A2AF<br />
pu setxy 0 0 pd lt 45<br />
repeat 5 [ leaf leaf_fill rt 72 ]</p>
<p>setpencolor &#8220;#DFA2E6<br />
pu setxy 200 0 pd lt 45<br />
repeat 5 [ leaf leaf_fill rt 72 ]</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>leaf<br />
คือ ฟังก์ชันวาดกลีบดอกไม้</li>
<li>leaf_fill<br />
คือ การระบายสีดอกไม้</li>
<li>setscreencolor &#8220;#D1EEFE<br />
คือ ตั้งค่าสีพื้นหลังให้เป็นสีฟ้า</li>
<li>setpencolor &#8220;#F9BC9D<br />
คือ การตั้งค่าสีปากกา</li>
<li>pu setxy -200 0 pd lt 45<br />
คือ การเปลี่ยนตำแหน่งเต่าโลโก้</li>
<li>repeat 5 [ leaf leaf_fill rt 72 ]<br />
คือ การวาดดอกไม้</li>
</ul>
<p>&nbsp;</p>
<p><strong>รูปดอกไม้ แบบที่ 6</strong></p>
<figure id="attachment_757" aria-describedby="caption-attachment-757" style="width: 937px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-full wp-image-757" src="https://karnlab.com/wp-content/uploads/2018/04/LOGO-EP8-Flower-in-the-Morning.png" alt="LOGO EP8 - Flower in the Morning" width="937" height="443" srcset="https://karnlab.com/wp-content/uploads/2018/04/LOGO-EP8-Flower-in-the-Morning.png 937w, https://karnlab.com/wp-content/uploads/2018/04/LOGO-EP8-Flower-in-the-Morning-300x142.png 300w, https://karnlab.com/wp-content/uploads/2018/04/LOGO-EP8-Flower-in-the-Morning-768x363.png 768w" sizes="auto, (max-width: 937px) 100vw, 937px" /><figcaption id="caption-attachment-757" class="wp-caption-text">LOGO EP8 &#8211; Flower in the Morning</figcaption></figure>
<table>
<tbody>
<tr>
<td width="387">TO core<br />
repeat 12 [<br />
repeat 360 [ fd 0.5 rt 1 ] rt 30<br />
]<br />
ENDTO leaf<br />
repeat 90 [ fd 1.5 rt 1 ]<br />
rt 90<br />
repeat 90 [ fd 1.5 rt 1 ]<br />
rt 90<br />
ENDsetscreencolor &#8220;lightcyan<br />
setpencolor &#8220;greenyellow setpensize 8 bk 200 fd 200<br />
setpencolor &#8220;orange setpensize 2 repeat 12 [ leaf rt 30 ]<br />
setpencolor &#8220;brown setpensize 2 core</td>
</tr>
</tbody>
</table>
<p>อธิบายสั้นๆ</p>
<ul>
<li>core<br />
คือ ฟังก์ชันวาดเกสรดอกไม้</li>
<li>leaf<br />
คือ ฟังก์ชันวาดกลีบดอกไม้</li>
<li>setscreencolor “lightcyan<br />
คือ ตั้งค่าสีพื้นหลังให้เป็นสีฟ้า</li>
<li>setpencolor “greenyellow setpensize 8 bk 200 fd 200<br />
คือ วาดก้านดอกไม้</li>
<li>setpencolor “orange setpensize 2 repeat 12 [ leaf rt 30 ]<br />
คือ วาดกลีบดอกไม้</li>
<li>setpencolor “brown setpensize 2 core<br />
คือ วาดเกสรดอกไม้</li>
</ul>
<p>&nbsp;</p>
<p>และนี่คือรูปดอกไม้ทั้งหมดที่นำมาฝากกันในวันนี้ครับ สามารถติดตามต่อตอนไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/ภาษาโลโก้">https://karnlab.com/tag/ภาษาโลโก้</a></p>
<p>The post <a href="https://karnlab.com/logo-tutorial-ep9-flower/">วาดรูปด้วยภาษาโลโก้ : ตอนที่ 9 – รูปดอกไม้</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/logo-tutorial-ep9-flower/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: karnlab.com @ 2026-05-03 02:31:21 by W3 Total Cache
-->