He's using the Sphere v2 API (note the new Surface(...)). Surfaces have no built-in primitives in Sphere v2, you're meant to use Galileo (i.e. Shape objects). See:
https://github.com/fatcerberus/minisphere/blob/v4.5.4/docs/sphere2-api.txt#L913-L938
Oh damn, lol I'm becoming and old fogy in the community. lol
No problem, hehe. Everything works differently now, which is jarring at first, but being in the process of upgrading Spectacles to take advantage of all the Sphere v2 stuff now, I would say the changes I made are for the better. I'm not really unhappy with any of them. Combined with ES6, Sphere v2 really feels like a fully modern development environment now unlike Sphere 1.x which was really showing its age.
@scojin: I can verify your report, and I'm almost certain this is a bug. I tried the following code:
const prim = require('prim');
var surf = new Surface(100, 100);
var img = new Texture('images/titleCard.png');
prim.rect(surf, 10, 10, 50, 50, Color.Chartreuse);
prim.blit(surf, 0, 0, img);
var surfImg = surf.toTexture();
while (Sphere.run()) {
prim.blit(screen, 0, 0, surfImg);
screen.flip();
}
The rectangle is rendered, but the image is not. Now I just have to figure out why. By the way,
Image was renamed to
Texture a few versions ago so you should probably upgrade your miniSphere installation if you want your code to keep running
edit: I found the bug. When drawing to the screen, texture coordinates (U/V) are normalized and go from [0-1] bottom-to-top. When drawing to a surface, however, they are in pixels and go from [0-w/h). So what's actually happening is that
prim.blit() correctly assumes the normalized coordinates, and only the top-left pixel of the image gets drawn. I'm not sure what causes that yet, I'll have to study the Galileo code.