0Pricing
Jetpack Compose Academy · บทเรียน

เส้นพาธ ไล่ระดับสี และโหมดผสม

สร้างการเติมสีและเส้นขอบที่ซับซ้อน

เส้นพาธ ไล่ระดับสี และโหมดผสม เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Jetpack Compose Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Beyond Simple Shapes

Lines and circles are great, but real graphics need curves and rich fills. Meet Path, gradients, and blend modes for that next level.

What Is a Path

A Path is a recorded outline you build point by point. You move and line your way around, then draw the finished shape in one call.

val path = Path()
path.moveTo(0f, 0f)
path.lineTo(100f, 0f)

moveTo and lineTo

Use moveTo to lift the pen to a start point, then lineTo to draw straight segments. Chain them to trace any polygon you like.

path.moveTo(0f, 0f)
path.lineTo(80f, 120f)
path.lineTo(160f, 0f)
path.close()

Curves with quadraticBezierTo

For smooth bends use quadraticBezierTo. A control point pulls the line into a curve, perfect for soft chart edges.

path.quadraticBezierTo(50f, -40f, 100f, 0f)

Draw the Path

Once built, hand the path to drawPath with a color or brush. You can fill it solid or outline it with a Stroke style.

drawPath(path = path, color = Color.Blue)

Meet the Brush

A Brush describes how an area is painted. Instead of a flat color, a brush can pour a smooth gradient across your shape.

Linear Gradients

Use Brush.linearGradient to blend colors along a straight line. Pass a list of colors and watch them fade from one to the next.

val brush = Brush.linearGradient(
    listOf(Color.Cyan, Color.Magenta)
)
drawRect(brush = brush)

Radial Gradients

Reach for Brush.radialGradient to blend outward from a center. It is ideal for spotlights, soft buttons, and glowing orbs.

val glow = Brush.radialGradient(
    listOf(Color.White, Color.Blue)
)

Sweep Gradients

A Brush.sweepGradient rotates colors around a center point. It is the secret behind colorful progress rings and rainbow dials.

val sweep = Brush.sweepGradient(
    listOf(Color.Red, Color.Yellow, Color.Red)
)

Meet Blend Modes

A BlendMode decides how a new shape mixes with what is already drawn. Multiply darkens, Screen lightens, and Plus adds light.

drawCircle(
    color = Color.Yellow,
    blendMode = BlendMode.Multiply
)

Layer for Effects

Blend modes shine when shapes overlap. Stack two translucent circles with BlendMode.Plus and their intersection glows brighter.

Quick Check

Which brush rotates colors around a center point?

Recap

You can now build curves with Path, fill shapes with linear, radial, and sweep gradients, and combine them using blend modes. Time to get creative! ✨

คำถามที่พบบ่อย

บทเรียน “เส้นพาธ ไล่ระดับสี และโหมดผสม” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เส้นพาธ ไล่ระดับสี และโหมดผสม” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เส้นพาธ ไล่ระดับสี และโหมดผสม”

สร้างการเติมสีและเส้นขอบที่ซับซ้อน คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “เส้นพาธ ไล่ระดับสี และโหมดผสม” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม

ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. DrawScope: เส้น สี่เหลี่ยม และวงกลม
  2. เส้นพาธ ไล่ระดับสี และโหมดผสม
  3. drawWithCache และประสิทธิภาพ
  4. สร้างวงแหวนความคืบหน้าแบบสด
← กลับไปที่ Jetpack Compose Academy