Giter Club home page Giter Club logo

Comments (4)

bohonghuang avatar bohonghuang commented on July 19, 2024

In Common Lisp, single-precision floating-point is the default, so both 0.0 and 0s0 represent single-precision floating-point numbers. To use double-precision floating-point, you need to write it as 0d0. Therefore, your code should be modified as follows:

(let ((level-bar-widget (gtk:make-level-bar :min-value 0d0 :max-value 4d0)))
  (setf (gtk:level-bar-mode level-bar-widget) gtk:+level-bar-mode-discrete+)
  (setf (gtk:level-bar-value level-bar-widget) 2d0)
  (gtk:box-append box level-bar-widget))

from cl-gtk4.

jonathanabennett avatar jonathanabennett commented on July 19, 2024

Aha, so maybe I'm doing this wrong but what if the data in the code is an integer? I'm trying to draw the HP a unit has remaining and I had thought that a discrete-mode level-bar from 0 to unit/max-hp, with the value set to unit/current-hp would be the best way to do that. But you can't lose half a hitpoint, so I'm keeping it internally as an int.

Is there another widget that would be better for this? I had originally considered making a drawing-area and drawing filled and emptied circles to mark of hits, but then I found the level bar.

from cl-gtk4.

jonathanabennett avatar jonathanabennett commented on July 19, 2024

I went ahead and just used either 0d0 or (float (num/accessor obj) 0d0) and it is working. So I'll just run with that for now since looking through the widget gallery didn't give me any more inspiration.

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

Many functions in GTK accept double-precision floating-point numbers as parameters. You can also use (coerce 123 'double-float) to achieve the same effect. You don't have to worry about the range of values because double-precision floating-point numbers can represent a much larger range than the commonly used int in C or Java.

from cl-gtk4.

Related Issues (20)

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.