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

fix a few warnings

Good find, @eyelash .
This commit is contained in:
eyelash 2020-04-26 11:42:44 +02:00 committed by GitHub
parent 270566055f
commit b495dac780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 27 deletions

View File

@ -4,13 +4,11 @@
module freetype module freetype
import ( import os
os import gx
gx import gg
gg import glm
glm import gl
gl
)
#flag windows -I @VROOT/thirdparty/freetype/include #flag windows -I @VROOT/thirdparty/freetype/include
#flag windows -L @VROOT/thirdparty/freetype/win64 #flag windows -L @VROOT/thirdparty/freetype/win64
@ -223,7 +221,7 @@ pub fn new_context(cfg gg.Cfg) &FreeType {
C.glPixelStorei(C.GL_UNPACK_ALIGNMENT, 1) C.glPixelStorei(C.GL_UNPACK_ALIGNMENT, 1)
// Gen texture // Gen texture
// Load first 128 characters of ASCII set // Load first 128 characters of ASCII set
mut chars := []Character mut chars := []Character{}
for c in 0..128 { for c in 0..128 {
ch := ft_load_char(face, i64(c)) ch := ft_load_char(face, i64(c))
// s := utf32_to_str(uint(0x043f)) // s := utf32_to_str(uint(0x043f))
@ -454,7 +452,7 @@ pub fn (f FT_Face) str() string {
*/ */
pub fn (ac []Character) str() string { pub fn (ac []Character) str() string {
mut res := []string mut res := []string{}
for c in ac { for c in ac {
res << ' Character{ code: $c.code , texture_id: $c.texture_id }' res << ' Character{ code: $c.code , texture_id: $c.texture_id }'
} }

View File

@ -4,14 +4,12 @@
module gg module gg
import ( import stbi
stbi import glm
glm import gl
gl import gx
gx import os
os import glfw
glfw
)
pub struct Vec2 { pub struct Vec2 {
pub: pub:
@ -434,7 +432,7 @@ pub fn (ctx &GG) draw_filled_arc(x, y, r, start_angle, end_angle f32, segments i
ctx.use_color_shader(color) ctx.use_color_shader(color)
mut vertices := []f32 mut vertices := []f32{}
vertices << [x, y] ! vertices << [x, y] !
vertices << arc_vertices(x, y, r, start_angle, end_angle, segments) vertices << arc_vertices(x, y, r, start_angle, end_angle, segments)
ctx.bind_vertices(vertices) ctx.bind_vertices(vertices)
@ -448,7 +446,7 @@ pub fn (ctx &GG) draw_circle(x, y, r f32, color gx.Color) {
pub fn (ctx &GG) draw_rounded_rect(x, y, w, h, r f32, color gx.Color) { pub fn (ctx &GG) draw_rounded_rect(x, y, w, h, r f32, color gx.Color) {
ctx.use_color_shader(color) ctx.use_color_shader(color)
mut vertices := []f32 mut vertices := []f32{}
segments := 6 + int(r / 8) segments := 6 + int(r / 8)
// Create a rounded rectangle using a triangle fan mesh. // Create a rounded rectangle using a triangle fan mesh.
@ -467,7 +465,7 @@ pub fn (ctx &GG) draw_rounded_rect(x, y, w, h, r f32, color gx.Color) {
pub fn (ctx &GG) draw_empty_rounded_rect(x, y, w, h, r f32, color gx.Color) { pub fn (ctx &GG) draw_empty_rounded_rect(x, y, w, h, r f32, color gx.Color) {
ctx.use_color_shader(color) ctx.use_color_shader(color)
mut vertices := []f32 mut vertices := []f32{}
segments := 6 + int(r / 8) segments := 6 + int(r / 8)
vertices << arc_vertices(x + w - r, y + h - r, r, 0, 90, segments) vertices << arc_vertices(x + w - r, y + h - r, r, 0, 90, segments)

View File

@ -1,13 +1,11 @@
module gg module gg
import ( import gl
gl import gx
gx import math
math
)
fn arc_vertices(x, y, r, start_angle, end_angle f32, segments int) []f32 { fn arc_vertices(x, y, r, start_angle, end_angle f32, segments int) []f32 {
mut vertices := []f32 mut vertices := []f32{}
start_rads := start_angle * 0.0174533 // deg -> rad approx start_rads := start_angle * 0.0174533 // deg -> rad approx
end_rads := end_angle * 0.0174533 end_rads := end_angle * 0.0174533
increment := (end_rads - start_rads) / segments increment := (end_rads - start_rads) / segments

View File

@ -115,7 +115,7 @@ pub fn digits(_n, base int) []int {
sign = -1 sign = -1
n = -n n = -n
} }
mut res := []int mut res := []int{}
for n != 0 { for n != 0 {
res << (n % base) * sign res << (n % base) * sign
n /= base n /= base