Autor Tema: Dos funciones para crear cajas y marcos  (Leído 732 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado iOtero

  • VIP
  • *
  • Mensajes: 2961
  • Gracias 104
  • Ciudad: Uno de Bilbao en Villanueva de la Cañada (Madrid)
  • Pais: España
  • Iniciales nick: ioc
Dos funciones para crear cajas y marcos
« en: Julio 11, 2018, 03:54:37 pm »
Advertisement
Me parece que attract mode no tiene funciones directas para hacerlo, así que por si a alguien le puede servir de algo, aquí van dos funciones para crear cajas y marcos.

Código: [Seleccionar]
// Dos funciones para crear cajas y marcos
//
// Primero crear un png blanco de 1x1 pixels y salvarlo como "white_point.png"
// Segundo, crear en el layout una carpeta llamada objs y copiar "white_point.png" dentro de ella.

//
// Function draw_box(box_x,box_y,box_w,box_h,box_r,box_g,box_b,box_a,box_s)
//
// box_x --> The x coordinate of the top left corner of the box (in layout coordinates).
// box_y --> The y coordinate of the top left corner of the box (in layout coordinates).
// box_w --> The width of the box (in layout coordinates).
// box_h --> The height of the box (in layout coordinates).
// box_r --> Set red colour level for the box. Range is 0-255.
// box_g --> Set green colour level for the box. Range is 0-255.
// box_b --> Set blue colour level for the box. Range is 0-255.
// box_a --> Set alpha level for the box. Range is 0-255.
// box_s --> Width of the box shadow (in layout coordinates). Set 0 for no shadow.

function draw_box(box_x,box_y,box_w,box_h,box_r,box_g,box_b,box_a,box_s)
{
if(box_s != 0)
{
local bflw = fe.layout.width;
local bflh = fe.layout.height;

local dbox = fe.add_image("objs/sys/white_point.png", box_x+box_s, box_y+box_s, box_w, box_h);
dbox.set_rgb(0,0,0);
dbox.alpha=255;
}

local dbox = fe.add_image("objs/sys/white_point.png", box_x, box_y, box_w, box_h);
dbox.set_rgb(box_r,box_g,box_b);
dbox.alpha=box_a;

}

// Function draw_frame(box_x,box_y,box_w,box_h,box_r,box_g,box_b,box_a,box_s)
//
// frame_x --> The x coordinate of the top left corner of the frame (in layout coordinates).
// frame_y --> The y coordinate of the top left corner of the frame (in layout coordinates).
// frame_w --> The width of the frame (in layout coordinates).
// frame_h --> The height of the frame (in layout coordinates).
// frame_r --> Set red colour level for the frame. Range is 0-255.
// frame_g --> Set green colour level for the frame. Range is 0-255.
// frame_b --> Set blue colour level for the frame. Range is 0-255.
// frame_a --> Set alpha level for the frame. Range is 0-255.
// frame_fw --> The Width of the border of the frame (in layout coordinates).
// frame_fh --> The Height of the border of the frame (in layout coordinates).

function draw_frame(frame_x,frame_y,frame_w,frame_h,frame_r,frame_g,frame_b,frame_a,frame_fw,frame_fh)
{
local dframe1 = fe.add_image("objs/white_point.png", frame_x, frame_y, frame_w, frame_fh);
dframe1.set_rgb(frame_r,frame_g,frame_b);
dframe1.alpha=frame_a;

local dframe2 = fe.add_image("objs/white_point.png", frame_x, frame_y+frame_h, frame_w, frame_fh);
dframe2.set_rgb(frame_r,frame_g,frame_b);
dframe2.alpha=frame_a;

local dframe3 = fe.add_image("objs/white_point.png", frame_x, frame_y, frame_fw, frame_h);
dframe3.set_rgb(frame_r,frame_g,frame_b);
dframe3.alpha=frame_a;

local dframe4 = fe.add_image("objs/white_point.png", frame_x+frame_w, frame_y, frame_fw, frame_h+frame_fh);
dframe4.set_rgb(frame_r,frame_g,frame_b);
dframe4.alpha=frame_a;
}

// Example: Draw two boxes and one frame
local flx = fe.layout.width;
local fly = fe.layout.height;
local flw = fe.layout.width;
local flh = fe.layout.height;
draw_box(flx*0.3, fly*0.3, flw*0.5, flh*0.5, 175, 175, 175, 255,flw*0.005);
draw_box(flx*0.35, fly*0.35, flw*0.4, flh*0.4, 135, 175, 50, 150,0);
draw_frame(flx*0.35, fly*0.35, flw*0.4, flh*0.4, 255, 0, 0, 255, flw*0.002, flh*0.003);



Lo he puesto aquí, pero si debe ir en Themes, que alguien lo mueva...
« Última modificación: Julio 11, 2018, 08:10:19 pm por zlagos »



Desconectado Josepzin

  • VIP
  • *
  • Mensajes: 2219
  • Gracias 38
  • Habitacus!
    • Blog
  • Ciudad: Carthago Miriya
  • Pais: Argentina
Re:Dos funciones para crear cajas y marcos
« Respuesta #1 en: Julio 11, 2018, 07:04:56 pm »
Estas cosas deben ir acompañadas de una imagen, que no soy Neo que puede interpretar la Matrix viendo sólo el código!!

Desconectado iOtero

  • VIP
  • *
  • Mensajes: 2961
  • Gracias 104
  • Ciudad: Uno de Bilbao en Villanueva de la Cañada (Madrid)
  • Pais: España
  • Iniciales nick: ioc
Re:Dos funciones para crear cajas y marcos
« Respuesta #2 en: Julio 11, 2018, 08:09:50 pm »
Estas cosas deben ir acompañadas de una imagen, que no soy Neo que puede interpretar la Matrix viendo sólo el código!!

Pero qué comodón es mi niño... anda que te cuesta mucho copiar el código y pegarlo en cualquier layout con el que andes enredando... si hasta te he puesto un ejemplo al final...  :P

Lo que pasa es que aún llevas clavado en el alma lo de la JukeBox... :D :D :D

Desconectado Josepzin

  • VIP
  • *
  • Mensajes: 2219
  • Gracias 38
  • Habitacus!
    • Blog
  • Ciudad: Carthago Miriya
  • Pais: Argentina
Re:Dos funciones para crear cajas y marcos
« Respuesta #3 en: Julio 12, 2018, 12:20:48 am »
La traición de Bruto no puede ser comparada con la tuya... #traitor

Y si, Señor Comodón, en mayusculas :P

 


* Salón Recreativo #56 - Olympics 2024 (01-07-2024 / 21-07-2024)  Autor: periko Foro: Salón Recreativo FaseBonus 07/07/2024 (00:38)
* ¿A qué estáis jugando ahora mismo?  Autor: joselopez Foro: Offtopic 06/07/2024 (00:19)
* Reto 202 - Track & Field - jordani11 76050 puntos  Autor: Zael Foro: Competiciones y concursos 03/07/2024 (20:54)
* [Recomendación] Cine para los findes en casa (bueno, bonito y barato)  Autor: arquillos Foro: Offtopic 01/07/2024 (19:47)
* Reto Amiguero 11 - Abu Simbel Profanation The Full Adventura 1.1  Autor: Zael Foro: Commodore Amiga 23/06/2024 (16:30)
* Están muy callados los culerdos, no?  Autor: daninuyusio Foro: Offtopic 22/06/2024 (21:43)
* La revolución que suponen las IA generativas de imágenes a partir de texto  Autor: zzgus Foro: Offtopic 22/06/2024 (19:11)
* [N3DS] Red Viper - Emulando Virtual Boy como Dios manda  Autor: Zael Foro: Noticias de emuladores 17/06/2024 (14:11)
* Reto 321 - Joust 2 - Survival of the Fittest  Autor: Zael Foro: Competiciones y concursos 16/06/2024 (11:37)
* M.A.L.A147+Mame0.153 64/32 bits +35 Roms + Layout Tron_MameV1   Autor: Zael Foro: MALA 16/06/2024 (11:32)
* ZX Touch o el timo de la estampita  Autor: sirdrak Foro: Retroconsolas 12/06/2024 (15:00)
* Lección de vida  Autor: Zael Foro: Offtopic 10/06/2024 (13:13)
* MPAGD (Multi Platform Arcade Game Designer)  Autor: empardopo Foro: Creación de juegos 09/06/2024 (14:37)
* El megapost del ZX Spectrum  Autor: empardopo Foro: Offtopic 09/06/2024 (14:25)
* Ayuda con configuración emulador PXSX2  Autor: empardopo Foro: Emuladores 09/06/2024 (14:20)
* Amiga Games + 1.9.7  Autor: empardopo Foro: Emuladores 09/06/2024 (14:12)
* Salón Recreativo #55 (27-04-2024 / 26-05-2024)  Autor: hoz3 Foro: Salón Recreativo FaseBonus 04/06/2024 (05:52)
* ASUS, ¿me engaña, me tima o se rie de mí?  Autor: empardopo Foro: Offtopic 03/06/2024 (20:09)
* [PS4] PS4 5.05 - Should I Stay or Shoud I Go?  Autor: empardopo Foro: Consolas actuales 03/06/2024 (20:07)
* Retro Portable Maker ArcadeSpain (RPMA)  Autor: empardopo Foro: Otros programas 03/06/2024 (20:03)
* Volante PXN V9 - ¿Ganga... o tongo?  Autor: Zael Foro: Reviews tecnológicas 01/06/2024 (12:08)
* Ofertas Amazon  Autor: empardopo Foro: Offtopic 30/05/2024 (19:35)
* Reto 320 - Wizard of wor  Autor: empardopo Foro: Competiciones y concursos 28/05/2024 (20:58)
* GB-Operator (Emulador GB/GBC/GBA en PC)  Autor: Zael Foro: Retroconsolas 28/05/2024 (20:12)
* Salón Recreativo FaseBonus - Preparativos y Sugerencias  Autor: Zael Foro: Salón Recreativo FaseBonus 24/05/2024 (10:21)
* Música y artistas aptos para nuestra jukebox  Autor: empardopo Foro: Offtopic 22/05/2024 (20:02)
* [Recomendacion] Series para ver  Autor: empardopo Foro: Offtopic 20/05/2024 (20:21)
* Van dos y se cae el del medio - Hilo de cachondeo general  Autor: joselopez Foro: Offtopic 16/05/2024 (00:56)

Reto 320: Wizard of Wor
Buscaunchollo.click