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

gg: change draw_cubic_bezier* call signatures for speed and to match *_poly (#11323)

This commit is contained in:
Larpon
2021-08-27 15:52:05 +02:00
committed by GitHub
parent 4d5521bbf7
commit e85311c2ba
3 changed files with 25 additions and 19 deletions

View File

@@ -4,8 +4,7 @@ import gg
import gx
const (
p1_and_p2 = [f32(200.0), 200.0, 400.0, 300.0]
ctrl_p1_and_p2 = [f32(200.0), 100.0, 400.0, 100.0]
points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0]
)
struct App {
@@ -30,6 +29,6 @@ fn main() {
fn frame(mut app App) {
app.gg.begin()
app.gg.draw_cubic_bezier(p1_and_p2, ctrl_p1_and_p2, gx.blue)
app.gg.draw_cubic_bezier(points, gx.blue)
app.gg.end()
}

View File

@@ -48,13 +48,21 @@ fn main() {
fn frame(mut app App) {
time := app.anim.time
ctrl_p1_x := f32(200.0) + (40 * time)
ctrl_p2_x := f32(400.0) + (-40 * time)
p1_x := f32(200.0)
p1_y := f32(200.0) + (10 * time)
p1_and_p2 := [f32(200.0), 200.0 + (10 * time), 400.0, 200.0 + (10 * time)]
p2_x := f32(400.0)
p2_y := f32(200.0) + (10 * time)
ctrl_p1_x := f32(200.0) + (40 * time)
ctrl_p1_y := f32(100.0)
ctrl_p2_x := f32(400.0) + (-40 * time)
ctrl_p2_y := f32(100.0)
points := [p1_x, p1_y, ctrl_p1_x, ctrl_p1_y, ctrl_p2_x, ctrl_p2_y, p2_x, p2_y]
app.gg.begin()
app.gg.draw_cubic_bezier(p1_and_p2, [ctrl_p1_x, 100.0, ctrl_p2_x, 100.0], gx.blue)
app.gg.draw_cubic_bezier(points, gx.blue)
app.gg.end()
app.anim.advance()
}