kopia lustrzana https://github.com/ertdfgcvb/play.core
Cleanup in programs and tests
rodzic
d3d23610fb
commit
8230941dc0
|
@ -8,7 +8,7 @@ import { map } from '/src/modules/num.js'
|
|||
import { sort } from '/src/modules/sort.js'
|
||||
import { vec2, rot, add, mulN, addN, subN, length } from '/src/modules/vec2.js'
|
||||
|
||||
const chars = '╳╱╲XYZabc.:+-=!? '.split('')
|
||||
const chars = '#Wabc:+-. '.split('')
|
||||
const colors = ['deeppink', 'black', 'red', 'blue', 'orange', 'yellow']
|
||||
|
||||
export function main(coord, context, cursor, buffers){
|
||||
|
@ -44,8 +44,8 @@ export function main(coord, context, cursor, buffers){
|
|||
c = Math.sin(st.x * 3.0 + s) + Math.sin(st.y * 21)
|
||||
c = map(Math.sin(c * 0.5), -1, 1, 0, 1)
|
||||
|
||||
const index = Math.floor(c * chars.length - 1)
|
||||
const color = Math.floor(c * colors.length - 1)
|
||||
const index = Math.floor(c * (chars.length - 1))
|
||||
const color = Math.floor(c * (colors.length - 1))
|
||||
|
||||
return {
|
||||
// char : (coord.x + coord.y) % 2 ? chars[index] : '╲',
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
import { sdCircle, opSmoothUnion } from "/src/modules/sdf.js"
|
||||
import { sub, vec2 } from "/src/modules/vec2.js"
|
||||
|
||||
const charMap = "╳\\|/?*:÷×+-=·".split('')
|
||||
const charMap = "#WX?*:÷×+=-· ".split('')
|
||||
|
||||
export function main(coord, context, cursor, buffers){
|
||||
|
||||
const t = context.time
|
||||
|
||||
const a = Math.min(context.cols, context.rows)
|
||||
const st = {
|
||||
x : 2.0 * (coord.x - context.cols / 2) / a * context.aspect,
|
||||
|
@ -23,30 +22,22 @@ export function main(coord, context, cursor, buffers){
|
|||
// A bit of a waste as cursor is not coord dependent;
|
||||
// it could be calculated in pre(), and stored in a global
|
||||
// (see commented code below).
|
||||
const p = {
|
||||
const pointer = {
|
||||
x : 2.0 * (cursor.x - context.cols / 2) / a * context.aspect,
|
||||
y : 2.0 * (cursor.y - context.rows / 2) / a
|
||||
}
|
||||
|
||||
// Positions
|
||||
const pos1 = sub(st, vec2(Math.cos(t*0.0012)*0.5, Math.sin(t*0.0011)*0.5))
|
||||
const pos2 = sub(st, p)
|
||||
|
||||
// Radii
|
||||
const rad1 = Math.cos(t * 0.002) * 0.2 + 0.2
|
||||
const rad2 = Math.cos(t * 0.003) * 0.2 + 0.2
|
||||
|
||||
// Circles
|
||||
const d1 = sdCircle(pos1, rad1)
|
||||
const d2 = sdCircle(pos2, rad2)
|
||||
const d1 = sdCircle(st, 0.2) // origin, 0.2 is the radius
|
||||
const d2 = sdCircle(sub(st, pointer), 0.2) // cursor
|
||||
|
||||
let d = 1e100
|
||||
d = opSmoothUnion(d, d1, 0.5)
|
||||
d = opSmoothUnion(d, d2, 0.5)
|
||||
|
||||
let c = 1.0 - Math.exp(-10 * Math.abs(d))
|
||||
// Smooth operation
|
||||
const d = opSmoothUnion(d1, d2, 0.9)
|
||||
|
||||
// Calc index of the char map
|
||||
const c = 1.0 - Math.exp(-5 * Math.abs(d))
|
||||
const index = Math.floor(c * charMap.length)
|
||||
|
||||
return charMap[index]
|
||||
}
|
||||
|
||||
|
@ -56,7 +47,7 @@ export function post(context, metrics, cursor, buffers){
|
|||
}
|
||||
|
||||
// Uncomment this to calculate the cursor position only once
|
||||
// And pass it to the main function as a global
|
||||
// and pass it to the main function as a global or as object in buffers.data
|
||||
/*
|
||||
const p = vec2(0, 0)
|
||||
export function pre(context, cursor, buffers){
|
||||
|
@ -66,3 +57,5 @@ export function pre(context, cursor, buffers){
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
|
||||
const TAU = Math.PI * 2
|
||||
|
||||
export function main(coord, context){
|
||||
const a = context.frame * 0.05
|
||||
const f = Math.floor((1-Math.cos(a)) * 10) + 1
|
||||
const g = Math.floor(a / TAU) % 6 + 1
|
||||
const i = coord.index % (coord.y * g + 1) % (f % context.cols)
|
||||
return {
|
||||
char : 'Andreas'[i],
|
||||
export const settings = {
|
||||
background : 'black',
|
||||
color : 'white',
|
||||
weight : '700'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function main(coord, context){
|
||||
const a = context.frame * 0.05
|
||||
const f = Math.floor((1-Math.cos(a)) * 10) + 1
|
||||
const g = Math.floor(a / TAU) % 10 + 1
|
||||
const i = coord.index % (coord.y * g + 1) % (f % context.cols)
|
||||
return 'Ada'[i]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { sort } from '/src/modules/sort.js'
|
|||
import { length, dot, rot } from '/src/modules/vec2.js'
|
||||
import { map, fract, smoothstep } from '/src/modules/num.js'
|
||||
|
||||
const charMap = sort('▚╳▄▀▐─═0123.+?+'.split(''))
|
||||
const chars = sort('▀▄▚▐─═0123.+?'.split(''))
|
||||
|
||||
export function main(coord, context, cursor, buffer){
|
||||
|
||||
|
@ -39,13 +39,12 @@ export function main(coord, context, cursor, buffer){
|
|||
const k = smoothstep(width, width + 0.2, Math.sin(10 * d + t));
|
||||
const c = (1.0 - Math.exp(-3 * Math.abs(d))) * k
|
||||
|
||||
const index = Math.floor(c * charMap.length)
|
||||
const index = Math.floor(c * (chars.length-1))
|
||||
|
||||
return {
|
||||
char : charMap[index],
|
||||
color : k < 0.4 ? 'orangered' : 'royalblue',
|
||||
char : chars[index],
|
||||
color : k == 0 ? 'orangered' : 'royalblue',
|
||||
// background : coord.y % 2 ? 'white' : 'cornsilk'
|
||||
background : 'cornsilk'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ abcdefghijklmnopqrstuvwxyz{|}~ ¡
|
|||
|
||||
▁▂▃▄▅▆▇█ ▖▗▘▙▚▛▜▝▞▟
|
||||
|
||||
XXX-XXX-XXX-XXX-XXX-XXX-XXX
|
||||
XX-XXX-XXX-XXX-XXX-XXX-XXX-
|
||||
X-XXX-XXX-XXX-XXX-XXX-XXX-X
|
||||
-XXX-XXX-XXX-XXX-XXX-XXX-XX
|
||||
XXX-XXX-XXX-XXX-XXX-XXX-
|
||||
XX-XXX-XXX-XXX-XXX-XXX-X
|
||||
X-XXX-XXX-XXX-XXX-XXX-XX
|
||||
-XXX-XXX-XXX-XXX-XXX-XXX
|
||||
|
||||
╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ┏━━┳━━┓
|
||||
║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ ┃┌─╂─┐┃
|
||||
|
|
Ładowanie…
Reference in New Issue