# 如何绘制一条优秀的GPA曲线

(1)准备工作

```//
<xyz.rickygao.gpa2.view.GpaLineChartView
android:id="@+id/cv_gpa_line"
android:layout_width="match_parent"
android:layout_height="320dp"
android:background="@color/gpa2_color_secondary"
app:fillColor="@color/gpa2_color_primary"
app:lineColor="@color/gpa2_color_primary_dark"
app:pointColor="@color/gpa2_color_primary_dark" />

//```

(2)绘制思路

• 创建画笔
• 确定上述基准线
• 确定起点，t0，t1… … 终点坐标
• 计算每两点之间三阶贝塞尔曲线路径

(3)代码实现

```//
data class DataWithDetail(val data: Double, val detail: String)
var dataWithDetail: List<DataWithDetail> = emptyList()
//```

```//
val widthStep = contentWidth.toFloat() / (dataWithDetail.size + 1)
//```

```//
val minData = dataWithDetail.minBy(DataWithDetail::data)?.data ?: 0.0
val maxData = dataWithDetail.maxBy(DataWithDetail::data)?.data ?: 1.0
val dataSpan = if (maxData != minData) maxData - minData else 1.0
val minDataExtended = minData - dataSpan / 4F
val maxDataExtended = maxData + dataSpan / 4F
val dataSpanExtended = maxDataExtended - minDataExtended
//```

```//
(0 until dataWithDetail.size).mapTo(pointsX.apply { clear() }) {
paddingLeft + widthStep * (it + 1)
}
//```

```//
dataWithDetail.mapTo(pointsY.apply { clear() }) {
paddingTop + ((1 - ((it.data - minDataExtended) / dataSpanExtended)) * contentHeight).toFloat()
}
//```

```//
var py = (paddingTop + contentHeight).toFloat()
moveTo(0F, py)
//```

```//
val cx = width - widthStep / 2F
//```

```//
drawPath(linePath, linePaint)
//```

```//
fillPath.apply {
reset()
lineTo(width.toFloat(), height.toFloat())
lineTo(0F, height.toFloat())
close()
}
//```

```//
pointPath.apply {
reset()
if (dataWithDetail.isEmpty())
return@apply // no need to draw
(0 until dataWithDetail.size)
.filter { it != selectedIndex }
.forEach {
pointsX[it] - LINE_STROKE / 4F,
pointsY[it] - LINE_STROKE / 4F,
Path.Direction.CCW
)
}
}
//```

（4）细节

```//
(0 until dataWithDetail.size).mapTo(pointsX.apply { clear() })
//```

```//
fillPath.apply {
reset()
lineTo(width.toFloat(), height.toFloat())
lineTo(0F, height.toFloat())
close()
}
//```

```//
var lineColor
get() = linePaint.color
set(value) {
linePaint.color = value
}
//```

## 《微北洋-代码读后感(1)》有113个想法

• 上官轩明说：

多亏画图工具强大，不然就剩一堆代码了0，0

1. oprol evorter说：

very good publish, i certainly love this website, carry on it

2. LesCack说：

3. MatBuct说：

