Deriving a new Array from an existing Array:
['■','●','▲'].slice(1, 3) ⟼ ['●','▲']
['■','●','■'].filter(x => x==='■') ⟼ ['■','■']
['▲','●'].map(x => x+x) ⟼ ['▲▲','●●']
['▲','●'].flatMap(x => [x,x]) ⟼ ['▲','▲','●','●']| """ | |
| NOTE: make sure to install: | |
| pip install Pillow google-genai loguru | |
| """ | |
| from google import genai | |
| from google.genai import types | |
| from PIL import Image | |
| from io import BytesIO | |
| import os |
| from google import genai | |
| from google.genai import types | |
| from PIL import Image | |
| from io import BytesIO | |
| import os | |
| import subprocess | |
| import tempfile | |
| from global_config import global_config | |
| from loguru import logger as log |
| const canvasSketch = require('canvas-sketch'); | |
| const { lerp } = require('./util/math'); | |
| const settings = { | |
| animate: true, | |
| duration: 3, | |
| dimensions: [ 640, 640 ], | |
| scaleToView: true, | |
| playbackRate: 'throttle', | |
| fps: 24 |
| const canvasSketch = require('canvas-sketch'); // not yet released tool | |
| const Random = require('./util/random'); | |
| const { lerp } = require('./util/math'); | |
| // We can force a random seed or a specific string/number | |
| Random.setSeed(Random.getRandomSeed()); | |
| const settings = { | |
| pixelsPerInch: 300, | |
| // When exporting, use the seed as the suffix |
| const sketcher = require('canvas-sketch-tool'); | |
| const settings = { | |
| // Pixel [width,height] of our artwork | |
| dimensions: [ 1280, 1280 ], | |
| // Export at a higher resolution than what we see | |
| // in the browser | |
| exportPixelRatio: 2 | |
| }; |
| const sketcher = require('canvas-sketch-tool'); // not yet public | |
| const seedRandom = require('seed-random'); | |
| const settings = { | |
| // Output resolution, we use a high value for print artwork | |
| pixelsPerInch: 300, | |
| // US Letter size 8.5x11 inches | |
| dimensions: [ 8.5, 11 ], | |
| // all our dimensions and rendering units will use inches | |
| units: 'in' |
| // Plane folding | |
| // Copyright by tsulej 2014, edited by Etienne Jacob (necessary-disorder.tumblr.com) | |
| // click mouse to change drawing | |
| float step ; | |
| Folds f; | |
| int[] folds = new int[8]; | |
| ///////////////////////////////////////////////////// | |
| // CHANGE THIS TO CHANGE THE 2D TRANSFORMATION USED ! |
| ArrayList<Rect> rects; | |
| float mx, my, mm, time; | |
| void setup() { | |
| size(720, 720, P2D); | |
| generate(); | |
| } | |
| void draw() { |