@wasamasa@lonely.town avatar

wasamasa

@wasamasa@lonely.town

Wildcard Consultant | Evil Emacser | Lisp Hacker | Infosec & Cryptography | #nobot

This profile is from a federated server and may be incomplete. Browse more on the original instance.

wasamasa, to random
@wasamasa@lonely.town avatar

> In the Ruby space, there is also Crystal, a Ruby-like language that is statically compiled with type inference. This language is intentionally not Ruby-compatible, it has chosen to diverge from Ruby, but has still seen limited success. I think this is interesting because it gives us a broader perspective. Rubyists don’t like Crystal because it’s almost-Ruby-but-not-quite. It looks like Ruby, syntactically, but has many subtle differences and is very much incompatible in practice. This just confuses people, it breaks their expectations. Crystal probably would have had better luck if it had never marketed itself as being similar to Ruby in the first place.

@ayo Why is it that I find myself thinking of you, I do wonder...

https://pointersgonewild.com/2024/04/20/the-alternative-implementation-problem/

Sandra, to random

Why my Dovecot! I loveded you! I loveded youuu!

Is there a fork on the horizon?

https://news.ycombinator.com/item?id=38333086

wasamasa,
@wasamasa@lonely.town avatar

@Sandra Unclear what's going on here. Thought at first this is about an unrelated Dovecot Pro fork by OX, but then I noticed it's prominently linked on the Dovecot website... I guess the open core business model strikes again?

Sandra, to emacs

Huh? Is there an @emacs setting to get format=flowed?

https://useplaintext.email/

wasamasa,
@wasamasa@lonely.town avatar

@Sandra @emacs According to the Gnus changelog, use-hard-newlines takes care of that. The code checking for that variable is used by message.el which is used in the composition buffers for seemingly all Emacs mail clients, so it should not need client-specific configuration. In theory at least.

loke, to random
@loke@functional.cafe avatar

I want to write a little graphics thing on the JVM. Last time I wrote some actual 3D graphics things was using OpenGL 1.2 back in... 2001?

All I really want to do is to draw some lighted polygons and rotate them. What's the easiest way to do that that will run on the JVM today?

Doing it in Vulkan looks like a nightmare. I'm not going there.

wasamasa,
@wasamasa@lonely.town avatar

@loke I remember seeing a demo scene submission using LWJGL for a PC entry, so that would be an option for doing OpenGL stuff. Here's another one using Kotlin: https://github.com/edwinRNDR/demo-strap

loke, to infosec
@loke@functional.cafe avatar

Having attended several talks at Black Hat, I have come to the conclusion that Microsoft could fix 90% of all security exploits by removing calculator.exe.

wasamasa,
@wasamasa@lonely.town avatar

@loke Conversely, an ubiquitious calc.exe equivalent on Linux would make verifying code execution vulns a lot less of a hassle. Other people seem to use the Gnome calculator instead, but that relies on a Gnome desktop. Currently I use espeak hello instead and crank up the volume.

wasamasa, to random
@wasamasa@lonely.town avatar

Using xcb.el I managed to recreate a X11 drawing demo with . This may or may not pave the way forward to faster graphics rendering programs in ...

https://www.x.org/releases/current/doc/libxcb/tutorial/index.html#drawingprim

wasamasa,
@wasamasa@lonely.town avatar

Basic animation works at 60fps, though it flickers a good deal. I wonder whether using pixmaps would help with optimization, especially once bitmap data is involved

Bouncing black rectangle, with some occasional stutter/flicker going on

wasamasa,
@wasamasa@lonely.town avatar

I managed to upload bitmaps and completed the DVD bounce demo.

DVD logo bouncing around

wasamasa,
@wasamasa@lonely.town avatar

Spent some more time porting the remaining X11 demos to understand how one handles fonts, key events, setting a window title and use colors. Then another day porting my Game of Life code to run at a competitive performance.

My findings so far:

  • Yes, using XCB directly is annoyingly low-level. There isn't nearly enough documentation, compared to using Xlib.
  • xcb.el is pretty cool all things considered. I just wish it wouldn't encourage generating tons of EIEIO objects. I don't really have an idea how to do better though. Maybe make it easier to reuse objects? The event handlers are halfway there by giving you the raw data rather than immediately turning it into EIEIO objects...
  • Recording the demo gave me a lot of weird inter-frames making it look as if execution jumped a frame back and forth occasionally. I had to kill my compositor for everything to look normal again...
  • There are a bunch of extensions I want to try out to improve performance. DBE is sadly unavailable (so I stick to painting everything to a backbuffer pixmap), XRender could be interesting for modern graphics (but again, there is not nearly enough documentation on it, besides reading Cairo code...)
  • Overall, using Emacs as UI toolkit is more convenient in comparison and cross-platform. In terms of speed, there is no clear winner.

B/W window showing Game of Life cellular automaton creating and destroying patterns. There is a text at the bottom explaining the available keyboard controls.

wasamasa,
@wasamasa@lonely.town avatar

Compositing with the render extension isn't as bad as expected. There's still some obvious optimizations to be made (precalculate one pixmap per ball before entering the loop, then use the composite operation to put it on the desired part of the screen), but now I have custom bitmap fonts and acceptable performance. Maybe some faux 3D shading next?

A black window with three colored circles bouncing around. The bottom text says "Look at my orbs!".

wasamasa,
@wasamasa@lonely.town avatar
wasamasa,
@wasamasa@lonely.town avatar

