• Home
  • Blog
  • C# / Unity
  • C++ / Unreal Engine
  • Python strategy games
  • Python arcade games
  • Python other
  • Machine Learning
  • C
  • Scratch
  • Coding and electronics
  • How I learnt to code
  • Project Euler
  • Feedback
  James L.'s coding

James's blog

what I've been doing.

Graphite - Rulers

28/10/2021

0 Comments

 
Picture
I have made the rulers functional for graphite, a work in progress vector editor written in the Rust programming language with Web Assembly. This was a smaller MR (merge request) with the main challenge being to dynamically adjust the distance between the major numbered lines so that the increments where round numbers. I achieved this through base 2 logarithms, a function which I had not previously come across. This allows the interval to double or half as many times as necessary for the current zoom, whilst maintaining a sensible gap of 51-100px between each number. I also had some issues with the modulus function not working correctly on negative numbers in javascript which took quite a bit of debugging to track down. This emphasized for me the value of planning things out on paper. The functionality is avaliable on the master branch build of graphite at editor.graphite.design/ The canvas can be moved with the middle mouse button, space plus left mouse button drag or with the scrollbars after drawing a shape.
0 Comments



Leave a Reply.

    Advert:

    Author

    I am doing lots of projects every projects all the time and I can't put them all on the website so I've made a blog.

    Archives

    August 2022
    April 2022
    March 2022
    February 2022
    January 2022
    November 2021
    October 2021
    August 2021
    July 2021
    June 2021
    April 2021
    March 2021
    June 2020
    May 2020
    April 2020
    March 2020
    September 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    November 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017

    Categories

    All

Proudly powered by Weebly
  • Home
  • Blog
  • C# / Unity
  • C++ / Unreal Engine
  • Python strategy games
  • Python arcade games
  • Python other
  • Machine Learning
  • C
  • Scratch
  • Coding and electronics
  • How I learnt to code
  • Project Euler
  • Feedback