GithubHelp home page GithubHelp logo

openrndr / openrndr Goto Github PK

View Code? Open in Web Editor NEW
818.0 24.0 71.0 11.07 MB

OPENRNDR. A Kotlin/JVM library for creative coding, real-time and interactive graphics

Home Page: http://openrndr.org

License: Other

Kotlin 99.81% GLSL 0.13% CSS 0.01% HTML 0.05%
creative-coding jvm kotlin shaders graphics webgl

openrndr's Introduction

OPENRNDR

Download Build status

A Kotlin/JVM and Kotlin/JS library for creative coding, real-time and interactive graphics. Can currently be used on Windows, macOS and Linux/x64 to create standalone graphical applications.

Basics and use are further explained in the OPENRNDR guide.

Repository structure

module description
openrndr-animatable Tooling for interactive animations
openrndr-application Application and Program classes
openrndr-binpack Binpacking algorithm used for texture atlasses
openrndr-color Color spaces
openrndr-dds DirectDraw Surface file (.dds) loader
openrndr-demos A collection of small in-repository demos
openrndr-draw Drawing primitives
openrndr-event Event classes
openrndr-extensions Built-in OPENRNDR extensions
openrndr-filter Built-in filters
openrndr-js Kotlin/JS specific modules
openrndr-jvm Kotlin/JVM specific modules
openrndr-math Math functions and classes
openrndr-nullgl Mock graphics back-end
openrndr-shape Classes and functions for working with 2D shapes
openrndr-svg Loading and saving SVG
openrndr-utils Assorted utilities

Using OPENRNDR

You are advised to use the OPENRNDR template which provides a quick start to using the library.

OPENRNDR's Javascript/WebGL is still experimental and under development. However, if you feel like trying it you should use the OPENRNDR JS template.

Building OPENRNDR

After cloning the repository, make sure you have Java 11 or newer installed and run the following command:

./gradlew build

This should start the build process, which will take some time to complete.

Note that OPENRNDR does not depend on anything that is not on Maven Central, builds should be easy and predictable.

Installing OPENRNDR as Maven artifacts

In order to use the OPENRNDR build from your applications one has to install OPENRNDR's Maven artifacts in the local Maven repository.

./gradlew publishToMavenLocal snapshot

A more detailed walk-through of building, publishing to Maven local and contributing can be found in the wiki.

Community

Visit the OPENRNDR website for the latest news on OPENRNDR, showcases and events

Join us on the OPENRNDR forum for questions, tutorials and showcases.

Reach us more directly on the OPENRNDR Slack.

openrndr's People

Contributors

alessiofaieta avatar axel-tanner avatar boydrotgans avatar codecox avatar daniel5gh avatar edwinrndr avatar ericyd avatar goudreinette avatar hamoid avatar ilyasshafigin avatar jbellis avatar jeroenbarendse avatar krksgbr avatar m165437 avatar morisil avatar ricardomatias avatar sidec avatar somecho avatar strangesource avatar syngeo avatar tortila avatar vechro avatar yvee1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openrndr's Issues

Add tiling support

tiles™

Aims to provide an abstraction between the window and color buffers/render targets, giving them a position alongside the dimensions. This would in return translate into a bounding box model, allowing mouse enter/exit events to be properly determined.

Implement back-end for testing

Implement a back-end that can be used to test code that is part of the last stage of the drawing pipeline, specifically the code that prepares geometry and hands it over to the Driver.

  • Is used as soon as openrndr-nullgl is on the classpath
  • provides dummy implementation for Application
  • provides dummy implementation for Driver
  • provides dummy implementation for ColorBuffer
  • provides dummy implementation for DepthBuffer
  • provides dummy implementation for VertexBuffer
  • provides dummy implementation for ArrayTexture
  • provides dummy implementation for Shader
  • provides dummy implementation for ComputeShader
  • provides dummy implementation for ShadeStyleManager
  • provides dummy implementation for RenderTarget
  • provides dummy implementation for FontMapManager
  • provides dummy implementation for ShaderGenerators
  • provides dummy implementation for IndexBuffer
  • provides dummy implementation for DrawThread
  • provides dummy implementation for ResourceThread
  • provides dummy implementation for Cubemap

