image_filter_dsl 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/image_filter_dsl/dsl/filter_instructions.rb +13 -0
- data/lib/image_filter_dsl/engine/image_processor.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11cb37a368d81f59215c62674f34ede4fa48628aec1836cb42d70529afca1fab
|
4
|
+
data.tar.gz: e3a48733e741052828f1a894179990fb2aa964b0f5964ccce2db5650f2667cd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc94cd228532001187ce242a1aa266ac7cf0281166fa74e61b939773f385c6d89f5e3a0136d4e33c595211d4427f679103e43eda87cdf73cee460b573d3fd584
|
7
|
+
data.tar.gz: a7c47d86d6487be190bc0b73589d0562a43a769cbca2c8a8cb1301d7e4c5bc099373d1c8f35a138afe4a77b63035236b3bf150dc00eb382c214ef3584a4ec0b2
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ processor = ImageFilterDsl.image_processor(swizzle)
|
|
43
43
|
processor.process_image('./my_source.png', './my_output.png')
|
44
44
|
```
|
45
45
|
|
46
|
-
- See {file:docs/dsl.md}
|
46
|
+
- See {ImageFilterDsl::Dsl} for instruction overview (or go directly to {file:docs/dsl.md DSL summary} )
|
47
47
|
- See `./sample_filters/samples.rb`
|
48
48
|
- See Also: [image_filter_dsl_samples](https://bitbucket.org/WadeH/image_filter_dsl_samples/src/master/) for samples
|
49
49
|
|
@@ -3,6 +3,9 @@
|
|
3
3
|
# (c) 2018-2020 VDTDEV/Wade H. ~ MIT License
|
4
4
|
# @author Wade H. <vdtdev.prod@gmail.com>
|
5
5
|
module ImageFilterDsl
|
6
|
+
##
|
7
|
+
# Module defining DSL
|
8
|
+
# {include:file:docs/dsl.md}
|
6
9
|
module Dsl
|
7
10
|
##
|
8
11
|
# Module defining filter kernel instruction logic
|
@@ -32,6 +35,7 @@ module ImageFilterDsl
|
|
32
35
|
switch: 0xd7,
|
33
36
|
eq: 0xd8,
|
34
37
|
bnot: 0xd9,
|
38
|
+
mix: 0xda,
|
35
39
|
# generation
|
36
40
|
rand: 0xe0
|
37
41
|
}
|
@@ -223,6 +227,15 @@ module ImageFilterDsl
|
|
223
227
|
end
|
224
228
|
end
|
225
229
|
|
230
|
+
##
|
231
|
+
# Mix two values with a ratio
|
232
|
+
# @param [Array] i input values (ratio (0-1.0), a, b)
|
233
|
+
# @return [Float] output value of ((ratio*a) + ((1.0-ratio)*b))
|
234
|
+
def self.mix(i)
|
235
|
+
ratio, a, b = i
|
236
|
+
(ratio*a)+((1.0-ratio)*b)
|
237
|
+
end
|
238
|
+
|
226
239
|
##
|
227
240
|
# Random number instruction
|
228
241
|
# @param [Array] i input values (min, max)
|
@@ -13,6 +13,8 @@ module ImageFilterDsl
|
|
13
13
|
|
14
14
|
attr_accessor :kernel, :config
|
15
15
|
|
16
|
+
|
17
|
+
|
16
18
|
##
|
17
19
|
# Constructor
|
18
20
|
# @param [Dsl::Kernel::FilterKernel|String] filter_kernel FilterKernel object or path to binary kernel file
|
@@ -121,7 +123,6 @@ module ImageFilterDsl
|
|
121
123
|
b = clr.b(pixel)
|
122
124
|
a = clr.a(pixel)
|
123
125
|
|
124
|
-
|
125
126
|
inputs = Hash[*@kernel.inputs.map{|k|[k,0]}.flatten]
|
126
127
|
inputs[:x] = x if inputs.keys.include?(:x)
|
127
128
|
inputs[:y] = y if inputs.keys.include?(:y)
|