Giter Site home page Giter Site logo

icon-finder-rs's People

Contributors

danielvoogsgerd avatar

Watchers

 avatar  avatar

icon-finder-rs's Issues

Add README / Documentation

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.

Threshold behaviour according to spec makes no sense

The Problem

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
}

image

Of course negative distance does not make all that much sense.

Luckilly the spec gives us a hint.

Table 2. Per-Directory Keys

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?

Solution

Solution 1

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

yields the following result
image

This makes more sense.

Solution 2

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

and this yield the following result
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.