How to work in layers? [solved]

Pixilang programming language
Post Reply
philipbergwerf
Posts: 174
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) Downloaded 180 times
Last edited by philipbergwerf on Mon Jul 12, 2021 8:17 pm, edited 1 time in total.
User avatar
NightRadio
Site Admin
Posts: 3941
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: 174
Joined: Sat Mar 17, 2018 4:23 pm

Re: How to apply an effector in a layer?

Post by philipbergwerf »

Thank you!
User avatar
AutumnCheney
Posts: 503
Joined: Sun Dec 29, 2019 8:16 am
Location: tahlequah, ok, usa
Contact:

Re: How to work in layers? [solved]

Post by AutumnCheney »

i have a related question: how would i do this using the demoscene engine? i tried layering scenes on top of each other but it seems that coordinate system transform functions work on all scenes

i guess i should say, is it possible to have separate coordinate systems for each layer that are subject to their own functions?
my website: https://acheney.xyz

it features my music, sunvox content, and social media links!
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: How to work in layers? [solved]

Post by NightRadio »

is it possible to have separate coordinate systems for each layer that are subject to their own functions?
You can use t_reset() to reset the transormation to the default state:

Code: Select all

fn scene1( $t1, $t2, $len, $frame )
{
  t_scale(...)
  t_rotate(...)
  t_translate(...)
  //draw something
  t_reset()
}
fn scene2( $t1, $t2, $len, $frame )
{
  t_scale(...)
  t_rotate(...)
  t_translate(...)
  //draw something
  t_reset()
}
rototom
Posts: 24
Joined: Mon Mar 14, 2022 4:12 pm

Re: How to work in layers? [solved]

Post by rototom »

philipbergwerf wrote: Mon Jul 12, 2021 11:40 am 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 :)
cool visual @philipbergwerf
and thanks for the math include!
did you manage to draw the cicle in a second, independent level, and if, how?
Post Reply