Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:42:53+00:00 2026-06-04T11:42:53+00:00

I’m experimenting with creating a small library/DSL for image synthesis in Clojure. Basically the

  • 0

I’m experimenting with creating a small library/DSL for image synthesis in Clojure. Basically the idea is to allow users of the library to compose sets of mathematical functions to procedurally create interesting images.

The functions need to operate on double values, and take the form of converting a location vector into a colour value, e.g. (x,y,z) – > (r,g,b,a)

However I’m facing a few interesting design decisions:

  • Inputs could have 1,2,3 or maybe even 4 dimensions (x,y,z plus time)
  • It would be good to provide vector maths operations (dot products, addition, multiplication etc.)
  • It would be valuable to compose functions with operations such as rotate, scale etc.
  • For performance reasons, it is important to use primitive double maths throughout (i.e. avoid creating boxed doubles in particular). So a function which needs to return red, green and blue components perhaps needs to become three separate functions which return the primitive red, green and blue values respectively.

Any ideas on how this kind of DSL can reasonably be achieved in Clojure (1.4 beta)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:42:54+00:00Added an answer on June 4, 2026 at 11:42 am

    OK, so I eventually figured out a nice way of doing this.

    The trick was to represent functions as a vector of code (in the “code is data” sense, e.g.

    [(Math/sin (* 10 x)) 
     (Math/cos (* 12 y)) 
     (Math/cos (+ (* 5 x) (* 8 y)))]
    

    This can then be “compiled” to create 3 objects that implement a Java interface with the following method:

    public double calc(double x, double y, double z, double t) {
        .....
    }
    

    And these function objects can be called with primitive values to get the Red, Green and Blue colour values for each pixel. Results are something like:

    enter image description here

    Finally, it’s possible to compose the functions using a simple DSL, e.g. to scale up a texture you can do:

    (vscale 10 some-function-vector)
    

    I’ve published all the code on GitHub for anyone interested:

    https://github.com/mikera/clisk

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.