Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFast Text width & height #189
Comments
vilterp
changed the title from
Fast Text width & heigh
to
Fast Text width & height
Mar 6, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vilterp
Apr 9, 2015
Here's a test showing measureText being 15x faster when I ran it (120k ops/sec vs. 8k ops/sec): https://jsperf.com/text-measurement-element-vs-canvas
vilterp
commented
Apr 9, 2015
|
Here's a test showing measureText being 15x faster when I ran it (120k ops/sec vs. 8k ops/sec): https://jsperf.com/text-measurement-element-vs-canvas |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vilterp
May 5, 2015
Implemented this as a native module in elm-diagrams; unfortunately canvas and DOM do not measure text width the same way, and canvas does not measure text height at all (see vilterp/elm-diagrams#36). So, not sure how to go about this.
vilterp
commented
May 5, 2015
|
Implemented this as a native module in elm-diagrams; unfortunately canvas and DOM do not measure text width the same way, and canvas does not measure text height at all (see vilterp/elm-diagrams#36). So, not sure how to go about this. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
May 11, 2016
Member
Sorry this did not get attention til now! The Graphics.* modules now live in evancz/elm-graphics so I am trying to get stuff migrated over there.
That said, I would like to keep that API stable for now. I expect to be focusing on <canvas> for professional users and "friendly graphics" for learning as separate use cases. Progress will be made when those start happening.
|
Sorry this did not get attention til now! The That said, I would like to keep that API stable for now. I expect to be focusing on |
vilterp commentedMar 6, 2015
Adding something like
textWidth : Text -> FloatandtextHeight : Text -> Floatto either Graphics.Collage or Text would be nice for laying out graphics which include text, but also forms. I suspect using the canvas'smeasureTextmethod would be faster than the current way of getting text width & height, which is making the text into an element and usingwidthOf, which uses the DOM.This would be a good addition to the recent change allowing direct rendering of text to canvas (#118).
I'm currently developing an app in which elements containing text are dragged and dropped. Constructing the Forms every frame from the data model involves getting the widths of each piece of text, and according to the Chrome profiler getting this width (the
htmlHeightmethod) is taking up the most time of anything in my code on each frame.