Fixed issue with pixels
This commit is contained in:
parent
a1af04063b
commit
d78a610d80
@ -44,7 +44,7 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(circle cx cy r)` Returns a circle shape.
|
- `(circle cx cy r)` Returns a circle shape.
|
||||||
- `(line a b)` Returns a line shape.
|
- `(line a b)` Returns a line shape.
|
||||||
- `(text x y p t ~f)` Returns a text shape.
|
- `(text x y p t ~f)` Returns a text shape.
|
||||||
- `(svg d)` Returns a svg shape.
|
- `(svg x y d)` Returns a svg shape.
|
||||||
- `(stroke ~shape)` Strokes a shape.
|
- `(stroke ~shape)` Strokes a shape.
|
||||||
- `(fill ~rect)` Fills a shape.
|
- `(fill ~rect)` Fills a shape.
|
||||||
- `(clear ~rect)` Clears a rect.
|
- `(clear ~rect)` Clears a rect.
|
||||||
@ -67,12 +67,16 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(mod a b)` Returns the modulo of a and b.
|
- `(mod a b)` Returns the modulo of a and b.
|
||||||
- `(clamp val min max)` Clamps a value between min and max.
|
- `(clamp val min max)` Clamps a value between min and max.
|
||||||
- `(step val step)`
|
- `(step val step)`
|
||||||
|
- `(floor)`
|
||||||
- `(min)`
|
- `(min)`
|
||||||
- `(max)`
|
- `(max)`
|
||||||
- `(ceil)`
|
- `(ceil)`
|
||||||
- `(floor)`
|
|
||||||
- `(sin)`
|
- `(sin)`
|
||||||
- `(cos)`
|
- `(cos)`
|
||||||
|
- `(log)` caclulates on the base of e.
|
||||||
|
- `(pow a b)` calculates a^b.
|
||||||
|
- `(sqrt)` calculate the square root.
|
||||||
|
- `(sq a)` calculate the square.
|
||||||
- `(PI)`
|
- `(PI)`
|
||||||
- `(TWO_PI)`
|
- `(TWO_PI)`
|
||||||
- `(random ...args)`
|
- `(random ...args)`
|
||||||
|
@ -153,7 +153,7 @@ function Library (ronin) {
|
|||||||
// Pixels
|
// Pixels
|
||||||
|
|
||||||
this.pixels = (rect, fn, q) => {
|
this.pixels = (rect, fn, q) => {
|
||||||
const img = ronin.surface.context.getImageData(0, 0, rect.w, rect.h)
|
const img = ronin.surface.context.getImageData(rect.x, rect.y, rect.w, rect.h)
|
||||||
for (let i = 0, loop = img.data.length; i < loop; i += 4) {
|
for (let i = 0, loop = img.data.length; i < loop; i += 4) {
|
||||||
const pixel = { r: img.data[i], g: img.data[i + 1], b: img.data[i + 2], a: img.data[i + 3] }
|
const pixel = { r: img.data[i], g: img.data[i + 1], b: img.data[i + 2], a: img.data[i + 3] }
|
||||||
const processed = fn(pixel, q)
|
const processed = fn(pixel, q)
|
||||||
@ -162,7 +162,7 @@ function Library (ronin) {
|
|||||||
img.data[i + 2] = processed[2]
|
img.data[i + 2] = processed[2]
|
||||||
img.data[i + 3] = processed[3]
|
img.data[i + 3] = processed[3]
|
||||||
}
|
}
|
||||||
ronin.surface.context.putImageData(img, 0, 0)
|
ronin.surface.context.putImageData(img, rect.x, rect.y)
|
||||||
return rect
|
return rect
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,29 +212,27 @@ function Library (ronin) {
|
|||||||
return Math.round(val / step) * step
|
return Math.round(val / step) * step
|
||||||
}
|
}
|
||||||
|
|
||||||
this.floor = Math.floor // round down to the nearest integer
|
|
||||||
|
|
||||||
this.min = Math.min
|
this.min = Math.min
|
||||||
|
|
||||||
this.max = Math.max
|
this.max = Math.max
|
||||||
|
|
||||||
this.ceil = Math.ceil
|
this.ceil = Math.ceil
|
||||||
|
|
||||||
this.floor = Math.floor
|
this.floor = Math.floor // round down to the nearest integer.
|
||||||
|
|
||||||
this.sin = Math.sin
|
this.sin = Math.sin
|
||||||
|
|
||||||
this.cos = Math.cos
|
this.cos = Math.cos
|
||||||
|
|
||||||
this.log = Math.log // caclulates on the base of e
|
this.log = Math.log // caclulates on the base of e.
|
||||||
|
|
||||||
this.pow = (a, b) => { // calculates a^b
|
this.pow = (a, b) => { // calculates a^b.
|
||||||
return Math.pow(a, b)
|
return Math.pow(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sqrt = Math.sqrt // calculate the square root
|
this.sqrt = Math.sqrt // calculate the square root.
|
||||||
|
|
||||||
this.sq = (a) => { // calculate the square
|
this.sq = (a) => { // calculate the square.
|
||||||
return a * a
|
return a * a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
; pixels
|
(clear)
|
||||||
|
; drag an image on the window
|
||||||
(clear)
|
(open $path)
|
||||||
(import "../../PREVIEW.jpg"
|
;
|
||||||
(frame))
|
|
||||||
(pixels
|
(pixels
|
||||||
(rect 0 0 500 500) saturation 0.5)
|
(rect 100 100 400 400) saturation 0)
|
||||||
|
(pixels
|
||||||
|
(rect 300 300 400 400) contrast 0.5)
|
Loading…
x
Reference in New Issue
Block a user