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" | |
"image/color" | |
"time" | |
"github.com/szeliga/goray/engine" | |
) |
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
func (s *Scene) Save(filename string) { | |
f, err := os.Create(filename) | |
if err != nil { | |
panic(err) | |
} | |
defer f.Close() | |
png.Encode(f, s.Img) | |
} |
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
func (s *Scene) EachPixel(colorFunction func(int, int) color.RGBA) { | |
for x := 0; x < s.Width; x++ { | |
for y := 0; y < s.Height; y++ { | |
s.setPixel(x, y, colorFunction(x, y)) | |
} | |
} | |
} | |
func TestSceneEachPixelSetsEachPixelToTheProvidedFunctionReturn(t *testing.T) { | |
scene := NewScene(4, 4) |
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
func generateImage(w, h int, pixelColor color.RGBA) *image.RGBA { | |
img := image.NewRGBA(image.Rect(0, 0, 4, 4)) | |
for x := 0; x < 4; x++ { | |
for y := 0; y < 4; y++ { | |
img.Set(x, y, pixelColor) | |
} | |
} | |
return img | |
} |
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
func TestNewSceneReturnsANewScene(t *testing.T) { | |
scene := NewScene(4, 4) | |
rect := image.Rect(0, 0, 4, 4) | |
assert.Equal(t, 4, scene.Width, "sets width of the scene") | |
assert.Equal(t, 4, scene.Height, "sets height of the scene") | |
assert.True(t, assert.ObjectsAreEqualValues(rect, scene.Img.Bounds()), | |
"creates an image.RGBA with proper bounds") | |
} | |
func NewScene(width int, height int) *Scene { |
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
type Scene struct { | |
Width, Height int | |
Img *image.RGBA | |
} |
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
test: | |
override: | |
- COVERAGE=true node_modules/ember-cli/bin/ember test | |
post: | |
- codeclimate-test-reporter < ‘coverage/lcov.info' |
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
Post Load (0.5ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT $1 [["LIMIT", 1]] | |
(0.1ms) BEGIN | |
SQL (0.4ms) DELETE FROM "comments" WHERE "comments"."post_id" = $1 [["post_id", 15]] | |
SQL (1.1ms) DELETE FROM "posts" WHERE "posts"."id" = $1 [["id", 15]] |
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
Post Load (0.5ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 [["id", 1]] | |
(0.1ms) BEGIN | |
Comment Load (0.5ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = $1 [["post_id", 16]] | |
SQL (0.5ms) DELETE FROM "comments" WHERE "comments"."id" = $1 [["id", 1]] | |
SQL (0.3ms) DELETE FROM "comments" WHERE "comments"."id" = $1 [["id", 2]] | |
SQL (0.2ms) DELETE FROM "comments" WHERE "comments"."id" = $1 [["id", 3]] | |
SQL (0.3ms) DELETE FROM "comments" WHERE "comments"."id" = $1 [["id", 4]] | |
SQL (0.5ms) DELETE FROM "posts" WHERE "posts"."id" = $1 [["id", 16]] |
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
class PostsController < ApplicationController | |
def destroy | |
@post = Post.find(params[:id]).destroy | |
... | |
end | |
end |