danielvoogsgerd / icon-finder-rs Goto Github PK
View Code? Open in Web Editor NEWThis project has not even entered alpha yet. It might soon though
License: ISC License
This project has not even entered alpha yet. It might soon though
License: ISC License
Some of the specifications are inlined as documentation in the project. This is still quite raw and needs some documentation for this specific implementation. I'm still doubting whether I should just include the spec wherever it's relevant under a separate heading.
According to the spec we have a function to determine distance and a function to determine an exact match. For the types fixed and scalable that is no problem. But taking a good look at threshold things, start to get weird.
The pseudocode for both functions below:
Inside DirectoryMatchesSize(subdir, iconsize, iconscale)
we find:
if Type is Threshold
return Size - Threshold <= iconsize <= Size + Threshold
Inside DirectorySizeDistance(subdir, iconsize, iconscale)
we find:
if Type is Threshold
if iconsize*iconscale < (Size - Threshold)*Scale
return MinSize*Scale - iconsize*iconscale
if iconsize*iconsize > (Size + Threshold)*Scale
return iconsize*iconsize - MaxSize*Scale
return 0
The problem is with the DirectorySizeDistance(...)
function. The two if-statements use the Threshold
, but the return uses MaxSize
and MinSize
.
This leads to this kind of behaviour.
theme_dir = {
"min_size": 256,
"max_size": 768,
"size": 512,
"scale": 1,
"threshold": 128
}
Of course negative distance does not make all that much sense.
Luckilly the spec gives us a hint.
Key | Description | Value Type | Required | Type |
---|---|---|---|---|
MaxSize | Specifies the maximum (unscaled) size that the icons in this directory can be scaled to. Defaults to the value of Size if not present. | integer | NO | Scalable |
MinSize | Specifies the minimum (unscaled) size that the icons in this directory can be scaled to. Defaults to the value of Size if not present. | integer | NO | Scalable |
Threshold | The icons in this directory can be used if the size differ at most this much from the desired (unscaled) size. Defaults to 2 if not present. | integer | NO | Threshold |
On one hand this would imply that the variables MaxSize
and MinSize
are not applicable for the icon type Threshold
, but if that were the case, why is it in the pseudocode?
Replacing DirectorySizeDistance(...)
with the following logic
if Type is Threshold
if iconsize*iconscale < (Size - Threshold)*Scale
return Size*Scale - iconsize*iconscale
if iconsize*iconsize > (Size + Threshold)*Scale
return iconsize*iconsize - Size*Scale
return 0
This makes more sense.
Another solution is replacing DirectorySizeDistance(...)
with something more along the lines of the behaviour of scaled. The logic for this would be:
if Type is Threshold
if iconsize*iconscale < (Size - Threshold)*Scale
return Size*Scale - iconsize*iconscale - Threshold
if iconsize*iconsize > (Size + Threshold)*Scale
return iconsize*iconsize - Size*Scale - Threshold
return 0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.