Cialis Crea Dependencia Amoxicillin Yogurt Effect Buy Generic Plavix Online India [url=http://cialibuy.com]Buy Cialis[/url] Comprar Viagra Cialis Generico Blaue Levitra Tanning Amoxicillin

4. LesCack说：

5. KelErex说：

Propecia 4 Month [url=http://cialibuy.com]Cialis[/url] Amoxicillin For Pets Without Prescription Zithromax Good For Strep Throat

6. MatBuct说：

Does Zithromax Cure Chlamydia [url=http://cialibuy.com]cialis[/url] Cialis Vs Levitra Vs Viagra Buy Viagra Online Reviews

7. LesCack说：

Cialis 20 Mg Para Que Sirve [url=http://cialibuy.com]Cialis[/url] Best Buy Discount Clobetasol Saturday Delivery Store Price Baton Rouge Buy Cialis Vosteran

8. LesCack说：

9. MatBuct说：

10. Stevviotly说：

Informacion Sobre La Viagra [url=http://cialibuy.com]tadalafil cialis from india[/url] Cialis Forum Prezzi Cialis Vendita Cialis In Svizzera

11. Stevviotly说：

12. Stevviotly说：

I Want To Buy Original Viagra [url=http://cialisir.com]Buy Cialis[/url] Plavix Buy Usa cialis prices Keflex Liquid Suspension Ingredients

13. LesCack说：

Zithromax Z Pak Dosing [url=http://abuycialisb.com]Cialis[/url] Amoxicillin In Pregnancy Cialis No Prescription Canadian Pharmacy

14. LesCack说：

15. LesCack说：

Best Place To Buy Tretinoin 0.05 [url=http://cheapcialisir.com]Buy Cialis[/url] Viagra 8000mg order cialis online Priligy 60 Mg

16. LesCack说：

17. LesCack说：

Baclofen Achat 25mg [url=http://abcialisnews.com]generic cialis canada[/url] Propecia Engorda Garantia De Satisfaccion cialis 5 mg Amoxicillin Cyp2d6

18. LesCack说：

19. LesCack说：

Cialis O Viagra [url=http://abcialisnews.com]buy generic cialis[/url] Buy Propecia No Prescription Uk Cialis What Are The Dosage Of Propecia

20. Stevviotly说：

Co Amoxil [url=https://buyciallisonline.com/#]cialis online[/url] Comment Utiliser Clomid cialis Cialis 8 Comprimes

21. Stevviotly说：

Kamagra Pfizer Achat [url=http://viacialisns.com/#]Buy Cialis[/url] Propecia Venta Online Buy Cialis Levitra Vardenafil Hydrochloride

22. MatBuct说：

Cialis E Sport [url=https://buyciallisonline.com/#]Buy Cialis[/url] Levitra Que Efectos Tiene Cialis Cialis Tiempo En Hacer Efecto

23. MatBuct说：

Generic Cialis Tadalafil 40 Mg [url=http://abuycialisb.com]generic 5mg cialis best price[/url] Viagra Corazon Cialis Purchase Viagra Australia

24. Elltymn说：

Buy Vigora 50 [url=https://buyciallisonline.com/#]Cialis[/url] What Is Ic Cephalexin Teva Cialis Clomid Essai Ovulation

25. Stevviotly说：

Calgary Online Order For Man Enhancer [url=http://viacialisns.com/#]Cialis[/url] Aromadex Cialis Safe To Buy Viagra Online

26. Elltymn说：

27. Elltymn说：

Cephalexin Interaction [url=http://apcialisle.com/#]cialis 20mg for sale[/url] Worldwide isotretinoin by money order in usa price Buy Cialis Where To Buy Tamoxifen Online

28. StepBarma说：

Cialis Online Bestellen Schnell [url=https://apcialisle.com/#]Cialis[/url] Pyridium 200mg By Money Order Cialis Cialis Wirkung Alkohol

29. StepBarma说：

Ciprofloxacine France [url=https://apcialisle.com/#]cialis vs viagra[/url] Cytotec Comprar Cialis Cialis Vente Libre

30. StepBarma说：

Clomid Diamicron [url=http://apcialisle.com/#]Buy Cialis[/url] Indian Pharmacy Clomid Buy Cialis Zithromax Is Used To Treat

31. StepBarma说：

Ultima Hora Para Tomar Propecia [url=http://apcialisle.com/#]Cialis[/url] Echo Cialis cialis Isotretinoin Skin Health Website On Line

32. Janteems说：

Amertripaline On Salle [url=http://apcialisle.com/#]Buy Cialis[/url] Leukemia By Antibiotic Amoxicillin Buy Cialis Acheter Viagra Discret

33. StepBarma说：

How To Buy Bentyl 20mg [url=http://apcialisle.com/#]generic cialis[/url] Cialis 20 Mg Walgreens order cialis online Side Affect To Cephalexin

34. StepBarma说：

Reputable Suppliers Of Generic Viagra [url=http://apcialisle.com/#]cialis 5mg[/url] Drugstore Online Buy Cialis No Prescription Discount Pharmacy

35. StepBarma说：

Dog Antibiotics Amoxicillin [url=http://apcialisle.com/#]Cialis[/url] Buy Amoxicillin In Australia cialis 5mg best price Sildenafil Citrate

36. StepBarma说：

Buy Now Fedex Shipping Doryx Tablet Medicine Visa [url=https://apcialisle.com/#]Cialis[/url] Kamagra Kautabletten cialis 5mg Piriton Mix Keflex

37. Janteems说：

Cialis Rezeptfrei Bestellen [url=https://buyciallisonline.com/#]cialis dosage[/url] Propecia O Finasterida Cialis Viagra Substitutes That Work

38. easelay说：
39. excano说：

Our games allow our online casino players to play at their own pace, without any pressure to make a fast decision or bet before the betting time is over.
free online casino All of our recommended real money casinos offer the best casino games online, with hundreds of games provided by the best software developers in the industry.

40. Kayaph说：

When you assign your task to an experienced writer, then you are assured that it will be done excellently, and according to the current academic standards.
write my paper for me They charge you per page, rather than per word, so you might have to end up paying way more than you should, just because their system does not allow you to set a specific word goal.

41. Janteems说：

Vagra [url=http://cialibuy.com/#]reddit cialis online[/url] Rash Zithromax Cialis Kamagra Oral Jelly Jak Zazywac

42. chaita说：

This will ensure that although the students do not get to improve themselves through learning while coming up with the essays, they learn from the information that they acquire. write my paper cheap It is worth noting that child labour leads to the denial of the chance of school attendance among children and harms them mentally, physically, morally, and socially.

43. ensush说：

To make this process easy, you need to validate any shortlisted website with various criteria such as using google search reviews, prices, and discount reviews. custom paper Our support team goes through your requirements and delegates the task to a suitable writer based on your subject, topic, educational level, and deadline.

44. Duernjep说：

We have been writing college papers for many years and have got a great number of returning customers who are satisfied with the quality of our custom college papers. paper help If you are among the many students in any of the categories mentioned above or are just having difficulties with your writing, you can buy essay from a reliable online writing service like samedayessay.

This will be ready for your stay, howveer if you do not wish to use this then please contact us and we will arrange for it to be folded and put in its storage area. wincustomerswebsites.com Indonesia, details of their exhibitions, of the museums which hold their works ands lists of related books and literature for further study.

46. excano说：

A repository provides an opportunity to increase the quality of teaching by repeated usage of good tasks, especially across different universities. authorecourses Erlebte andererseits, signe, hast pfotenspuren pendeln kostenlos markiert, an dreispitzigen richterhut.

47. Wearpmum说：

Ophthalmoscopy in his sister showed peripheral pigmentary changes with only minor functional abnormalities. fron tech nigeria Along with the workbook, it leads you to a greater understanding and empathy towards yourself and partner.

48. lyclasT说：

Er hat nie etwas dagegen ausgesagt, aber er sagt sowieso nie etwas aus, was gegen ihm verwendet werden kann. frontechnigeria Jahren 2100, 2400, 2700, 3000,3300, 3600, 3900, 4300, 4600, 4900, 5200, 5500,5800, 6100, 6400, 6800 u.

49. Janteems说：

Keflex And Anxiousness [url=https://apcialisle.com/#]Cialis[/url] Buy Viagra Online In The Us Cialis Priligy Uk

50. Spafdype说：

An intensely emotional skyward journey, the three-piece have long mulled over their music, crafting indie slacker rock, ready to flirt with moments of soaring pop. tgu-tommyguns Tartaros quoque latet, nam licet pedibus regant habenas, nesciunt tamen torquere, attrahere, et extendere per trocleam staffarum.

51. impaito说：

Bei mir sieht es nicht besser aus, ich bin verzweifelt, immerzu traurig und absolut unzufrieden mit allem. gmp course online And for those of you who are older, you carry wisdom and maturity that is lacking in the younger generation and you still have much to contribute.

52. smore traiolit说：

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?

53. acim spain说：

As a Newbie, I am continuously searching online for articles that can help me. Thank you

54. best CBD Oil说：

Hello! This is kind of off topic but I need some guidance from an established blog. Is it difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to start. Do you have any points or suggestions? Thanks|

55. Janteems说：

Que Es El Kamagra [url=https://cheapcialisir.com/#]daily cialis online[/url] Levitra Efficacite cheapest cialis Propecia Und Testosteron

56. pabooro说：

Cialis Super Active is cheap and the best solution to erectile dysfunction. Get it now and immediately reap the rewards of a better sex life! Package buy cialis generic Precautions:it is meanwhile advised to avoid consuming this canadian viagra concentration under the cheap cialis overnight no prescription karel of wastewater.

57. Duathy说：
58. agen bandarQ说：

For hottest information you have to go to see world-wide-web and on internet I found
this web site as a most excellent website for most up-to-date updates.

59. finnasp说：

Precio Cialis Generico 20 Mg [url=https://ascialis.com/]generic cialis[/url] cialis nouveau canadian pharmacy cialis Prix Cialis Tunisie

60. KeneUpser说：

Buy Cialis Germany [url=https://agenericcialise.com/]Cialis[/url] Buy Accutane In Usa30 Mg Accutane From Canada Online cialis 20mg for sale On Line Free Shipping Dutasteride Internet Medication Shop Overseas

61. weifierge说：

Lioresal En Ligne France [url=https://agenericcialise.com/]Cialis[/url] Secure Ordering Progesterone Amex Accepted Tablets Generic Cialis Cephalexin 500mg Color

62. weifierge说：

Buy Amoxicillin 500mg Capsules [url=https://agenericcialise.com/]Cialis[/url] Best Buy Doxycycline Generic Cialis Viagra En Vente Libre Belgique

63. KeneUpser说：

64. grolyrto lemcs说：

I do accept as true with all of the ideas you have offered on your post. They are very convincing and will definitely work. Nonetheless, the posts are very brief for starters. May just you please extend them a little from subsequent time? Thank you for the post.

65. KeneUpser说：

Cheap Doryx No Prescription Needed [url=https://cheapcialisll.com/]Cialis[/url] Amoxicillin Rash Cialis Healthy Meds Viagra

66. generic cialis说：

Get Generic Cheapeast Provera Medication Shop soinaisrurse [url=https://bbuycialisss.com/#]cheap cialis generic online[/url] Calign acheter du cialis belgique Nesarracle Buy Cialis Iconiannit Zithromax For Syphilis

67. WimJaild说：

68. YonJaild说：

69. TedJaild说：

70. BooJaild说：

71. ZakJaild说：

72. BeardenSwanHinee说：

walmart pharmacy cialis cost

[url=https://ciasale20.com/]online cialis[/url]
cialis

cialis en lnea annimo

73. TeoJaild说：

[url=https://dapoxetinetabs.com/]dapoxetine pills[/url]

74. BooJaild说：

[url=http://wellbutrinbupropion.com/]price of wellbutrin 100 mg[/url] [url=http://xenical24.com/]buy xenical[/url] [url=http://amoxicillinz.com/]buy amoxicillin online[/url] [url=http://silagra24.com/]buy silagra[/url] [url=http://priligytab.com/]priligy tablets over the counter[/url] [url=http://clonidinenorx.com/]clonidine medication[/url] [url=http://vermox.us.org/]purchase vermox[/url]

75. TeoJaild说：

[url=https://erythromycinz.com/]erythromycin 500mg[/url]

76. Animal Porn说：

Good day! This is my first comment here so I just wanted to give a quick shoutout and tell you I really enjoy reading through your articles.Can you recommend any other blogs/websites/forums that cover the sametopics? Thank you!

77. generic cialis说：

Viagra Ai Ragazzi soinaisrurse [url=https://bbuycialisss.com/#]Buy Cialis[/url] Calign Levothyrox No Prescription Nesarracle Cialis Iconiannit Propecia Work Long Term

78. OstroskyPeytynnHinee说：

viagra nombre de la droga

[url=https://frviagrafrance.com/]viagra compresse 50 mg prezzo[/url]
viagra vente

can i take to viagra a day

79. ZakJaild说：

80. TedJaild说：

[url=https://furosemidelasix.com/]furosemide tablet price[/url] [url=https://priligytab.com/]can i buy priligy in usa[/url] [url=https://wellbutrinbupropion.com/]wellbutrin hcl[/url] [url=https://xenical24.com/]xenical canada price[/url] [url=https://finpecia911.com/]finpecia online[/url] [url=https://kamagratb.com/]kamagra jelly[/url] [url=https://atorvastatin.us.com/]lipitor atorvastatin[/url] [url=https://erythromycinz.com/]erythromycin 400mg[/url]

81. ZakJaild说：

82. YonJaild说：

83. TeoJaild说：

84. cialis online说：

Viagra Pfizer Generika Jeososmorb [url=https://ascialis.com/#]buy cialis canada[/url] byboarmalm prix levitra casablanca Feemia generic cialis 20mg annony Cialis Immagini

85. WimJaild说：

[url=http://valtrex.us.org/]valtrex without prescription[/url]

86. BooJaild说：

[url=http://silagra24.com/]buy silagra online[/url] [url=http://clonidinenorx.com/]clonidine 0.4 mg[/url] [url=http://amoxicillinz.com/]antibiotics amoxicillin[/url] [url=http://dapoxetinetabs.com/]dapoxetine 60 mg online purchase in india[/url]

87. ZakJaild说：

[url=https://xenical24.com/]xenical 120 mg[/url] [url=https://baclofen24.com/]baclofen 10mg[/url] [url=https://ciprofloxacin24.com/]buy ciprofloxacin online[/url] [url=https://clonidinenorx.com/]clonidine 0.1[/url] [url=https://priligytab.com/]priligy buy online[/url]

88. YonJaild说：

[url=https://avanatop.com/]buy avana 200 mg[/url] [url=https://hydroxychloroquine.us.org/]hydroxychloroquine online[/url] [url=https://sildenafil36.com/]sildenafil 100mg[/url]

89. TeoJaild说：

[url=https://dapoxetinetabs.com/]dapoxetine online pharmacy[/url]

90. UgoJaild说：

[url=http://levitra36.com/]levitra cost south africa[/url] [url=http://dapoxetinetabs.com/]buy dapoxetine[/url] [url=http://buspar.us.com/]buy buspar[/url] [url=http://priligytab.com/]priligy usa[/url] [url=http://silagra24.com/]silagra soft[/url] [url=http://isotretinoinacutane.com/]accutane order online[/url]

91. AshJaild说：

92. UgoJaild说：

[url=http://kamagratb.com/]buy kamagra[/url] [url=http://priligytab.com/]priligy pills over the counter[/url] [url=http://finpecia911.com/]buy finpecia[/url] [url=http://furosemidelasix.com/]furosemide 20mg[/url] [url=http://singulair.us.org/]buy singulair[/url] [url=http://sildenafil36.com/]sildenafil 100 mg[/url] [url=http://hydroxychloroquine.us.org/]hydroxychloroquine sulfate[/url]

93. BooJaild说：