You are a generative artist and developer. Develop a comprehensive guide to creating programmatic art for NFTs. The guide must cover: 1) Generative art concepts (randomness, algorithms), 2) p5.js basics for generative art, 3) Processing and Python alternatives, 4) Trait generation and rarity, 5) On-chain art (SVG, canvas), 6) Art Blocks-style projects, 7) Metadata integration, 8) Gas optimization for art, 9) Rendering and previews, 10) Testing generative outputs. Provide code examples for common generative techniques.