Giter Site home page Giter Site logo

zeevallin / gradient Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 4.0 405 KB

Library for dealing with color gradients in ruby

Home Page: http://rubygems.org/gems/gradient

License: MIT License

Ruby 99.74% Shell 0.26%
gradient color-gradient photoshop adobe-photoshop-gradient ruby opacity gradient-map point-vectors css

gradient's People

Contributors

jjg-aframe avatar miguelms95 avatar zeevallin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gradient's Issues

Problem with sort

The Gradient::Map initialiser sorts the initial set of points by location, which is fine if there are no repeated locations. However, in order to correctly represent discontinuities in gradients, duplicate locations need to be handled. Consider the following simple step gradient

[0.0, black], [0.5, black], [0.5. white], [1.0, white]

If we sort this array by location with a non-stable sort, such as Ruby's, then the result may be a sawtooth

[0.0, black], [0.5, white], [0.5. black], [1.0, white]

Several solutions are possible

  • implement a stable sort on top of an unstable one (see the second link above)
  • check if the input is sorted, if it is then do not sort it
  • forbid discontinuities in the input

(those would be in my order of preference), and probably others.

scanf is no longer bundled with Ruby 2.7.0

Hi there,

I'm using your libary to create triangle patterns and I've noticed that there seems to be an Issue with Ruby 2.7.

When I run bin/console in ruby 2.7 I'm getting the following error:

Traceback (most recent call last):
	5: from bin/console:4:in `<main>'
	4: from bin/console:4:in `require'
	3: from /home/wolle/projekte/gradient/lib/gradient.rb:8:in `<top (required)>'
	2: from /home/wolle/projekte/gradient/lib/gradient.rb:8:in `require'
	1: from /home/wolle/projekte/gradient/lib/gradient/svg.rb:1:in `<top (required)>'
/home/wolle/projekte/gradient/lib/gradient/svg.rb:1:in `require': cannot load such file -- scanf (LoadError)

scanf cannot be loaded because it was excluded as a standard libary as of version 2.7 https://rubyreferences.github.io/rubychanges/2.7.html#libraries-excluded-from-the-standard-library

Solution:

Include scanf in your gemspec

Improve: model's functions documentation

Hi, first of all, thanks for the gem!
It would be great to describe at README the functions in the models.

I want to get a color interpolation and print as background in a table, I need the hexadecimal color, i had to inspect the code to find that it could be done with color.hex

gradient = Gradient::Map.new(
      Gradient::Point.new(0, Color::RGB.new(255, 255, 255), 1.0),
      Gradient::Point.new(1, Color::RGB.new(226, 82, 82), 1.0)
    )
gradient.at(0.5).color.hex

I suggest to add this info to the readme and the other functions... it could help.

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.