Code Compliance

This page serves as a comprehensive guide for artists and developers to ensure their code meets the unique requirements of the Genify platform

Understanding and adhering to these standards is crucial for maintaining the integrity and consistency of your generative art. Here, you'll find detailed instructions on how to:

Utilize Genify's Random Functions: Learn how to use Genify's specific random functions for generating numbers, booleans, and choosing elements from a list. This ensures that your artwork remains consistent across different renders with the same hash.

//How to use genify random functions

// Generate a random decimal number between 0 and 1
let decimal = R.random_dec();

// Generate a random number between 'a' and 'b'
let num = R.random_num(10, 20); 

// Generate a random integer between 'a' and 'b'
let integer = R.random_int(1, 100); 

// Generate a boolean value based on a probability 'p'
let bool = R.random_bool(0.5); 

// Randomly choose an element from a list
let choice = R.random_choice(["apple", "banana", "cherry"]); 

Signal that rendering is done

R.render_done(); 

Set features for generation

R.set_features({"key1": "value1", "key2": "value2"});

Add Extra CSS Styles: Instructions on how to incorporate additional CSS styles into your artwork, enhancing its visual appeal without affecting its performance.

let gcss = document.getElementById("gcss");
let style = '.myclass { color: red; }';
gcss.innerHTML = gcss.innerHTML + style;

Adapt p5.js Code: A step-by-step guide on how to modify your p5.js code so that it integrates seamlessly with the Genify platform, ensuring compatibility and performance. p5.js@1.0 or p5.js@1.6

document.addEventListener('p5Loaded', () => {
    function setup() {
        //your original setup code
    }

    function draw() {
        //your original draw code
    }

    window.setup = setup;
    window.draw = draw;
}); 

Use Genify Random Functions in p5.js: Techniques for incorporating Genify's random functions within your p5.js code, enabling you to maintain consistency in randomness and generate unique yet replicable artwork patterns.

function setup() {
    let seed = ~~(R.random_dec() * 123456789);
    randomSeed(seed);
    noiseSeed(seed);
}

Important Tip:

If you encounter a conflict with the variable R in your code, you can resolve this by redefining it at the very beginning of your script. For example, you can create a new instance of the random number generator by declaring

var Rr = new Random();

. This allows you to use Rr instead of R to access Genify's random functions, thus avoiding any potential naming conflicts. This approach ensures that your code runs smoothly on the Genify platform, while maintaining consistency and readability.

Last updated