General Programming Discussion

8665 readers
1 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 6 years ago
MODERATORS
51
 
 

cross-posted from: https://lemmy.ml/post/25043892

I wrote a program that turns the feed it receives from your webcam in ASCII art. It's open source: you can find the code on Github.

52
53
54
22
submitted 5 months ago* (last edited 5 months ago) by JRepin@lemmy.ml to c/programming@lemmy.ml
 
 

Forgejo is a self-hosted lightweight software forge. In version 10.0: TOTP secrets were made more secure. The UI was made more accessible and reworked to improve the UX. Searching users, repositories, releases and issues was improved. Low German (Plattdüütsch) translation was completed. This is the last version to allow a transparent upgrade from Gitea v1.22 or lower.

55
56
57
58
59
60
61
62
63
64
 
 

the code

(ns index)

(defn prep-canvas []
  (let [can (js/document.createElement "canvas")
        ctx (.getContext can "2d")
        width js/window.innerWidth
        height js/window.innerHeight]
    (set! can.style "position: absolute; top: 0px; left: 0px;")
    (set! can.width width)
    (set! can.height height)
    (js/document.body.appendChild can)
    {:canvas can
     :context ctx
     :width width
     :height height}))

(defn rand [n]
  (js/Math.floor (* (js/Math.random) n)))

(defn render-snowflake [{:keys [context]} {:keys [x y size]}]
  (set! context.fillStyle "#fff")
  (set! context.font (str size "px serif"))
  (.fillText context "*" x y))

(defn snowflake-step [{:keys [height]} {:keys [x y dy] :as snowflake}]
  (set! snowflake.y (if (> y height) (- 20) (+ y dy)))
  (set! snowflake.x (+ x (- (js/Math.random) 0.5))))

(defn gen-snowflakes [n {:keys [width height]}]
  (->>
   (range n)
   (map
    (fn [_]
      (let [size (+ (rand 10) 2)
            x (rand width)
            y (rand height)]
        {:size size
         :x x
         :y y
         :dy (inc (js/Math.random 10))})))
   (doall)))

(defn animation-loop [step-fn]   
   (step-fn)
   (js/window.requestAnimationFrame (partial animation-loop step-fn)))

(defn draw-text [{:keys [context width height]} text]
  (set! context.fillStyle "#fff")
  (set! context.font "100px serif")
  (context.fillText text (* width 0.3) (* height 2/6) (* width 7/8)))

(defn draw-terrain [{:keys [context width height]} fill growing?]
  (set! context.fillStyle fill)
  (context.beginPath)
  (context.moveTo -500 (if growing? height height))
  (loop [x 0
         y (if growing?
             (- height 100)
             (- height 400))]
    (if (< x width)
      (let [x (+ x (+ 10 (rand 20)))
            y (if growing?
                (- y (rand 10))
                (+ y (rand 10)))]
        (context.lineTo x y)
        (recur x y))
      (context.lineTo (+ x 100) height)))
  (context.fill))

(let [background (prep-canvas)
      text-layer (prep-canvas)
      {:keys [context width height] :as snow} (prep-canvas)
      terrain (prep-canvas)
      snowflakes (gen-snowflakes 800 snow)]
  (background.context.fillRect 0 0 width height)
  (draw-text text-layer "Happy Holidays!")
  (draw-terrain terrain "#fff" true)
  (draw-terrain terrain "#ddd" false)
  (animation-loop
   (fn []
     (set! context.fillStyle "#000")
     (context.clearRect 0 0 width height)
     (doseq [sf snowflakes]
       (render-snowflake snow sf)
       (snowflake-step snow sf)))))
65
66
67
68
 
 

cross-posted from: https://lemmy.ml/post/23785552

After nearly 2 years of work, I'm excited to release the first version of bjForth, featuring partial JONESFORTH compatibility and initial Java interop.

Grab it and start hacking: https://github.com/bahmanm/bjforth/releases/tag/v0.0.2

PS: bjForth is a Forth (indirect threaded) written entirely in Java and its execution model is influenced by that of JONESFORTH.

69
 
 

Hey all.

First off, bjForth is a Forth written from the ground up with modern Java and its execution model is largely influenced by that of JONESFORTH.

Currently I'm working on Java inter-op and would like to ask for your opinions/experience on semantics and syntax.

The relevant GitHub issue.

Thanks in advance.

70
71
72
73
 
 

cross-posted from: https://lemmy.ml/post/23144215

The Khronos Group, an open consortium of industry-leading companies dedicated to creating advanced interoperability standards, has announced the release of Vulkan 1.4, the latest version of its cross-platform 3D graphics and compute API. Vulkan 1.4 integrates and mandates support for many proven features into its core specification, expanding the functionality that is consistently available to developers, greatly simplifying application development and deployment across multiple platforms.

The Vulkan 1.4 specification consolidates numerous previously optional extensions, features, and increased minimum hardware limits, many of which were defined in the Vulkan Roadmap 2022 and 2024 milestones and associated profiles, including:

  • Streaming Transfers: Vulkan 1.4 imposes new implementation requirements to ensure portable, cross-platform applications can stream large quantities of data to a device while simultaneously rendering at full performance.
  • Previously optional extensions and features critical to emerging high-performance applications are now mandatory in Vulkan 1.4, ensuring their reliable availability across multiple platforms. These include push descriptors, dynamic rendering local reads, and scalar block layouts.
  • Maintenance extensions up to and including VK_KHR_maintenance6 are now part of the core Vulkan 1.4 specification.
  • 8K rendering with up to eight separate render targets is now guaranteed to be supported, along with several other limit increases.
74
75
view more: ‹ prev next ›