That was easy enough to resolve by fine-tuning the starting positions and speeds. I guess the leftover color fragments were uninitialized memory obtained from outside the canvas.

Even more bouncing balls, but without glitches this time.

wasamasa,
@wasamasa@lonely.town avatar

One tip for profiling non-interactively when using --batch:

(require 'profiler)
(profiler-start 'cpu)
;; ...
(profiler-stop)
(let ((filename (format "%d.profile" (truncate (float-time)))))
(profiler-write-profile (profiler-cpu-profile) filename))

You can then use M-x profiler-find-profile on the file.

I've moved some of the request objects outside the drawing loop and resorted to reusing one object per type of request, then mutating the fields as necessary before sending the request. Now the performance hotspots left seem to be inside the data marshalling code. I can't do much about it unless I were to rewrite it to avoid creating/walking objects in the first place.

wasamasa,
@wasamasa@lonely.town avatar

So, to demonstrate the intersection between Porter/Duff operators and alpha, I decided to recreate a transparency effect. Many attempts later, I've figured out the following:

  • Premultiplied alpha is a weird concept. I need to multiply my colors with a hexadecimal fraction and need the compositor to be aware of this, otherwise the colors turn out darker (premultiplied alpha, but ignored by the compositor) or not transparent at all (unpremultiplied alpha, but compositor expects a darker tone). Given the bias towards darker shades, I'd expect them to be less represented and the concept to be "lossy" (supposedly, Photoshop does discard color information when saving a transparent PNG, despite the file format mandating unpremultiplied alpha)
  • On the other hand, it means that combining two pictures can be as easy as adding the color values, therefore I did initially have to use the Add Porter/Duff operator
  • The Clear operator is useful to remove already painted color or restore transparency

Overlaying semi-transparent white rectangles on red background
Overlaying semi-transparent white rectangles with opaque border on red background
Overlaying semi-transparent white rectangles with border on red background

wasamasa,
@wasamasa@lonely.town avatar

One open point was handling gradients. I made a small demo at first not relying on masks to learn how they work. Unlike the previous demo, they require unpremultiplied alpha, presumably due to other colors that need to be interpolated into the gradient.

To handle masks correctly, some prerequisites need to be fulfilled:

  • The ComponentAlpha property of the backing picture needs to be set for some reason
  • The mask will turn out choppy due to the underlying picture defaulting to sharp polygon edges, therefore smooth polygon edges need to be enabled first
  • The background of the mask needs its pixels cleared (with the Clear operator, using black did make for glitches), whereas the bits allowed to pass through are painted solid white

Some more tricks I consider figuring out/explaining:

  • The mystery behind ComponentAlpha (perhaps using a different picture format like A8 allows avoiding it?)
  • Alpha maps used as transparency control (with a solid grey value)
  • Clipping, transforms and filters
  • Cursors

Some more ideas to write small programs for:

  • Game of Life, but using render with pixel transforms
  • Bouncing DVD logo, but with an image loader and transparency demo
  • Classic game screen transition effects
  • Filter/transform demo

Bouncing orbs, but with a radial gradient applied to them that makes them look a bit less flat.

wasamasa,
@wasamasa@lonely.town avatar

I've started work on a simple game and will hopefully hand in something for this time.

While hacking on a prototype with properly prefixed identifiers, I noticed that spawning just the window took 2.4s every time. I started debugging what took so long and eventually found accidentally quadratic code in the unmarshalling bits. PR is at https://github.com/ch11ng/xelb/pull/30 and may be of interest to users.

Now I'm debugging a font issue. Previously, I used a script turning the ASCII glyphs of the GNU Unifont .hex files into a char table and expanded each glyph into 8 times as many bytes to use the A8 format (alpha channel only, 8 bits). However, I realized that the font does not need 8 bits anyway (no anti-aliasing, only solid black/white pixels) and the A1 format would avoid the need for expansion. In theory at least, for some reason not a single glyph is drawn...

wasamasa,
@wasamasa@lonely.town avatar

Due to an upcoming conference, I decided to pause work on the game for now and instead build a presentation about the stuff I've learned so far. Here's the opening slide.

wasamasa, to random
@wasamasa@lonely.town avatar

Been a while since I did recreational hacking. Should I bother putting this up on MELPA?

An Emacs screen saver displaying the current time flipping from 23:56 to 23:57

wasamasa,
@wasamasa@lonely.town avatar

Follow-up question: What kind of zone (AKA screensaver) programs would you like to see in ? The existing options:

  • Built-in stuff (most of which scramble the existing buffer text or otherwise mess with it)
  • Two Matrix™ ones
  • Rainbow colors
  • A steam locomotive (clone of the sl command)
  • A nyancat animation written by yours truly

Most screensaver ideas seem to be about graphics rather than text, but graphics are of course still possible. One thing I've considered is game cut scenes, much like the "attract mode" of arcade machines (or maybe just add a whole game and relax the screen saver rules a bit).

wasamasa,
@wasamasa@lonely.town avatar

@loke No, that was @temporal. I made zone-nyan.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • thenastyranch
  • osvaldo12
  • Durango
  • ngwrru68w68
  • khanakhh
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • Youngstown
  • everett
  • InstantRegret
  • slotface
  • rosin
  • megavids
  • kavyap
  • GTA5RPClips
  • cisconetworking
  • cubers
  • modclub
  • tacticalgear
  • ethstaker
  • tester
  • normalnudes
  • provamag3
  • anitta
  • Leos
  • lostlight
  • All magazines