Loading multiple fonts causes crash

When loading around 10 fonts I get crashes in native code in (often but not always in stbtt_GetGlyphHMetrics). Probably a memory initialization/leak issue?

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000148201309, pid=8551, tid=775
Current thread (0x00007febdb001000):  JavaThread "main" [_thread_in_native, id=775, stack(0x00007ffee927e000,0x00007ffee9a7e000)]

Stack: [0x00007ffee927e000,0x00007ffee9a7e000],  sp=0x00007ffee9a76f70,  free space=8163k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [liblwjgl_stb.dylib+0x3b309]
[error occurred during error reporting (printing native stack), id 0xe0000000, Internal Error (/scratch/mesos/slaves/fcf4c0c4-d73e-4321-860c-6613427db92b-S1400/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/daacdadf-a1b9-40bc-9978-e61e217c02bb/runs/8ae9fce2-2d0e-4b1f-b6c6-d913bc747292/workspace/open/src/hotspot/os/bsd/decoder_machO.hpp:43)]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 1147  org.lwjgl.stb.STBTruetype.nstbtt_GetGlyphBitmapBoxSubpixel(JIFFFFJJJJ)V (0 bytes) @ 0x0000000118c51283 [0x0000000118c51220+0x0000000000000063]
J 1143 c1 org.lwjgl.stb.STBTruetype.stbtt_GetGlyphBitmapBoxSubpixel(Lorg/lwjgl/stb/STBTTFontinfo;IFFFFLjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V (65 bytes) @ 0x00000001118d6d8c [0x00000001118d6a80+0x000000000000030c]
J 1181 c1 org.openrndr.internal.gl3.FontImageMapManagerGL3.fontMapFromUrl(Ljava/lang/String;DD)Lorg/openrndr/draw/FontImageMap; (2005 bytes) @ 0x00000001119011b4 [0x00000001118f7480+0x0000000000009d34]
j  org.openrndr.draw.FontImageMap$Companion.fromFile(Ljava/lang/String;DD)Lorg/openrndr/draw/FontImageMap;+97
j  org.openrndr.draw.FontMapKt.loadFont(Lorg/openrndr/Program;Ljava/lang/String;DD)Lorg/openrndr/draw/FontImageMap;+46
j  org.openrndr.draw.FontMapKt.loadFont$default(Lorg/openrndr/Program;Ljava/lang/String;DDILjava/lang/Object;)Lorg/openrndr/draw/FontImageMap;+24
j  TemplateProgramKt$main$1$2.invoke(Lorg/openrndr/Program;)V+55
j  TemplateProgramKt$main$1$2.invoke(Ljava/lang/Object;)Ljava/lang/Object;+5
j  org.openrndr.ApplicationBuilder$program$1.setup()V+5
j  org.openrndr.internal.gl3.ApplicationGLFWGL3.loop()V+389
j  org.openrndr.Application$Companion.run(Lorg/openrndr/Program;Lorg/openrndr/Configuration;)V+68
j  org.openrndr.ApplicationKt.application(Lorg/openrndr/Program;Lorg/openrndr/Configuration;)V+17
j  org.openrndr.ApplicationBuilderKt.application(Lkotlin/jvm/functions/Function1;)V+51
j  TemplateProgramKt.main()V+6
j  TemplateProgramKt.main([Ljava/lang/String;)V+0
v  ~StubRoutines::call_stub

Can reproduce on Windows and MacOS, works OK on Linux/x64

Rename background() to a verb

Is your feature request related to a problem? Please describe.

stroke = ColorRGBa.GREEN
fill = ColorRGBa.RED
background(ColorRGBa.BLUE)

stroke and fill use an equal sign to assign a color, but background is a function instead even if it takes the same type of variable.

Describe the solution you'd like

As what background() does is to clear the background, it could be renamed something like clear() or clearBackground(), so stroke and fill are nouns but this method is a verb.

Additional context

https://openrndr.slack.com/archives/CBJGUKVSQ/p1586173652005600

Inconsistent HiDPI support across operating systems

Describe the bug
The way OPENRNDR deals with screen scaling is different between macOS and Linux.

On macOS, setting width and height in configure { } works as expected--app window will have the specified size in "points". On a Retina display, the actual # of pixels will be more than the # of points according to the scale factor in the OS configuration.

On Linux (tested on Kubuntu), however, setting width and height in configure { } will set the actual pixel size of the app window, regardless of the screen scaling setup of the OS. The values of width and height in program { } become the values you set in configure { } divided by window.scale. window.size also gets these scaled values.

But the app content isn't scaled while the app window is scaled. The content still follows the "point" metric according to the scale factor in the OS configuration. This results in normal-sized content in a small window with the content being cropped (see Screenshots).

To Reproduce
Put the following code in openrndr-template and run:

fun main() = application {
    configure {
        width = 768
        height = 576
    }

    program {
        println("width: $width")
        println("height: $height")
        println("window.size: ${window.size}")
        println("window.scale: ${window.scale}")
    }
}

Expected behavior
On Linux, expect the following output in the console:

width: 453
height: 340
window.size: Vector2(x=453.0, y=340.0)
window.scale: Vector2(x=1.6979166269302368, y=1.6979166269302368)

The values differ according to screen scaling setup in the OS, but you can see that width and height has changed from configure { } to program { } (divided by window.scale).

Screenshots
Running C03_Color003.kt in openrndr-examples results in cropped content, which demonstrates the description in Describe the bug.

image

Context:

  • OS and version: Kubuntu 19.10 (KDE Plasma 5.16.5, KDE framework 5.62.0, Qt 5.12.4, Linux kernel 5.3.0-26-generic)
  • OpenRNDR version: 0.3.37
  • Java Version: Oracle Java 13.0.2 2020-01-14

Add beforeScreenshot hook/listener

Describe the solution you'd like

I want to be able to run code right before a screenshot is taken.

Additional context

This allows code that is only executed once (outside of an extend loop) to adapt before a screenshot is taken.

Poor drawing performance compared to Processing

Describe the bug

Processing significantly outperforms OPENRNDR at drawing rectangles to the screen. On my machine, Processing can draw 1000 rectangles to the screen at around 58 FPS, whereas a similar program using OPENRNDR runs at about 22 FPS.

To Reproduce

Run the following code in Processing:

void setup() {
  size(1000, 1000);
}

void draw() {
  background(0);
  fill(255);
  noStroke();
  
  for (int i = 0; i < 1000; i++) {
    rect(random(width), random(height), 10, 10);  
  }
  
  println(frameCount / (millis() / 1000.0));
}

Then run the following code in an OPENRNDR project:

import org.openrndr.*
import org.openrndr.color.ColorRGBa

class TemplateProgram: Program() {
    var numFrames = 0

    override fun draw() {
        drawer.background(ColorRGBa.BLACK)
        drawer.fill = ColorRGBa.WHITE
        drawer.stroke = null
        for (i in 0 until 1000) {
            drawer.rectangle(Math.random() * width, Math.random() * height, 10.0, 10.0)
        }

        println(numFrames / seconds)

        numFrames++
    }
}

fun main(args: Array<String>) {
    application(TemplateProgram(),
            configuration {
                width = 1000
                height = 1000
            })
}

These two programs both print out the average FPS of the program as it is running.

Expected behavior

I would expect the drawing performance of the two frameworks to be comparable.

Context:

  • OS and version: 10.11.6
  • OpenRNDR version: 0.3.19
  • Java Version: 10.0.1

Running the gradle template does not work

Hi,

I wanted to try out OPENRNDR so I followed the guide at http://guide.openrndr.org/#/Tutorial_Start. I managed to checkout the project and build it, but I am unable to run it.

I get the following error:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[LWJGL] Failed to load a library. Possible solutions:
	a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
	b) Add the JAR that contains the shared library to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openrndr.Application$Companion.run(Application.kt:12)
	at org.openrndr.ApplicationKt.application(Application.kt:41)
	at TemplateProgramKt.main(TemplateProgram.kt:23)
Caused by: java.lang.UnsatisfiedLinkError: Failed to locate library: liblwjgl.so
	at org.lwjgl.system.Library.loadSystem(Library.java:147)
	at org.lwjgl.system.Library.loadSystem(Library.java:67)
	at org.lwjgl.system.Library.<clinit>(Library.java:50)
	at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:61)
	at org.lwjgl.system.MemoryStack.<init>(MemoryStack.java:61)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:82)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:71)
	at java.lang.ThreadLocal$SuppliedThreadLocal.initialValue(ThreadLocal.java:284)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
	at java.lang.ThreadLocal.get(ThreadLocal.java:170)
	at org.lwjgl.system.MemoryStack.stackGet(MemoryStack.java:628)
	at org.lwjgl.system.MemoryStack.stackPush(MemoryStack.java:637)
	at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
	at org.openrndr.internal.gl3.ApplicationGL3.createPrimaryWindow(ApplicationGL3.kt:251)
	at org.openrndr.internal.gl3.ApplicationGL3.<init>(ApplicationGL3.kt:96)
	... 7 more

