Has someone coded something similar to this? Maybe a math module that has a similar object. I am a bit unsure on how to fill the functions imported by these functions.
Edit: Solved
ash
managed struct Size{
int width;
int height;
import static Size* Create(int width, int height); // $AUTOCOMPLETESTATICONLY$
import Size* Add(Size * sizeToAdd);
import Size* Subtract(Size * sizeToAdd);
import Size* MultiplyInt(int multiplier);
import Size* MultiplyFloat(float multiplier);
import Size* Set(Size* sizeToSet);
};
managed struct Rect {
int x;
int y;
int width;
int height;
import static Rect * Create(int x, int y, int width, int height); // $AUTOCOMPLETESTATICONLY$
import Rect * SetPosition(Point * point);
import Rect * SetSize(Size * size);
import Rect * SetBounds(int x, int y, int width, int height);
import Rect * SetBoundsRect(Rect * rect);
import Rect * SetBoundsPS(Point* position, Size* size);
};
asc
// Size object
static Size* Size::Create(int width, int height){
Size * size = new Size;
size.width = width;
size.height = height;
return size;
}
Size* Size::Add(Size* sizeToAdd){
this.width += sizeToAdd.width;
this.height += sizeToAdd.height;
return this;
}
Size* Size::Subtract(Size* sizeToAdd){
this.width -= sizeToAdd.width;
this.height -= sizeToAdd.height;
return this;
}
Size* Size::MultiplyInt(int multiplier){
this.width = this.width*multiplier;
this.height = this.height*multiplier;
return this;
}
Size* Size::MultiplyFloat(float multiplier){
this.width = FloatToInt(IntToFloat(this.width)*multiplier);
this.height = FloatToInt(IntToFloat(this.height)*multiplier);
return this;
}
Size* Size::Set(Size* sizeToSet){
this.width = sizeToSet.width;
this.height = sizeToSet.height;
return this;
}
// End of Size object
// Rect object
static Rect* Rect::Create(int x, int y, int width, int height){
Rect* rect = new Rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
return rect;
}
Rect * Rect::SetPosition(Point * point){
this.x = point.x;
this.y = point.y;
return this;
}
Rect * Rect::SetSize(Size * size){
this.width = size.width;
this.height = size.height;
return this;
}
Rect * Rect::SetBounds(int x, int y, int width, int height){
this.x = x;
this.y = y;
this.width = width;
this.height = height;
return this;
}
Rect * Rect::SetBoundsRect(Rect * rect){
this.x = rect.x;
this.y = rect.y;
this.width = rect.width;
this.height = rect.height;
return this;
}
Rect * Rect::SetBoundsPS(Point* position, Size* size){
this.x = position.x;
this.y = position.y;
this.width = size.width;
this.height = size.height;
return this;
}
// End of Rect Object