This file contains hidden or 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
def self.translate(matrix : Matrix(T, 4, 16), translation : Vector(T, 3)) forall T | |
cpy = matrix.dup | |
cpy[3, 0] = translation.x | |
cpy[3, 1] = translation.y | |
cpy[3, 2] = translation.z | |
cpy | |
end | |
def self.translate(matrix : Matrix(T, 4, 16), translation : Vector(T, 3)) forall T | |
matrix[3, 0] = translation.x |
This file contains hidden or 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
private macro do_math(operator, times) | |
self[{{SIZE - times}}].{{operator}}(other[{{SIZE - times}})] | |
{% if times != 0 %} | |
, do_math({{operator}}, {{times - 1}}) | |
{% end %} | |
end | |
def +(other : Vector(Type, Size)) | |
self.class.new(do_math(:+, SIZE)) | |
end |
This file contains hidden or 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
struct Vector2(Type) | |
SIZE = 2 | |
TYPE = Type | |
ZERO = self.new() | |
ONE = self.new(1, 1) | |
property :x, :y | |
@x : Type | |
@y : Type |
This file contains hidden or 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 FooBar | |
def initialize(@value = 0) | |
end | |
def value | |
@value | |
end | |
protected def value=(val) | |
@value = val |
This file contains hidden or 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
macro finished | |
{% for definition in Crystal::Clear::CLASS_COMPILE_DATA %} | |
class {{definition[0]}} | |
Crystal::Clear::CLASS_RUNTIME_DATA << Crystal::Clear::ClassData({{definition[0]}}).new() | |
def {{definition[1]}} | |
{% for condition in definition[2] %} | |
if(({{condition}}) == false) | |
raise Crystal::Clear::Exception.new("Failed {{definition[0]}} require contract: {{condition}}") | |
end | |
{% end %} |
This file contains hidden or 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 Foo | |
invariant( some_other_test ) # Run at entry of every contract | |
# First argument run at function start, second argument run at function end | |
contract baz == true, @thing.nil? == false, | |
def bar(val) | |
@thing = val.do_thing | |
end | |
end |
This file contains hidden or 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
// In Update function | |
myTransform = sf::Transform::Identity | |
myTransform.translate(-originVector); | |
myTransform.roate(rotation); | |
// In Draw | |
states.transform = states.transform.combine(myTransform); | |
target.draw(sprite, states); |
This file contains hidden or 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 BaseSubscriberInterface | |
{ | |
publlic: | |
/* stuff */ | |
}; | |
class DerivedSubscriber : public BaseSubscriberInterface | |
{ | |
public: | |
void funcThatReceivesMessage(const Message& message); |
This file contains hidden or 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
MessageType foo = MessageType(Messages.Base) ~ MessageType(Messages.Window) ~ MessageType(Messages.Foo); | |
writeln(foo.toString()); | |
MessageType bar = MessageType("Base.Window.Foo"); | |
writeln(bar.toString()); |
This file contains hidden or 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
#version 330 | |
vertex | |
{ | |
layout(location = 0) in vec4 position; | |
void main() | |
{ | |
gl_Position = position; | |
} | |
} |