DrawScope: Çizgiler, Dikdörtgenler ve Daireler
Temel şekilleri tuval üzerine çizin.
DrawScope: Çizgiler, Dikdörtgenler ve Daireler, CoddyKit'te ücretsiz bir Jetpack Compose Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Jetpack Compose Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Meet the Canvas
The Canvas Composable hands you a blank drawing surface. Inside it you paint pixels directly instead of stacking other Composables.
Canvas(modifier = Modifier.size(200.dp)) {
// drawing goes here
}Inside DrawScope
The lambda you pass to Canvas runs inside a DrawScope. That receiver gives you draw functions and the current size to work with.
Know Your Size
DrawScope exposes size, the area you can paint. Read size.width and size.height so your art scales to whatever space it gets.
Canvas(Modifier.fillMaxSize()) {
val w = size.width
val h = size.height
}Draw a Line
Use drawLine to connect two points. You pass a color, a start Offset, an end Offset, and a stroke width.
drawLine(
color = Color.Blue,
start = Offset(0f, 0f),
end = Offset(size.width, size.height),
strokeWidth = 4f
)Pixels Are Floats
Every coordinate here is a Float in pixels, not dp. The origin (0,0) sits at the top-left and x grows right, y grows down.
Offset Points the Way
An Offset is just an x and y pair. You will build almost every shape position from Offsets, so they show up everywhere on the canvas.
val center = Offset(size.width / 2, size.height / 2)Draw a Rectangle
Call drawRect with a color, a topLeft Offset, and a Size. Leave topLeft out and it fills the whole canvas for you.
drawRect(
color = Color.Green,
topLeft = Offset(20f, 20f),
size = Size(100f, 60f)
)Draw a Circle
Use drawCircle with a color, a radius, and a center Offset. Center it on the canvas and you get a perfectly placed dot.
drawCircle(
color = Color.Red,
radius = 50f,
center = center
)Fill or Stroke
Each shape takes a style. The default is solid Fill, but pass Stroke to draw just the outline with a width you choose.
drawCircle(
color = Color.Black,
radius = 50f,
style = Stroke(width = 6f)
)Control Transparency
Pass an alpha between 0f and 1f to fade any shape. Stack a few translucent circles and you get a soft layered glow.
drawCircle(color = Color.Magenta, radius = 60f, alpha = 0.4f)Order Is Layering
Draw calls paint in order, so later shapes sit on top of earlier ones. Think of it like dropping cutouts onto a page one by one.
Quick Check
Where does the canvas coordinate system begin?
Recap
You learned the Canvas basics: draw inside DrawScope, read size, and paint lines, rects, and circles with Offsets and float pixels. Order is everything! 🎨
Sıkça Sorulan Sorular
“DrawScope: Çizgiler, Dikdörtgenler ve Daireler” dersi ücretsiz mi?
Evet — “DrawScope: Çizgiler, Dikdörtgenler ve Daireler” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Jetpack Compose Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.
“DrawScope: Çizgiler, Dikdörtgenler ve Daireler” dersinde ne öğreneceğim?
Temel şekilleri tuval üzerine çizin. Jetpack Compose Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Jetpack Compose Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Jetpack Compose Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.
“DrawScope: Çizgiler, Dikdörtgenler ve Daireler” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Jetpack Compose Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Jetpack Compose Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- DrawScope: Çizgiler, Dikdörtgenler ve Daireler
- Yollar, Degradeler ve Karıştırma Modları
- drawWithCache ve Performans
- Canlı İlerleme Halkası Oluşturma