![]() |
Very Simple Round Gauge Discussion Thread - Printable Version +- PowerBASIC Users Meeting Point (http://pump.richheimer.de) +-- Forum: User to User Discussions (http://pump.richheimer.de/forumdisplay.php?fid=3) +--- Forum: Programming (http://pump.richheimer.de/forumdisplay.php?fid=7) +--- Thread: Very Simple Round Gauge Discussion Thread (/showthread.php?tid=85) |
Very Simple Round Gauge Discussion Thread - Jules Marchildon - 24.09.2025 Posted in source code forum. Nice one Kevin, yours looks better. I didn't know I had a friendly stalker! ![]() Patrice, I gave it a try, while I've run out of socks from trying all your other demo's out, I did feel the whoosh and then goosebumps! Impressive! Seems much much faster! Did you use the native LZNT1 in the last release? Since I know diddly about obj files I downloaded a free one of the curiosity Rover... https://free3d.com/3d-model/curiosity-rover-46907.html ...but it's missing the MTL file, so I made one up, unfortunately the conversion still failed. Code: # dummy MTL for Curiosity Rover P RE: Very Simple Round Gauge Discussion Thread - Kevin Diggins - 25.09.2025 (24.09.2025, 11:33 PM)Jules Marchildon Wrote: Nice one Kevin, yours looks better. I didn't know I had a friendly stalker! Certainly not a stalker, friendly or otherwise- just a decades long fan of your code. Keep 'em coming! RE: Very Simple Round Gauge Discussion Thread - Patrice Terrier - 25.09.2025 1. On the speed / compression: Yes, starting with the last release, OR can take advantage of native LZNT1 compression on Windows. That’s why the load/unload feels noticeably snappier. It avoids the overhead of external zlib and integrates directly with the system’s fast block compression API. 2. On the Curiosity Rover model: Many free .obj downloads come without a proper .mtl file, or with broken texture paths. OR expects at least one .mtl entry (even if it’s minimal).
That should let OR import it cleanly (you’ll just get a plain-colored rover, but you can layer in textures later). But that only, won't fix the bad conversion. Do you want me to prep a ready-to-use dummy .mtl material, altogether with fixed .obj file, so you can see it in OR? Added: BTW, the model is full of small normal errors. RE: Very Simple Round Gauge Discussion Thread - Jules Marchildon - 30.09.2025 Patrice, in reference to your PlgBlt() suggestion, I can't seem to get my needle to draw correctly, does anything pop out at you in this snippet? Code: '=== draw needle using PlgBlt === RE: Very Simple Round Gauge Discussion Thread - Patrice Terrier - 30.09.2025 Jules I have a new ASUS laptop, but not had time yet to install PowerBASIC on it (Only VS2022). Thus about your problem Short answer: the three destination points you pass to PlgBlt don’t correspond to the expected corners of the source rectangle. PlgBlt maps the source RECT (0,0,w,h) to a parallelogram whose corners must be given in this order: pts(0) → upper-left of the dest parallelogram (maps source (0,0)) pts(1) → upper-right (maps source (w,0)) pts(2) → lower-left (maps source (0,h)) Your code sets pts(0) at the needle tip and the other two as small offsets around the center, so the source bitmap (which has base on top and tip at the bottom) is being warped incorrectly. You also use the full needleWidth instead of half-width for the side offsets. Fix Keep the source bitmap exactly as you drew it (base at the top, tip at the bottom). Compute a unit vector along the needle (u) and a perpendicular unit vector (v), then place the three corners as a rotated rectangle whose top edge is the base and whose bottom edge reaches the tip. PowerBASIC-style math (same symbols you used): ' angle already in radians, pointing from center to tip ux = COS(angle) : uy = -SIN(angle) ' forward (toward tip) vx = COS(angle + cherryPi/2) : vy = -SIN(angle + cherryPi/2) ' left normal halfW = needleWidth / 2 h = needleHeight ' Base is at the gauge center (cx,cy) baseX = cx : baseY = cy ' === Parallelogram corners for PlgBlt === ' UL (maps source 0,0) → base - halfW * v pts(0).x = baseX - halfW * vx pts(0).y = baseY - halfW * vy ' UR (maps source w,0) → base + halfW * v pts(1).x = baseX + halfW * vx pts(1).y = baseY + halfW * vy ' LL (maps source 0,h) → base + h * u - halfW * v pts(2).x = baseX + h * ux - halfW * vx pts(2).y = baseY + h * uy - halfW * vy PlgBlt hDC, pts(0), hMemDC, 0, 0, needleWidth, needleHeight, hMaskBitmap, 0, 0 Mask note You create a 1-bit mask and paint the same triangle white on black. That’s fine for PlgBlt (white bits in the mask select the pixels to transfer). If you see inverted transparency, just invert the mask (fill white, draw the triangle black). Other small nits Use half width for the side offsets (fixed above). SetStretchBltMode(hDC, %HALFTONE) is harmless here but not required unless you actually stretch the source. Ensure you re-select the old bitmap/brush/pen into the DCs before deleting (you already do that—good). With the corrected corner mapping the needle will rotate cleanly around (cx,cy) while still using your triangular source + mask. RE: Very Simple Round Gauge Discussion Thread - Jules Marchildon - 03.10.2025 Patrice, I'm not getting any better results, perhaps in this case. It's OK, I do have a custom GDI+ round gauge to finish working on later. For now, this simple gauge is good enough for the testing PCB application at work. Code: '=== draw needle using PlgBlt with corrected points === |