-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for a Graphics Tiling Effect #2744
Comments
It's not 100% clear yet what the API would look like |
This issue hasn't had any recent activity lately and is being marked as stale automatically. |
For reference on possible API, PixiJS has a TilingSprite component |
@mattjennings Thanks, this is a great reference. I might be able to sneak tiling into the existing API into the option bag constructor? Potentially if the repeat flag is set on a dimension, it will tile if the destSize is greater than the sourceView's corresponding dimension? export interface SpriteOptions {
/**
* Image to create a sprite from
*/
image: ImageSource;
/**
* By default the source is the entire dimension of the [[ImageSource]]
*/
sourceView?: { x: number; y: number; width: number; height: number };
/**
* By default the size of the final sprite is the size of the [[ImageSource]]
*/
destSize?: { width: number; height: number };
repeatX: boolean;
repeatY: boolean;
} |
Perhaps a new type would be best tho... |
Hmm. To be honest I'm not entirely sure what My thinking is if you had |
This issue hasn't had any recent activity lately and is being marked as stale automatically. |
We accidentally implemented this feature (see discord conversation for full context https://discord.com/channels/1195771303215513671/1229051072027562074) 20240414-1430-04.2978303.mp4The gist for sprites, is if the var game = new ex.Engine({
canvasElementId: 'game',
width: 600,
height: 400,
displayMode: ex.DisplayMode.FitScreenAndFill,
pixelArt: true
// antialiasing: false
});
var tex = new ex.ImageSource('https://cdn.rawgit.com/excaliburjs/Excalibur/7dd48128/assets/sword.png', {
wrapping: ex.ImageWrapping.Repeat
});
var loader = new ex.Loader([tex]);
var sprite = new ex.Sprite({
image: tex,
sourceView: {
x: 0,
y: 0,
width: 500,
height: 500
},
destSize: {
width: 1000,
height: 1000
}
});
var actor = new ex.Actor({
x: 0, y: 0,
anchor: ex.vec(0, 0),
coordPlane: ex.CoordPlane.Screen,
z: -10
});
actor.onInitialize = () => {
actor.graphics.add(sprite);
};
actor.onPostUpdate = (engine, delta) => {
sprite.sourceView.x += .05 * delta;
}
game.add(actor);
game.start(loader);
game.currentScene.camera.pos = actor.pos; Current hack for animation tiling this.backgroundAnim = Resources.Background.getAnimation('default')!;
// Terrible terrible to enable animation tiling
for (let frame of this.backgroundAnim.frames) {
const sprite = (frame.graphic as Sprite);
sprite.image.wrapping = { x: ImageWrapping.Repeat, y: ImageWrapping.Repeat };
sprite.image.image.setAttribute('wrapping-x', ImageWrapping.Repeat);
sprite.image.image.setAttribute('wrapping-y', ImageWrapping.Repeat);
sprite.image.image.setAttribute('forceUpload', 'true');
sprite.sourceView.width *= 5;
sprite.sourceView.height *= 5;
sprite.destSize.width *= 5;
sprite.destSize.height *= 5;
} |
This issue hasn't had any recent activity lately and is being marked as stale automatically. |
See comment
#2621 (reply in thread)
Discussed in #2621
Originally posted by KokoDoko April 15, 2023
In CSS and in javascript canvas, there's an option to create an infinitely repeating pattern. See this link.
I struggled a while to find out how to apply this in Excalibur, I eventually came up with this solution!
The text was updated successfully, but these errors were encountered: