1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg,os: minimize memory allocation

This commit is contained in:
Delyan Angelov
2020-02-03 05:01:39 +02:00
committed by GitHub
parent 71653273f6
commit da21b50750
4 changed files with 32 additions and 20 deletions

View File

@ -11,14 +11,14 @@ fn arc_vertices(x, y, r, start_angle, end_angle f32, segments int) []f32 {
start_rads := start_angle * 0.0174533 // deg -> rad approx
end_rads := end_angle * 0.0174533
increment := (end_rads - start_rads) / segments
vertices << [x + f32(math.cos(start_rads)) * r, y + f32(math.sin(start_rads)) * r]
vertices << [x + f32(math.cos(start_rads)) * r, y + f32(math.sin(start_rads)) * r] !
mut i := 1
for i < segments {
theta := f32(i) * increment + start_rads
vertices << [x + f32(math.cos(theta)) * r, y + f32(math.sin(theta)) * r]
vertices << [x + f32(math.cos(theta)) * r, y + f32(math.sin(theta)) * r] !
i++
}
vertices << [x + f32(math.cos(end_rads)) * r, y + f32(math.sin(end_rads)) * r]
vertices << [x + f32(math.cos(end_rads)) * r, y + f32(math.sin(end_rads)) * r] !
return vertices
}