Skip to content

Easier way to make sure a number is in range #22

Description

@meodai
$value: (360 + $value) % 360;

you add you value to 360 (if the value is negative it will be subtracted) and then modulo 360 (meaning the rest of a division by 360)

@while $value >= 360 {
$value: $value - 360;
}
@while $value < 0 {
$value: $value + 360;
}

made a JS example: https://codepen.io/meodai/pen/dcc6b03dbde04469bc54fead46235c7a

Activity

  1. danielhaim1 commented on Nov 5, 2021

    @danielhaim1
    Member

    Neat, thanks @meodai. I'm working on a separate branch. with a lot of new additions and fixes. I'll go through this thread once it's merged and add your recommendation.

  2. self-assigned this
    on Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions