This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
const LIM = 41 | |
var facts [LIM]uint64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BitmapData.prototype.getContext = function() { | |
return this.context; | |
}; | |
BitmapData.prototype.getCanvas = function() { | |
return this.canvas; | |
}; | |
BitmapData.prototype.getCanvasPos = function(el) { | |
var canvas = document.getElementById(el) || this.getCanvas(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NOISE = NOISE || { }; | |
NOISE.Perlin = (function() { | |
var iOctaves = 1, | |
fPersistence = 0.2, | |
fResult, fFreq, fPers, | |
aOctFreq, // frequency per octave | |
aOctPers, // persistance per octave | |
fPersMax; // 1 / max persistence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/rand" | |
"fmt" | |
) | |
const ( | |
N int = 128 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c.processor = &triangle.Processor{ | |
BlurRadius: 2, | |
Noise: 0, | |
BlurFactor: 2, | |
EdgeFactor: 4, | |
PointRate: c.pointRate, | |
MaxPoints: c.trianglePoints, | |
PointsThreshold: c.pointsThreshold, | |
Wireframe: c.wireframe, | |
StrokeWidth: c.strokeWidth, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8Arr := js.Global().Get("Uint8Array").New(width * height * 4) | |
js.CopyBytesToJS(uint8Arr2, pixels.ImgToPix(blurred)) | |
uint8Clamped := js.Global().Get("Uint8ClampedArray").New(uint8Arr2) | |
rawData := js.Global().Get("ImageData").New(uint8Clamped, width, height) | |
c.ctx.Call("putImageData", rawData, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rgba := c.ctx.Call("getImageData", 0, 0, width, height).Get("data") | |
// Convert the rgba value of type Uint8ClampedArray to Uint8Array in order to | |
// be able to transfer it from Javascript to Go via the js.CopyBytesToGo function. | |
uint8Arr := js.Global().Get("Uint8Array").New(rgba) | |
js.CopyBytesToGo(data, uint8Arr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ImgToPix converts an image to an 1D uint8 pixel array. | |
// In order to preserve the color information per pixel we need to reconstruct the array to a specific format. | |
func ImgToPix(src *image.NRGBA) []uint8 { | |
size := src.Bounds().Size() | |
width, height := size.X, size.Y | |
pixels := make([][][3]uint8, height) | |
for y := 0; y < height; y++ { | |
row := make([][3]uint8, width) | |
for x := 0; x < width; x++ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package draw | |
import ( | |
"image" | |
"image/color" | |
) | |
// ellipse defines the struct components required to apply the ellipse's formula. | |
type ellipse struct { | |
cx int // center x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
draw.DrawMask(source.(*image.NRGBA), source.Bounds(), ellipse, image.Point{}, mask, image.Point{}, draw.Over) |
NewerOlder