Skip to content

Commit 831fad3

Browse files
committed
Update to latest V, (byte -> u8)
1 parent 624bb78 commit 831fad3

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

drawer.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn draw_image(mut win ui.Window, com &ui.Component) {
120120
fn color_from_string(st string) gx.Color {
121121
val := st.split('{')[1].split('}')[0]
122122
spl := val.split(', ')
123-
return gx.rgb(spl[0].byte(), spl[1].byte(), spl[2].byte())
123+
return gx.rgb(spl[0].u8(), spl[1].u8(), spl[2].u8())
124124
}
125125

126126
//
@@ -165,7 +165,7 @@ fn make_gg_image(mut storage KA, mut win ui.Window, first bool) {
165165
}
166166

167167
// Create an new ui.Image
168-
fn make_icon(mut win ui.Window, width int, height int, data []byte) int {
168+
fn make_icon(mut win ui.Window, width int, height int, data []u8) int {
169169
ggim := win.gg.new_streaming_image(width, height, 4, gg.StreamingImageConfig{
170170
pixel_format: .rgba8
171171
})

image_file.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn write(img stbi.Image, path string) {
1515
pub fn get_pixel(x int, y int, mut this stbi.Image) gx.Color {
1616
image := this
1717
unsafe {
18-
data := &byte(image.data)
18+
data := &u8(image.data)
1919
p := data + (4 * (y * image.width + x))
2020
r := p[0]
2121
g := p[1]
@@ -36,7 +36,7 @@ fn set_pixel(image stbi.Image, x int, y int, color gx.Color) bool {
3636
}
3737

3838
unsafe {
39-
data := &byte(image.data)
39+
data := &u8(image.data)
4040
p := data + (4 * (y * image.width + x))
4141
p[0] = color.r
4242
p[1] = color.g

rgb_picker.v

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ fn show_rgb_picker(mut win ui.Window) {
3838
mut b_slider := &ui.Slider(win.get_from_id('b_slider'))
3939
mut a_slider := &ui.Slider(win.get_from_id('a_slider'))
4040

41-
cr := byte(clamp(r_slider.cur - 2, 0, 255))
42-
cg := byte(clamp(g_slider.cur - 2, 0, 255))
43-
cb := byte(clamp(b_slider.cur - 2, 0, 255))
44-
ca := byte(clamp(a_slider.cur - 2, 0, 255))
41+
cr := u8(clamp(r_slider.cur - 2, 0, 255))
42+
cg := u8(clamp(g_slider.cur - 2, 0, 255))
43+
cb := u8(clamp(b_slider.cur - 2, 0, 255))
44+
ca := u8(clamp(a_slider.cur - 2, 0, 255))
4545

4646
this.text = this.text.split('rgba(')[0] + 'rgba(' + cr.str() + ', ' + cg.str() + ', ' +
4747
cb.str() + ', ' + ca.str() + ')'
@@ -75,10 +75,10 @@ fn show_rgb_picker(mut win ui.Window) {
7575
mut b_slider := &ui.Slider(win.get_from_id('b_slider'))
7676
mut a_slider := &ui.Slider(win.get_from_id('a_slider'))
7777

78-
cr := byte(clamp(r_slider.cur - 2, 0, 255))
79-
cg := byte(clamp(g_slider.cur - 2, 0, 255))
80-
cb := byte(clamp(b_slider.cur - 2, 0, 255))
81-
ca := byte(clamp(a_slider.cur - 2, 0, 255))
78+
cr := u8(clamp(r_slider.cur - 2, 0, 255))
79+
cg := u8(clamp(g_slider.cur - 2, 0, 255))
80+
cb := u8(clamp(b_slider.cur - 2, 0, 255))
81+
ca := u8(clamp(a_slider.cur - 2, 0, 255))
8282

8383
canvas.color = gx.rgba(cr, cg, cb, ca)
8484

toolbar.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn (mut this Toolbar) draw_colors(mut win ui.Window, sw int) {
147147
}
148148

149149
fn create_img_button(mut win ui.Window, path string, x int, y int, w int, h int) &ui.Image {
150-
img_data := os.read_bytes(os.resource_abs_path('resources/' + path)) or { [byte(0)] }
150+
img_data := os.read_bytes(os.resource_abs_path('resources/' + path)) or { [u8(0)] }
151151
mut pen_btn := ui.image_from_byte_array_with_size(mut win, img_data, 32, 32)
152152
pen_btn.z_index = 8
153153

vpaint.v

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ fn save_as_click(mut win ui.Window, com ui.MenuItem) {
186186
l1.set_pos(30, 70)
187187
modal.add_child(l1)
188188

189-
mut path := ui.textbox(win, '')
189+
mut path := ui.textfield(win, '')
190190
path.set_id(mut win, 'save-as-path')
191191
path.set_bounds(140, 70, 300, 25)
192-
path.multiline = false
192+
//path.multiline = false
193193

194194
if 'save_path' in win.extra_map {
195195
path.text = win.extra_map['save_path']
@@ -211,7 +211,7 @@ fn save_as_click(mut win ui.Window, com ui.MenuItem) {
211211
mut save := ui.button(win, 'Save')
212212
save.set_bounds(150, 250, 100, 25)
213213
save.set_click(fn (mut win ui.Window, btn ui.Button) {
214-
mut path := &ui.Textbox(win.get_from_id('save-as-path'))
214+
mut path := &ui.TextField(win.get_from_id('save-as-path'))
215215
canvas := &KA(win.id_map['pixels'])
216216
file := canvas.file
217217

0 commit comments

Comments
 (0)