FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
luaplot/oscillogram.lua at master · thewizardplusplus/luaplot · GitHub
thewizardplusplus
/
luaplot
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
luaplot
/
oscillogram.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
109 lines (89 loc) · 2.52 KB
Breadcrumbs
luaplot
/
oscillogram.lua
Copy path
File metadata and controls
109 lines (89 loc) · 2.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--
luacheck: no max comment line length
---
--
@
classmod
Oscillogram
local
middleclass
=
require
(
"
middleclass
"
)
local
assertions
=
require
(
"
luatypechecks.assertions
"
)
local
Plot
=
require
(
"
luaplot.plot
"
)
---
--
@table instance
--
@
tfield
"custom"|"linear"|"random" _kind
--
@
tfield
{number,...} _points
--
@
tfield
number _default
--
@
tfield
number _minimum
--
@
tfield
number _maximum
local
Oscillogram
=
middleclass
(
"
Oscillogram
"
,
Plot
)
---
--
@
function
new
--
@
tparam
"custom"|"linear"|"random" kind
--
@
tparam
number length [0, ∞)
--
@
tparam
[opt=minimum] number default
--
@
tparam
[opt=0] number minimum
--
@
tparam
[opt=1] number maximum [minimum, ∞)
--
@
treturn
Oscillogram
function
Oscillogram
:
initialize
(
kind
,
length
,
default
,
minimum
,
maximum
)
minimum
=
minimum
or
0
maximum
=
maximum
or
1
default
=
default
or
minimum
assertions
.
is_enumeration
(
kind
, {
"
custom
"
,
"
linear
"
,
"
random
"
})
assertions
.
is_number
(
length
)
assertions
.
is_number
(
default
)
assertions
.
is_number
(
minimum
)
assertions
.
is_number
(
maximum
)
Plot
.
initialize
(
self
,
length
,
default
,
minimum
,
maximum
)
self
.
_kind
=
kind
end
---
--
It is used for iterating over plot points in Lua 5.3+.
--
@
function
__index
--
@
tparam
number index [1, ∞)
--
@
treturn
number
---
--
It is used for iterating over plot points in Lua 5.2.
--
@
function
__ipairs
--
@
treturn
iterators.inext iterator function
--
@
treturn
Oscillogram self
--
@
treturn
number always zero
---
--
@
treturn
tab table with instance fields
--
(see the [luaserialization](https://github.com/thewizardplusplus/luaserialization) library)
function
Oscillogram
:
__data
()
return
{
kind
=
self
.
_kind
,
points
=
self
.
_points
,
default
=
self
.
_default
,
minimum
=
self
.
_minimum
,
maximum
=
self
.
_maximum
,
}
end
---
--
@
function
__tostring
--
@
treturn
string stringified table with instance fields
--
(see the [luaserialization](https://github.com/thewizardplusplus/luaserialization) library)
---
--
@
function
push
--
@
tparam
number point
---
--
@
function
push_with_factor
--
@
tparam
number factor
---
--
@
function
push_with_random_factor
--
@
tparam
number factor_limit
---
--
@
function
shift
--
@
treturn
number
---
--
@
tparam
number value
--
@
treturn
number
function
Oscillogram
:
update
(
value
)
assertions
.
is_number
(
value
)
if
self
.
_kind
==
"
custom
"
then
self
:
push
(
value
)
elseif
self
.
_kind
==
"
linear
"
then
self
:
push_with_factor
(
value
)
elseif
self
.
_kind
==
"
random
"
then
self
:
push_with_random_factor
(
value
)
end
local
first_point
=
self
:
shift
()
return
first_point
end
return
Oscillogram
Back
|
FazBrowse Home
|
New Git URL