Show HN: Wiv.js – A library for a more wiggly div
jjkaufman.github.io
jjkaufman.github.io
var speed = parseFloat(wivCurve.parentNode.dataset.wivSpeed)
var height = parseFloat(wivCurve.parentNode.dataset.wivHeight)
var tightness = parseFloat(wivCurve.parentNode.dataset.wivTightness)
var thickness = parseFloat(wivCurve.parentNode.dataset.wivThickness)
var ctx = wivCurve.getContext("2d");
do this once on init, the canvas context remembers it anyway: ctx.strokeStyle = wivCurve.parentNode.dataset.wivColor != undefined ? wivCurve.parentNode.dataset.wivColor : "#FF0000"
don't convert numbers and strings all the time, use numbers and init them to 0 //current frame is tracked on per wiv basis. This is to help with speed calculations
if (parseFloat(wivCurve.dataset.count) > 100000) {
wivCurve.dataset.count = "0";
}
wivCurve.dataset.count = (wivCurve.dataset.count ? parseFloat(wivCurve.dataset.count) : 0) + speed;
parseFloat(wivCurve.dataset.count) also is used a lot in that loop.And don't set unneccessary canvas state, this should happen only once per draw loop iteration: [edit, actually, as I said above, the canvas contexts remember it individually, so do this once in initWiv(), and not in the draw loop at all, yay!]
ctx.lineWidth = thickness;
That's all just at first glance, but I bet you, this would help with slow laptops and whatnot :) Such "small" things really add up when you do them 60 times per second * number of borders. I don't know if setting the canvas width or height to the value it has anyway to clear it (instead of clearing/drawing a rectangle explicitly) is still a useful thing to do, but you might try that as well.https://github.com/jjkaufman/wiv.js/pull/5 if you are curious
You're the one who is rad! Thanks for sharing this Christmas gift! :)
(also, I love neocities. Happily donate to it and using it unironically for sharing small things)
it might be my ancient hardware, but this is rather CPU intensive it seems.
But the effect is fun, and cool non the less!
(on Linux, Xorg + Frirefox)
But now I realize these things should also be collected to a list somewhere. I linked your project in mine for starters. Thanks for sharing! Cheers!
Like an awesome list? What should it be called? awesome-oldschool maybe?
tl;dr ...websites with a lots of character which break best practice guidelines and design rules are able to capture audience better and produce better results (turnover, traffic, user retention, etc.)
So I ended up finding a neutral sounding word: QUIRKY - having or characterized by peculiar or unexpected traits or aspects.
I would gladly reformat quirky-ux to be primarely this collestion/list of quirky stuff, but maybe awesome-quirky makes more sense or awesome-quirky-ui or something similar...
Please contribute! If you really prefer the name awesome-quirksmode I have no problem with renaming the repo or adding you as a contributor so you can do it. Thanks for the feedback!
The canvas declaration is staring right at me now that I review it again. That's life...
https://github.com/ctrl-freaks/freezeframe.js
except this is just any regular div element