Skip to content

Commit fceee7d

Browse files
committed
Major update to extrusion; also creates color.blend(rgb1,rgb2) function
1 parent d823e96 commit fceee7d

File tree

3 files changed

+535
-377
lines changed

3 files changed

+535
-377
lines changed

lib/compiling/GScompiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ where compile() was called, in untrusted/run.js.
702702
let pre = m.index-1
703703
if (pre >= 0) {
704704
let p = line[pre]
705-
ok = (p == 'w' || p == '.' || p == ' ' || p == '=')
705+
ok = (p == 'w' || p == '.' || p == ' ' || p == '=' || p == '(')
706706
}
707707
if (ok) newprogram += ' '+indent+'sleep(0.1)'
708708
}

lib/glow/color.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@
7575
var g = Math.floor(255 * colvec.y)
7676
var b = Math.floor(255 * colvec.z)
7777
return 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')'
78+
},
79+
blend: function (c1, c2) { // convert two rgb colors to hsv, average the hues, return blended rgb
80+
let hsv1, hsv2, small, big, temp, hue
81+
hsv1 = color.rgb_to_hsv(c1)
82+
hsv2 = color.rgb_to_hsv(c2)
83+
if (hsv1.x < hsv2.x) {
84+
small = hsv1.x
85+
big = hsv2.x
86+
} else {
87+
small = hsv2.x
88+
big = hsv1.x
89+
}
90+
if (big-small > 0.5) {
91+
temp = small+1
92+
small = big
93+
big = temp
94+
}
95+
hue = (small+big)/2
96+
return color.hsv_to_rgb( vec(hue, (hsv1.y+hsv2.y)/2, (hsv1.z+hsv2.z)/2) )
7897
}
7998
}
8099

0 commit comments

Comments
 (0)