MrFrankel / ruler

HTML5 Canvas ruler for authoring tools
http://mrfrankel.github.io/ruler/
221 stars 56 forks source link

very nice tool ! but I find Some can be improved. #6

Closed cyulin closed 7 years ago

cyulin commented 7 years ago

very nice tool ! Thank you MrFrankel ! This is what I need, but I find Some can be improved.

  1. If I call setScale(), the guide line is not follow the Ruler's scale.
  2. The same input( setGuides ) can't get the same output ( getGuides ).
MrFrankel commented 7 years ago

@wxa1048989080 Hey, Thanks for the feedback.

Seems to be bugs introduced recently, Ill look into them. Also the documentation needs a brush up.

MrFrankel commented 7 years ago

@wxa1048989080 Ive fixed the issues mentioned and also the demo page.

If you can please verify and can close this issue. thanks.

cyulin commented 7 years ago

@MrFrankel Excellent! I install the ruler package of version 1.0, after testing,the first problem has bend fixed, but the second question still exists.

I think this section code should changed: Source line 104

var constructGuide = function(dimension, x, y, e, isSet) {
        var guideIndex;
        //.....

        if (dimension === VERTICAL) {
            guide.style.left = ruler.prototype.utils.pixelize(x - options.container.getBoundingClientRect().left);

            if (isSet) guide.style.left = ruler.prototype.utils.pixelize( Math.round( x / CUR_SCALE ) + options.rulerHeight );

        } else {
            guide.style.top = ruler.prototype.utils.pixelize(y - options.container.getBoundingClientRect().top);

            if (isSet) guide.style.top = ruler.prototype.utils.pixelize( Math.round( y / CUR_SCALE ) + options.rulerHeight );
        }
       //......
    };
MrFrankel commented 7 years ago

@wxa1048989080 Not quit sure what you mean. If I do: var guides = myRuler.getGuides(); myRuler.clearGuides(); myRuler.setGuides(guides);

The guides are applied to the ruler.

Maybe if you can supply a gist reproducing the issue.

cyulin commented 7 years ago

Image of Yaktocat

cyulin commented 7 years ago

Got it?

MrFrankel commented 7 years ago

@wxa1048989080 Yea! got it! Best bug report ever!

You want to put in a pull request for the fix?

MrFrankel commented 7 years ago

fixed in #7