Process finished with exit code 1

Can't run openrndr-gradle-template program

Describe the bug
I followed the tutorial here, but I get an error (pasted below).

To Reproduce
Follow the steps as outlined in the OPENRNDR getting started guide and run the template program.

Expected behavior
I would expect the template program to run.

Screenshots
screen shot 2018-07-10 at 12 20 19 pm

Context:

  • OS and version: macOS 10.11.6
  • OpenRNDR version: 0.3.18
  • Java Version: 1.8.0_05

Additional context

Logs:

objc[14792]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3.3.0 Cocoa NSGL dynamic
opengl vendor: ATI Technologies Inc.
opengl version: 4.1 ATI-1.42.15
java.lang.VerifyError: Uninitialized object exists on backward branch 43
Exception Details:
  Location:
    org/openrndr/shape/ShapeContour.getReversed()Lorg/openrndr/shape/ShapeContour; @89: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: bb00 0259 2ab4 000a c000 0c4c 3a0b 3a0a
    0000010: 2b4d bb00 3459 2b10 0ab8 008b b700 8ec0
    0000020: 003a 4e2c b900 1001 003a 0419 04b9 0016
    0000030: 0100 9900 2a19 04b9 001a 0100 3a05 2d19
    0000040: 05c0 001c 3a06 3a0c 1906 b601 8e3a 0d19
    0000050: 0c19 0db9 0098 0200 57a7 ffd2 2dc0 004f
    0000060: 3a0c 190a 190b 190c c000 0cb8 0192 2ab4
    0000070: 00f6 b700 94b0                         
  Stackmap Table:
    full_frame(@43,{Object[#2],Object[#12],Object[#12],Object[#58],Object[#18],Top,Top,Top,Top,Top,Uninitialized[#0],Uninitialized[#0]},{})
    same_frame(@92)

	at org.openrndr.shape.ShapeBuilderKt.contour(ShapeBuilder.kt:25)
	at TemplateProgram.draw(TemplateProgram.kt:12)
	at org.openrndr.Program.drawImpl(Program.kt:306)
	at org.openrndr.internal.gl3.ApplicationGL3.drawFrame(ApplicationGL3.kt:489)
	at org.openrndr.internal.gl3.ApplicationGL3.loop(ApplicationGL3.kt:436)
	at org.openrndr.Application$Companion.run(Application.kt:13)
	at org.openrndr.ApplicationKt.application(Application.kt:39)
	at TemplateProgramKt.main(TemplateProgram.kt:23)
Exception in thread "main" java.lang.VerifyError: Uninitialized object exists on backward branch 43
Exception Details:
  Location:
    org/openrndr/shape/ShapeContour.getReversed()Lorg/openrndr/shape/ShapeContour; @89: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: bb00 0259 2ab4 000a c000 0c4c 3a0b 3a0a
    0000010: 2b4d bb00 3459 2b10 0ab8 008b b700 8ec0
    0000020: 003a 4e2c b900 1001 003a 0419 04b9 0016
    0000030: 0100 9900 2a19 04b9 001a 0100 3a05 2d19
    0000040: 05c0 001c 3a06 3a0c 1906 b601 8e3a 0d19
    0000050: 0c19 0db9 0098 0200 57a7 ffd2 2dc0 004f
    0000060: 3a0c 190a 190b 190c c000 0cb8 0192 2ab4
    0000070: 00f6 b700 94b0                         
  Stackmap Table:
    full_frame(@43,{Object[#2],Object[#12],Object[#12],Object[#58],Object[#18],Top,Top,Top,Top,Top,Uninitialized[#0],Uninitialized[#0]},{})
    same_frame(@92)

	at org.openrndr.shape.ShapeBuilderKt.contour(ShapeBuilder.kt:25)
	at TemplateProgram.draw(TemplateProgram.kt:12)
	at org.openrndr.Program.drawImpl(Program.kt:306)
	at org.openrndr.internal.gl3.ApplicationGL3.drawFrame(ApplicationGL3.kt:489)
	at org.openrndr.internal.gl3.ApplicationGL3.loop(ApplicationGL3.kt:436)
	at org.openrndr.Application$Companion.run(Application.kt:13)
	at org.openrndr.ApplicationKt.application(Application.kt:39)
	at TemplateProgramKt.main(TemplateProgram.kt:23)

Improve keyboard handling

Keyboard handling is found to be confusing, currently keys are designed by 3 different values in KeyEvent: name, key and `scanCode.

From what I understand scanCode is highly platform specific and shouldn't be exposed by OPENRNDR.

It is unclear that key is a physical identifier that is treating any keyboard like it is a keyboard with a US layout. This is confusing for users with Azerty, Qwertz and Dvorak layouts, among others.

It is unclear that name should be used to provide layout independent interactions.

  • remove scancode from KeyEvent
  • add documentation that explains when to use KeyEvent.key and KeyEvent.name
  • update code that compares keys through key, afaik this is ScreenRecorder only
  • add translators for non-printable keys such that they can be used through KeyEvent.name

Screenshot export result has different color tones

In some examples the differences are more noticeable than others. @edwin is this due to a late color space correction?

The examples below were created with 32 bit color buffers within the compositor.

Examples:

Left: Screenshot - Right: Openrndr Window
Screenshot 2020-03-04 at 11 57 20

Left: Openrndr Window - Right: Screenshot
Screenshot 2020-03-04 at 10 00 11

Left: Openrndr Window - Right: Screenshot
Screenshot 2020-03-04 at 09 55 56

Here is the Screenshots usage:

            extend(Screenshots()) {
                scale = 4.0
                multisample = BufferMultisample.SampleCount(12)
            }

Batch Mode individual draw style

Describe the bug
The batch mode methods like drawer.circles and drawer.rectangles lock in on the style that was set before the method call. The individual classes should have a way to set them before rendering.

To Reproduce

drawer.circles((0 until 100).map{
drawer.fill = ColorRgba(Random.nextDouble(1.0), Random.nextDouble(1.0), Random.nextDouble(1.0)
Circle(Random.nextDouble(width), Random.nextDouble(height), 10.0)
})

Expected behavior
All circles should have a random colour

Context:

  • macOS 10.14.6
  • OpenRNDR 0.3.35
  • 1.8

Add social media dimensions as profiles

This could be dealt either at top-level within configuration/configure. In a nutshell it would provide the right dimensions, f.ex:

configure {
	profile = WindowProfile.Instagram.Landscape // => width 1080, height 608
}

ShapeContour .offset() produces unexpected result

The last segment of the .offset() contour seems to be too short.

            backgroundColor = ColorRGBa.WHITE

            val a = ShapeContour.fromPoints(
                listOf(
                    Vector2(50.0, 50.0),
                    Vector2(150.0, 50.0),
                    Vector2(60.0, 150.0),
                    Vector2(40.0, 60.0)
                ), false // <= true makes it crash
            )
            val b = a.offset(5.0, SegmentJoin.MITER)

            drawer.fill = null
            drawer.stroke = ColorRGBa.BLACK
            drawer.contour(a)
            drawer.stroke = ColorRGBa.RED
            drawer.contour(b)

Screenshot from 2020-02-07 14-25-53

Context:

  • OS and version: Ubuntu 19.04
  • OpenRNDR Template 0.3.9
  • Java Version: openjdk version "11.0.5" 2019-10-15

Additional context
A second issue with .offset() is that it crashes if closed == true.
I can open a second issue for this if desired.

Create Program extension function `namedTimestamp`

ScreenRecorder and Screenshots already generate file names automatically that include a time stamp and the program name. These strings can be useful in other occasions, for example to save an svg, an xml file or for uploading a named result to a server.

One use case would be to save an image with Screenshots, and at the same time save a json or xml file with a matching name including the required configuration to recreate that image in the future.

The proposed idea is to extract the name-generation part already used in those two cases and make it available for other purposes.

It was discussed here

Decommission FFMPEGVideoPlayer

FFMPEGVideoPlayer has been marked as deprecated for a while now and most if not all of its functionality has now been replaced by VideoPlayerFFMPEG. There is also some adopted Java code that can be removed from the OPENRNDR codebase too.

submit issues for any FFMPEGVideoPlayer usecases not covered by VideoPlayerFFMPEG

Creating a ShapeContour .offset() may produce a first segment with NaN value

Describe the bug
Calling .offset() on a ShapeContour produces an invalid curve in some cases

To Reproduce

    program {

        val curve = contour {
            moveTo(Vector2(0.1 * width, 0.3 * height))
            continueTo(Vector2(0.5 * width, 0.5 * height))
            continueTo(Vector2(0.9 * width, 0.3 * height))
            continueTo(Vector2(0.1 * width, 0.3 * height))
            close()
        }

        val curve2 = curve.offset(20.0, SegmentJoin.ROUND)

        println(curve2.segments[0])
        println(curve2.segments[1])
        println(curve2.segments[curve2.segments.size-2])
        println(curve2.segments[curve2.segments.size-1])

        extend {
            drawer.contour(curve)
            drawer.contour(curve2) // <-- crash

            drawer.fill = null
            drawer.rectangle(curve.bounds)
            drawer.rectangle(curve2.bounds)
        }
    }

Expected behavior
Drawing two offset curves.

Output

Segment(start=Vector2(x=NaN, y=NaN), end=Vector2(x=111.05572809000084, y=227.88854381999832), control=[Vector2(x=NaN, y=NaN), Vector2(x=NaN, y=NaN)])
Segment(start=Vector2(x=111.05572809000084, y=227.88854381999832), end=Vector2(x=291.05572809000085, y=317.8885438199983), control=[Vector2(x=168.94427190999915, y=212.11145618000168), Vector2(x=228.94427190999915, y=242.11145618000168)])
Segment(start=Vector2(x=55.87973916815717, y=159.7054959036708), end=Vector2(x=53.47067495099499, y=160.90549399722113), control=[Vector2(x=55.07772582253885, y=160.10448872737393), Vector2(x=54.2747044156394, y=160.50448808867085)])
Segment(start=Vector2(x=53.47067495099499, y=160.90549399722113), end=Vector2(x=51.05572809000071, y=162.11145618000174), control=[Vector2(x=52.66670065119528, y=161.30647490590087), Vector2(x=51.86171836303135, y=161.70846229698998)])

Context:

  • OS and version: ArchLinux
  • OpenRNDR version 0.4.0
  • Java Version 11

Move filters away from core into ORX

Most filters will find a better home in ORX (orx-vfx?). Idea is that filters will enjoy more visibility and receive more community contributions when in a looser and faster moving release cycle.

Rework resource tracking

The way that resource tracking is currently done leads to errors in olive such as:

[main] ERROR org.openrndr.internal.gl3.ApplicationGLFWGL3 - caught exception, breaking animation loop
java.lang.IllegalStateException: colorbuffer is destroyed
	at org.openrndr.internal.gl3.ColorBufferGL3.checkDestroyed(ColorBufferGL3.kt:1076)
	at org.openrndr.internal.gl3.ColorBufferGL3.bind(ColorBufferGL3.kt:1065)
	at org.openrndr.internal.FontImageMapDrawer.flush(FontImageMapDrawer.kt:111)
	at org.openrndr.internal.FontImageMapDrawer.drawText(FontImageMapDrawer.kt:42)
	at org.openrndr.draw.Drawer.text(Drawer.kt:731)

SVG Rendering

Hello.

I'm interested in improving OpenRNDR's SVG support, with a personal end-goal being to be able to render SVG's exported from OpenStreetMap layers. As far as I can see, the current SVGLoader class supports only the 'tiny' base profile and so far not fully. How can I best help in increasing SVG support in line with any current goals or work on this? Failing any specific requirements, I'd like start improving just 'tiny' profile support.

Thanks!

drawer.circles influences drawing of other circles.

Describe the bug
With the use of:
drawer.circles((0 until 20000).map { Circle(Vector2(0.0, 0.0), circleRadius*2.0) })
Other circles are not visible in the view, other circles as in:
drawer.circle(Vector2( 1.0, 2.0 ), 6.0)

Context:

  • OS and version: macOS 10.13.4
  • OpenRNDR version
    project.ext.openrndrVersion = "0.3.20"

Request: implement the HSLuv color space

http://www.hsluv.org/

HSLuv is a human-friendly alternative to HSL. HSLuv extends CIELUV with a new saturation component that allows you to span all the available chroma as a neat percentage.

From Slack, about HSLuv vs ColorLUVa:

ColorLUVa is (CIE)Luv. HSLuv seems to be based on the cylindrical transformation of Luv, LCHuv. From a quick glance it is tries to rectify the LCHuv color space.

HSLuv Java implementation:
https://github.com/hsluv/hsluv-java/blob/master/src/main/java/org/hsluv/HUSLColorConverter.java

Keyboard pressedKeys should be based on an Enum

At the moment it's hard to figure out what is the name of the key that is pressed down. For example, left shift is left-shift which makes sense but only after printing out the contents of the pressedKeys collection.

I suggest moving to something in the direction of keyboard.pressedKeys.contains(Keys.LEFT_SHIFT).

Request: implement rectMode from Processing

As the title states rectMode() would be very useful for the same reasons it is useful in Processing.

I don't have much Kotlin experience or with the OpenRNDR API but I could try and implement it, is there any guide or even a Javadoc style documentation for OpenRNDR?

Thank you in advance!

Add support for Linux/Arm64 (Aarch64) platform

LWJGL and Bytedeco JavaCPP both offer Arm64 native libraries. I have a nVidia Jetson Nano at my disposal on which I can validate if things are working.

  • Add natives for Linux/Arm64
  • Window and OpenGL context creation
  • Webcams through ffmpeg
  • Audio though OpenAL
  • Verify that ScreenRecorder works
  • Verify that file dialogs work

Allow having a margin on the main renderTarget

This would allow having a setup where we can have the panel/gui placed on the side without being on top of the canvas, f.ex:

configure {
	width = 768
	height = 768
	margin = WindowMargin.Left(200.0)
}

The window's width would be 968 but the main Rendertarget would have a width of 768. I assume the margin part cannot just be made of nothing, so we would need another rendertarget that would be the full dimensions of the window 968x768.

Add Feature Request issue template

As title says.

  • Example (taken from bpmn-js repo). The name, about, labels should show a table.. not sure why it isn't working.

name: Feature request
about: Suggest an idea or general improvement.
labels: "enhancement"

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

CompositionDrawer does not preserve transformations when writing to SVG

I don't know if this counts as a bug or just my own ignorance, but I'm attempting to use the CompositionDrawer with transformations such as translate, rotate, and scale. I'm able to use these successfully with the normal Drawer. If it is a bug then I will reformat the issue to match the template.

My problem is that none of the transformations used withCompositionDrawer seem to make it into an SVG file.

Here's a sample code snippet that produces a handful of rectangles all in their original orientation with no rotation when written to an SVG file:

fun writeSvgFile(width: Int, height: Int) {
        val symmetry: Int = 6
        val drawer = CompositionDrawer()

        drawer.translate(width / 2.0, height / 2.0)
        val angle = 360.0 / symmetry.toDouble()
        for (i in (0 until symmetry)) {
            drawer.rotate(angle)
            drawer.rectangle(5.0*i, 5.0*i, 10.0, 15.0)
        }

        val composition: Composition = drawer.composition
        val svgDoc = writeSVG(composition)
        File("screenshots/output.svg").writeText(svgDoc)
}

It is certainly possible I am misunderstanding something about CompositionDrawer in relation to Drawer but I haven't seen anything to indicate as such. Below is a slightly styled version of how Drawer draws the rectangles.

Screen Shot 2020-02-02 at 4 04 32 PM

Add ColorBuffer.fromBytes

This is needed to load encoded data from ByteArray and/or ByteBuffer. There's already ColorBuffer.fromStream but that may be inconvenient in some use scenarios.

Add Drawer.defaults()

Drawer.reset() has similar behaviour but destroys the state stacks, which doesn't work nice inside .isolated { } environments.

Rework uniform optimization message

At the moment, when uniforms are removed this kind of message will be logged in the console: [main] WARN org.openrndr.internal.gl3.ShaderGL3 - shader <unknown-vertex-shader> / <unknown-fragment-shader> does not have a uniform called 'color'

There should be a way to set/have the name of the shader in question.

mark Drawer.isolated and Drawer.isolatedWithTarget as inline

Describe the bug
minor improvement: Drawer.isolated() and Drawer.isolatedWithTarget() functions could probably be marked as inline to avoid the allocation of the lambda argument.

Context:

/**
* Pushes style, view- and projection matrix, calls function and pops.
* @param function the function that is called in the isolation
*/
fun Drawer.isolated(function: Drawer.() -> Unit) {
pushTransforms()
pushStyle()
function()
popStyle()
popTransforms()
}
/**
* Pushes style, view- and projection matrix, sets render target, calls function and pops,
* @param function the function that is called in the isolation
*/
fun Drawer.isolatedWithTarget(target: RenderTarget, function: Drawer.() -> Unit) {
target.bind()
isolated(function)
target.unbind()
}

Change ColorHSVa.mix() so it takes the shorter path between hues

Colors with hue 0.05 and 0.95 are very similar.
Interpolation between them should go from 0.05 down to 0.0 and
then from 1.0 down to 0.95, as hue 0° = hue 360°.

Otherwise interpolating these similar colors goes through the whole spectrum producing a rainbow.

// current implementation
fun mix(left: ColorHSVa, right: ColorHSVa, x: Double): ColorHSVa {
    val sx = x.coerceIn(0.0, 1.0)
    return ColorHSVa(
            (1.0 - sx) * left.h + sx * right.h,
            (1.0 - sx) * left.s + sx * right.s,
            (1.0 - sx) * left.v + sx * right.v,
            (1.0 - sx) * left.a + sx * right.a)
}

For .h, if the distance between sx and (1.0 - sx) > 0.5, it should shift one of the values by 1.0 so the distance is < 0.5 and maybe use modulo(1.0) to make sure the result wraps around the maximum.

IllegalArgumentException when using ScreenRecorder

Describe the bug
A program fails to start with an IllegalArgumentException when the app is extended with ScreenRecorder with some window sizes.

To Reproduce
Here is a small snippet of code:

class Demo : Program() {
    override fun setup() {
        extend(ScreenRecorder().apply {
            frameRate = 10
        })

        extend(FunctionDrawer {
            drawer.circle(width / 2.0, height / 2.0, 10.0)
        })
    }
}

fun main(args: Array<String>) {
    application(
            Demo(),
            configuration {
                width = 800
                height = 600
                showBeforeSetup = false
                hideCursor = true
            }
    )
}

If one starts it without modifications, the exception is given:

Exception in thread "main" java.lang.IllegalArgumentException: width (800) and height (599) should be divisible by 2
	at org.openrndr.ffmpeg.VideoWriter.size(VideoWriter.kt:150)
	at org.openrndr.ffmpeg.ScreenRecorder.setup(ScreenRecorder.kt:38)
	at org.openrndr.Program.extend(Program.kt:211)
	at Demo.setup(Posters.kt:9)
	at org.openrndr.internal.gl3.ApplicationGLFWGL3.loop(ApplicationGLFWGL3.kt:434)
	at org.openrndr.Application$Companion.run(Application.kt:18)
	at org.openrndr.ApplicationKt.application(Application.kt:56)
	at PostersKt.main(Posters.kt:20)

To fix that one can set height to 601 or disable the ScreenRecorder.

Expected behavior
A black window with a small circle in a center

Context:
OS:

$ cat /etc/lsb-release
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=18.0.0-rc
DISTRIB_CODENAME=Illyria
DISTRIB_DESCRIPTION="Manjaro Linux"

OpenRNDR:

0.3.27

Java:

$ java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

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.