-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplottk_utils.tcl
More file actions
40 lines (34 loc) · 998 Bytes
/
implottk_utils.tcl
File metadata and controls
40 lines (34 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) 2022 Nicolas ROBERT.
# Distributed under MIT license. Please see LICENSE for details.
namespace eval ::implottk {}
proc ::implottk::rgbaToVec4 {rgb {a 255}} {
# Transform rgb colors to struct.ImVec4 format.
#
# rgb - list colors rgb
# a - alpha state
#
# Returns A struct.ImVec4
set rgba [linsert $rgb end $a]
foreach value {x y z w} color $rgba {
lappend vec4 $value [expr {$color / double(255)}]
}
return $vec4
}
proc ::implottk::arrayToFloat {data} {
# Transform list data to cffi array float.
#
# data - list
#
# Returns A pointer
set len [llength $data]
return [cffi::memory new float\[$len\] $data]
}
proc ::implottk::doubleToPointer {data} {
# Transform list data to cffi array double.
#
# data - list
#
# Returns A pointer.double
set len [llength $data]
return [cffi::memory new double\[$len\] $data ::implot::double]
}