css-doodle
Advanced tools
Comparing version 0.40.0 to 0.40.1
{ | ||
"name": "css-doodle", | ||
"version": "0.40.0", | ||
"version": "0.40.1", | ||
"description": "A web component for drawing patterns with CSS", | ||
@@ -29,3 +29,3 @@ "scripts": { | ||
"exports": { | ||
".": "src/index.js", | ||
".": "./css-doodle.min.js", | ||
"./component": { | ||
@@ -32,0 +32,0 @@ "import": "./src/exports/component/index.js" |
@@ -74,3 +74,6 @@ import parse_value_group from './parser/parse-value-group.js'; | ||
function add_unit(input, unit) { | ||
return unit ? `calc((${input}) * 1${unit})` : `calc(${input})`; | ||
let value = unit | ||
? `calc((${input}) * 1${unit})` | ||
: `calc(${input})`; | ||
return [value]; | ||
} | ||
@@ -90,3 +93,3 @@ | ||
} | ||
return compute(op, Number(base), Number(value)) + unit; | ||
return [compute(op, Number(base), Number(value)), unit]; | ||
} | ||
@@ -101,6 +104,6 @@ else if (/[\+\*\-\/%]$/.test(v)) { | ||
} | ||
return compute(op, Number(value), Number(base)) + unit; | ||
return [compute(op, Number(value), Number(base)), unit]; | ||
} else { | ||
let { unit = '', value } = parse_compound_value(v || 0); | ||
return (Number(base) + Number(value)) + unit; | ||
return [(Number(base) + Number(value)), unit]; | ||
} | ||
@@ -110,7 +113,12 @@ } | ||
function calc_with(base) { | ||
let unit = ''; | ||
return (...args) => { | ||
for (let v of args) { | ||
base = calc_value(base, v); | ||
let [output, output_unit] = calc_value(base, v); | ||
base = output; | ||
if (!unit) { | ||
unit = output_unit; | ||
} | ||
} | ||
return base; | ||
return base + unit; | ||
} | ||
@@ -117,0 +125,0 @@ } |
@@ -382,5 +382,11 @@ import Func from '../function.js'; | ||
if (rotate) { | ||
if (/[0-9]$/.test(rotate)) { | ||
rotate += 'deg'; | ||
} | ||
this.add_rule(':container', `rotate:${rotate};`); | ||
} | ||
if (hueRotate) { | ||
if (/[0-9]$/.test(hueRotate)) { | ||
hueRotate += 'deg'; | ||
} | ||
this.add_rule(':host', `filter:hue-rotate(${hueRotate});`); | ||
@@ -387,0 +393,0 @@ } |
@@ -6,4 +6,2 @@ /** | ||
import { lerp } from '../utils/index.js'; | ||
const map = [ | ||
@@ -25,2 +23,14 @@ 151,160,137,91,90,15, | ||
function lerp(t, a, b) { | ||
return a + t * (b - a); | ||
}; | ||
// Convert LO 4 bits of hash code into 12 gradient directions. | ||
function grad(hash, x, y, z) { | ||
let h = hash & 15, | ||
u = h < 8 ? x : y, | ||
v = h < 4 ? y : h == 12 || h == 14 ? x : z; | ||
return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v); | ||
} | ||
export default class Perlin { | ||
@@ -31,12 +41,4 @@ constructor() { | ||
// Convert LO 4 bits of hash code into 12 gradient directions. | ||
grad(hash, x, y, z) { | ||
let h = hash & 15, | ||
u = h < 8 ? x : y, | ||
v = h < 4 ? y : h == 12 || h == 14 ? x : z; | ||
return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v); | ||
} | ||
noise(x, y, z) { | ||
let { p, grad } = this; | ||
let { p } = this; | ||
// Find unit cube that contains point. | ||
@@ -43,0 +45,0 @@ let [X, Y, Z] = [x, y, z].map(n => Math.floor(n) & 255); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
270509
6580