<?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>เคลื่อนไหว Archives - KarnLab</title>
	<atom:link href="https://karnlab.com/tag/%e0%b9%80%e0%b8%84%e0%b8%a5%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%99%e0%b9%84%e0%b8%ab%e0%b8%a7/feed/" rel="self" type="application/rss+xml" />
	<link>https://karnlab.com/tag/เคลื่อนไหว/</link>
	<description>Blog รีวิว หนังสือ เขียนโปรแกรม นานาสาระ</description>
	<lastBuildDate>Sat, 19 Jan 2019 10:10:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://karnlab.com/wp-content/uploads/2017/12/Logo-150x150.png</url>
	<title>เคลื่อนไหว Archives - KarnLab</title>
	<link>https://karnlab.com/tag/เคลื่อนไหว/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>สร้างเกมส์ด้วย Scratch : ตอนที่ 2 – ตัวอักษรเคลื่อนไหว</title>
		<link>https://karnlab.com/scratch-ep2-animated-text/</link>
					<comments>https://karnlab.com/scratch-ep2-animated-text/#respond</comments>
		
		<dc:creator><![CDATA[Admin]]></dc:creator>
		<pubDate>Thu, 10 Jan 2019 11:28:26 +0000</pubDate>
				<category><![CDATA[สอนเขียนโปรแกรม]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scratch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ตัวอักษร]]></category>
		<category><![CDATA[บทเรียน]]></category>
		<category><![CDATA[เกมส์]]></category>
		<category><![CDATA[เคลื่อนไหว]]></category>
		<category><![CDATA[โปรแกรม]]></category>
		<guid isPermaLink="false">http://karnlab.com/?p=1829</guid>

					<description><![CDATA[<p>สวัสดีครับน้องๆ วันนี้เราจะมาเขียนโปรแกรมภาษา Scratch เพื่อสร้างตัวอักษรเคลื่อนไหวกันครับ สำหรับวิธีการใช้งานโปรแกรม Scratch – น้องๆ สามารถอ่านได้ที่ https://karnlab.com/scratch-ep1-lets-start/ &#160; เลือกตัวอักษร คลิกที่ไอคอนรูปตัวละคร (อยู่ที่แถบ Sprites – สังเกตที่ข้างๆ ข้อความ New Sprite) [&#8230;]</p>
<p>The post <a href="https://karnlab.com/scratch-ep2-animated-text/">สร้างเกมส์ด้วย Scratch : ตอนที่ 2 – ตัวอักษรเคลื่อนไหว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>สวัสดีครับน้องๆ วันนี้เราจะมาเขียนโปรแกรมภาษา Scratch เพื่อสร้างตัวอักษรเคลื่อนไหวกันครับ</p>
<p>สำหรับวิธีการใช้งานโปรแกรม Scratch – น้องๆ สามารถอ่านได้ที่ <a href="https://karnlab.com/scratch-ep1-lets-start/">https://karnlab.com/scratch-ep1-lets-start/</a></p>
<p>&nbsp;</p>
<h2>เลือกตัวอักษร</h2>
<ol>
<li>คลิกที่ไอคอนรูปตัวละคร (อยู่ที่แถบ Sprites – สังเกตที่ข้างๆ ข้อความ New Sprite)</li>
</ol>
<figure id="attachment_1814" aria-describedby="caption-attachment-1814" style="width: 527px" class="wp-caption alignnone"><img fetchpriority="high" decoding="async" class="size-full wp-image-1814" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-1.jpg" alt="Scratch - EP2 (1)" width="527" height="219" /><figcaption id="caption-attachment-1814" class="wp-caption-text">Scratch &#8211; EP2 (1)</figcaption></figure>
<ol start="2">
<li>เลือก Category: Letters – เลือกตัวอักษรที่ต้องการ (จะเป็นตัวอักษรแรกของชื่อเล่น ชื่อที่ชอบ หรือ คำศัพท์ภาษาอังกฤษอะไรก็ได้ครับ)</li>
</ol>
<figure id="attachment_1815" aria-describedby="caption-attachment-1815" style="width: 1318px" class="wp-caption alignnone"><img decoding="async" class="size-full wp-image-1815" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-2.jpg" alt="Scratch - EP2 (2)" width="1318" height="655" /><figcaption id="caption-attachment-1815" class="wp-caption-text">Scratch &#8211; EP2 (2)</figcaption></figure>
<ol start="3">
<li>เอารูปแมวออก – ด้วยการคลิกขวาที่รูปแมว ในแถบ Sprites – จากนั้นคลิก Delete</li>
</ol>
<figure id="attachment_1816" aria-describedby="caption-attachment-1816" style="width: 494px" class="wp-caption alignnone"><img decoding="async" class="size-full wp-image-1816" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-3.jpg" alt="Scratch - EP2 (3)" width="494" height="255" /><figcaption id="caption-attachment-1816" class="wp-caption-text">Scratch &#8211; EP2 (3)</figcaption></figure>
<p>&nbsp;</p>
<h2>ใส่เอฟเฟกต์</h2>
<p>ต่อไป เราจะทำให้ตัวอักษรเปลี่ยนสี เมื่อเราคลิกที่ตัวอักษรนะครับ</p>
<p>4.1) ที่แถบ Scripts ให้คลิกที่คำว่า Events (สีน้ำตาล) – ลากกล่องที่เขียนว่า [ when this spike clicked ] มาวางไว้ที่พื้นที่ว่างด้านขวา</p>
<p>4.2) ที่แถบ Scripts ให้คลิกที่คำว่า Looks (สีม่วง) – ลากกล่องที่เขียนว่า [ change color effect by 25 ] มาต่อข้างล่างกล่อง [ when this spike clicked ]</p>
<figure id="attachment_1817" aria-describedby="caption-attachment-1817" style="width: 1040px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1817" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-4.jpg" alt="Scratch - EP2 (4)" width="1040" height="601" /><figcaption id="caption-attachment-1817" class="wp-caption-text">Scratch &#8211; EP2 (4)</figcaption></figure>
<p>เมื่อเราคลิกที่ตัวอักษร จะพบว่าสีเปลี่ยนไป</p>
<p>&nbsp;</p>
<h2>ใส่เสียง</h2>
<ol start="5">
<li>ที่แถบ Scripts ให้คลิกที่คำว่า Looks (สีม่วง) – ลากกล่องที่เขียนว่า [ play sound pop ] มาต่อข้างล่างกล่อง [ change color effect by 25 ]</li>
</ol>
<figure id="attachment_1818" aria-describedby="caption-attachment-1818" style="width: 1040px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1818" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-5.jpg" alt="Scratch - EP2 (5)" width="1040" height="600" /><figcaption id="caption-attachment-1818" class="wp-caption-text">Scratch &#8211; EP2 (5)</figcaption></figure>
<p>เมื่อเราคลิกที่ตัวอักษร เราจะได้ยินเสียง (อย่าลืมเปิดลำโพงด้วยนะครับ)</p>
<p>&nbsp;</p>
<p>นอกจากนี้เราสามารถเพิ่มเสียงเอฟเฟกต์เพิ่มเติมได้โดย คลิกที่แถบ Sounds – ข้างล่างข้อความ New Sound ใหคลิกไอคอนลำโพง</p>
<figure id="attachment_1819" aria-describedby="caption-attachment-1819" style="width: 1033px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1819" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-5-1.jpg" alt="Scratch - EP2 (5-1)" width="1033" height="594" /><figcaption id="caption-attachment-1819" class="wp-caption-text">Scratch &#8211; EP2 (5-1)</figcaption></figure>
<p>เลือกเสียงที่ต้องการ แล้วกดปุ่ม OK</p>
<figure id="attachment_1820" aria-describedby="caption-attachment-1820" style="width: 1330px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1820" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-5-2.jpg" alt="Scratch - EP2 (5-2)" width="1330" height="663" /><figcaption id="caption-attachment-1820" class="wp-caption-text">Scratch &#8211; EP2 (5-2)</figcaption></figure>
<p>&nbsp;</p>
<h2>ใส่พื้นหลัง</h2>
<p>ต่อไป เราจะมาใส่พื้นหลังกันครับ</p>
<p>6.1) ที่แถบ Sprites ข้างล่างข้อความ New Backdrop คลิกไอคอนรูปภาพ</p>
<figure id="attachment_1821" aria-describedby="caption-attachment-1821" style="width: 491px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1821" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-6-1.jpg" alt="Scratch - EP2 (6-1)" width="491" height="189" /><figcaption id="caption-attachment-1821" class="wp-caption-text">Scratch &#8211; EP2 (6-1)</figcaption></figure>
<p>6.2) เลือกรูปภาพที่ต้องการ แล้วกดปุ่ม OK</p>
<figure id="attachment_1822" aria-describedby="caption-attachment-1822" style="width: 1320px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1822" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-6-2.jpg" alt="Scratch - EP2 (6-2)" width="1320" height="659" /><figcaption id="caption-attachment-1822" class="wp-caption-text">Scratch &#8211; EP2 (6-2)</figcaption></figure>
<p>&nbsp;</p>
<h2>ใส่ตัวอักษรถัดไป</h2>
<ol start="7">
<li>เพิ่มตัวอักษรถัดไปครับ (ใครลืมวิธีเพิ่มตัวอักษร ให้กลับไปอ่านข้อ 1-2 ใหม่นะครับ)</li>
</ol>
<figure id="attachment_1823" aria-describedby="caption-attachment-1823" style="width: 1036px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1823" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-7.jpg" alt="Scratch - EP2 (7)" width="1036" height="592" /><figcaption id="caption-attachment-1823" class="wp-caption-text">Scratch &#8211; EP2 (7)</figcaption></figure>
<p>&nbsp;</p>
<h2>หมุนหมุน</h2>
<p>ต่อไป เราจะเพิ่มเอฟเฟกต์ให้ตัวอักษรหมุนได้ครับ</p>
<p>8.1) ที่แถบ Sprites คลิกที่ A-GLOW – ที่แถบ Scripts คลิกคำว่า Events (สีน้ำตาล) – ลากกล่องที่เขียนว่า [ when this spike clicked ] มาวางไว้ที่พื้นที่ว่างด้านขวา</p>
<p>8.2) ที่แถบ Scripts คลิกคำว่า Motions (สีน้ำเงิน) – ลากกล่องที่เขียนว่า [ turn &#8211;&gt; 15 15 degrees ] มาต่อข้างล่างกล่อง [ when this spike clicked ]</p>
<figure id="attachment_1824" aria-describedby="caption-attachment-1824" style="width: 1040px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1824" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-8-2.jpg" alt="Scratch - EP2 (8-2)" width="1040" height="593" /><figcaption id="caption-attachment-1824" class="wp-caption-text">Scratch &#8211; EP2 (8-2)</figcaption></figure>
<p>เมื่อเราคลิกที่ตัวอักษร ก็จะหมุนไปทางขวาครั้งละ 15 องศาครับ</p>
<p>&nbsp;</p>
<p>แล้วถ้าเราต้องการให้ตัวอักษรหมุน 360 องศา ?</p>
<p>8.3) ที่แถบ Scripts คลิกคำว่า Controls (สีส้ม) – ลากกล่องที่เขียนว่า [ repeat 10 ] มาครอบกล่อง [turn &#8211;&gt; 15 15 degrees ] – จากนั้นเปลี่ยนค่าเป็น [ repeat 24 ] – เมื่อเราคลิกที่ตัวอักษร ก็จะหมุนครบ 1 รอบพอดีครับ</p>
<figure id="attachment_1825" aria-describedby="caption-attachment-1825" style="width: 1030px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1825" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-8-3.jpg" alt="Scratch - EP2 (8-3)" width="1030" height="597" /><figcaption id="caption-attachment-1825" class="wp-caption-text">Scratch &#8211; EP2 (8-3)</figcaption></figure>
<p>&nbsp;</p>
<h2>ใส่ตัวอักษรให้ครบ</h2>
<p>สุดท้าย เพิ่มตัวอักษรให้ครบครับ</p>
<figure id="attachment_1826" aria-describedby="caption-attachment-1826" style="width: 1034px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1826" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-8-5.jpg" alt="Scratch - EP2 (8-5)" width="1034" height="592" /><figcaption id="caption-attachment-1826" class="wp-caption-text">Scratch &#8211; EP2 (8-5)</figcaption></figure>
<p>&nbsp;</p>
<p>ก่อนจากกัน เราจะเพิ่มเทคนิค/เอฟเฟกต์กันอีกนิดครับ</p>
<ol start="9">
<li>เปลี่ยนขนาดตัวอักษร – ให้น้องๆ ลองลากกล่องคำสั่งตามรูปภาพข้างล่างนะครับ แล้วลองสังเกตผลลัพธ์</li>
</ol>
<figure id="attachment_1827" aria-describedby="caption-attachment-1827" style="width: 1034px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1827" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-9.jpg" alt="Scratch - EP2 (9)" width="1034" height="597" /><figcaption id="caption-attachment-1827" class="wp-caption-text">Scratch &#8211; EP2 (9)</figcaption></figure>
<p>&nbsp;</p>
<ol start="10">
<li>ตัวอักษรเคลื่อนที่ &#8211; ให้น้องๆ ลองลากกล่องคำสั่งตามรูปภาพข้างล่างนะครับ แล้วลองสังเกตผลลัพธ์</li>
</ol>
<figure id="attachment_1828" aria-describedby="caption-attachment-1828" style="width: 1035px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full wp-image-1828" src="https://karnlab.com/wp-content/uploads/2019/01/Scratch-EP2-10.jpg" alt="Scratch - EP2 (10)" width="1035" height="593" /><figcaption id="caption-attachment-1828" class="wp-caption-text">Scratch &#8211; EP2 (10)</figcaption></figure>
<p>&nbsp;</p>
<p>น้องๆ สามารถติดตามสร้างเกมส์ด้วย Scratch ตอนต่อไปได้ที่นี่ครับ <a href="https://karnlab.com/tag/scratch/">https://karnlab.com/tag/scratch/</a></p>
<p>สำหรับโปรเจคทั้งหมด สามารถเข้าไปเยี่ยมชมได้ที่นี่ครับ <a href="https://scratch.mit.edu/users/doctorkarn/">https://scratch.mit.edu/users/doctorkarn/</a></p>
<p><strong>หมายเหตุ:</strong> บทเรียนนี้เขียนตอน Scratch 2.0 นะครับ ตอนนี้เป็น Scratch 3.0 แล้ว อาจจะมีบางส่วนเปลี่ยนไปบ้าง แต่คำสั่งส่วนใหญ่ยังเหมือนเดิมครับ</p>
<p>&nbsp;</p>
<p>The post <a href="https://karnlab.com/scratch-ep2-animated-text/">สร้างเกมส์ด้วย Scratch : ตอนที่ 2 – ตัวอักษรเคลื่อนไหว</a> appeared first on <a href="https://karnlab.com">KarnLab</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://karnlab.com/scratch-ep2-animated-text/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>
	</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-06-28 06:07:58 by W3 Total Cache
-->