misty
This commit is contained in:
26
graphics.cm
26
graphics.cm
@@ -55,10 +55,10 @@ function decorate_rect_px(img) {
|
||||
|
||||
// store pixel-space version: [x, y, w, h] in texels
|
||||
img.rect_px = {
|
||||
x:number.round(img.rect.x * width),
|
||||
y:number.round(img.rect.y * height),
|
||||
width:number.round(img.rect.width * width),
|
||||
height:number.round(img.rect.height * height)
|
||||
x:round(img.rect.x * width),
|
||||
y:round(img.rect.y * height),
|
||||
width:round(img.rect.width * width),
|
||||
height:round(img.rect.height * height)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ function wrapSurface(surf, maybeRect){
|
||||
return h;
|
||||
}
|
||||
function wrapFrames(arr){ /* [{surface,time,rect}, …] → [{image,time}] */
|
||||
return arr.map(f => {
|
||||
return array(arr, f => {
|
||||
// Handle both surface objects and objects with surface property
|
||||
var surf = f.surface || f;
|
||||
return {
|
||||
@@ -119,7 +119,7 @@ function decode_gif(decoded) {
|
||||
}
|
||||
|
||||
// Multiple frames - return array with time property
|
||||
return decoded.frames.map(function(frame) {
|
||||
return array(decoded.frames, frame => {
|
||||
return {
|
||||
surface: frame,
|
||||
time: (frame.duration || 100) / 1000.0 // convert ms to seconds
|
||||
@@ -138,7 +138,7 @@ function decode_aseprite(decoded) {
|
||||
|
||||
// Multiple frames without tags - return as single animation
|
||||
return {
|
||||
frames: decoded.frames.map(function(frame) {
|
||||
frames: array(decoded.frames, frame => {
|
||||
return {
|
||||
surface: frame,
|
||||
time: (frame.duration || 100) / 1000.0 // convert ms to seconds
|
||||
@@ -152,7 +152,7 @@ function create_image(path){
|
||||
try{
|
||||
def bytes = io.slurp(path);
|
||||
|
||||
var ext = path.split('.').pop()
|
||||
var ext = array(path, '.').pop()
|
||||
var raw = decode_image(bytes, ext);
|
||||
|
||||
/* ── Case A: single surface (from make_texture) ────────────── */
|
||||
@@ -258,7 +258,7 @@ graphics.texture = function texture(path) {
|
||||
if (!is_text(path))
|
||||
throw Error('need a string for graphics.texture')
|
||||
|
||||
var parts = path.split(':')
|
||||
var parts = array(path, ':')
|
||||
var id = parts[0]
|
||||
var animName = parts[1]
|
||||
var frameIndex = parts[2]
|
||||
@@ -353,7 +353,7 @@ graphics.texture = function texture(path) {
|
||||
}
|
||||
|
||||
graphics.tex_hotreload = function tex_hotreload(file) {
|
||||
var basename = file.split('/').pop().split('.')[0]
|
||||
var basename = array(array(file, '/').pop(), '.')[0]
|
||||
|
||||
// Check if this basename exists in our cache
|
||||
if (!(basename in cache)) return
|
||||
@@ -390,7 +390,7 @@ graphics.tex_hotreload = function tex_hotreload(file) {
|
||||
Merges specific properties from nv into ov, using an array of property names.
|
||||
*/
|
||||
function merge_objects(ov, nv, arr) {
|
||||
arr.forEach(x => ov[x] = nv[x])
|
||||
arrfor(arr, x => ov[x] = nv[x])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +411,7 @@ graphics.get_font = function get_font(path) {
|
||||
if (!is_text(path))
|
||||
throw Error(`Can't find font with path: ${path}`)
|
||||
|
||||
var parts = path.split('.')
|
||||
var parts = array(path, '.')
|
||||
var size = 16 // default size
|
||||
parts[1] = number(parts[1])
|
||||
if (parts[1]) {
|
||||
@@ -434,7 +434,7 @@ graphics.get_font = function get_font(path) {
|
||||
}
|
||||
|
||||
graphics.queue_sprite_mesh = function(queue) {
|
||||
var sprites = queue.filter(x => x.type == 'sprite')
|
||||
var sprites = filter(queue, x => x.type == 'sprite')
|
||||
if (sprites.length == 0) return []
|
||||
var mesh = graphics.make_sprite_mesh(sprites)
|
||||
for (var i = 0; i < sprites.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user