How to work in layers? [solved]

Pixilang programming language
Post Reply
philipbergwerf
Posts: 132
Joined: Sat Mar 17, 2018 4:23 pm

How to work in layers? [solved]

Post by philipbergwerf »

I created a cool looking visual using pixilang!

Code: Select all

include "math.pixi"

set_pixel_size( WINDOW_XSIZE / 2048 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )

scr = get_screen()
xscr = get_xsize( scr )
yscr = get_ysize( scr )

prob = 10

while(1)
{
    $greyshd = rand_range_int(0, 100)
    $grey = get_color(rand_range_int(0, 150), greyshd, $greyshd)
    
    $i = 0 while $i < 100
    {
        fire(rand_range(-xscr, xscr), 0+yscr/2-10, $grey)
        $i + 1
    }

    effector(EFF_HBLUR, 1.5)//try
    effector(EFF_VBLUR, 1.5)//try
    effector( EFF_SPREAD_LEFT, prob+1, WHITE )
    effector( EFF_SPREAD_RIGHT, prob, WHITE )
    effector( EFF_SPREAD_UP, prob, WHITE )

    while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { breakall } }
    frame()
}

fn fire($x, $y, $c)
{
    dot($x, $y, $c)
}
But how can I add things over this without having the effector play with it? So lets say I want a clean circle on top of this visual. How to do this? I attached my project so you can run it :)
Attachments
visuals.zip
(2.17 KiB) Not downloaded yet
Last edited by philipbergwerf on Mon Jul 12, 2021 8:17 pm, edited 1 time in total.
User avatar
NightRadio
Site Admin
Posts: 3549
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: How to apply an effector in a layer?

Post by NightRadio »

Please try to use an additional screen container:

Code: Select all

scr = get_screen()
scr2 = clone( scr )

while 1
{
  //First layer:
  set_screen(scr)
  ... draw something ...
  
  //Second layer (top):
  set_screen(scr2)
  pixi(scr) //draw previuos layer
  ... draw something ...
  
  frame()  //show the second layer
}
philipbergwerf
Posts: 132
Joined: Sat Mar 17, 2018 4:23 pm

Re: How to apply an effector in a layer?

Post by philipbergwerf »

Thank you!
Post Reply