Giter Site home page Giter Site logo

smackem / ylang Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 14.45 MB

An image manipulation language

License: MIT License

Go 95.12% HTML 1.20% JavaScript 3.66% Shell 0.02%
compiler golang image image-analysis image-manipulation image-processing vscode-extension

ylang's People

Contributors

smackem avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ylang's Issues

Change kernel syntax

replace [] with || for kernels:

|1 2 1
 2 4 2
 1 2 1|

[] should be used for lists

Add README

Add a real README with language description, sample code and images

Add intersect function

intersect(line(0;0, 100;100), line(0;100, 100;0))

should return 50;50
returns nil when there is no intersection

Change number format to float32

lang.Number should point to float32 instead of float64.
convert entire image when loading to lang.Number format, convert back on save

nil should point to constant

nil in ylang is represented by the golang nil value. this leads to golang runtime errors on nil dereference.
better introduce a constant of type nilValue that implements value to represent ylang's nil

Add polygon type

polygon(10;20, 40;23, 100;40)

creates a closed polygon, which can be iterated like a rect or a line

Ellipse type

e := ellipse(10;10, 200) // center, radius
for p in e {
    ....

Create symbol table to report positions from interpreter

each ast element should be associated (via map of instance to some Position) to a Position as generated by the lexer like this:

	harald := person{"harald", 10}
	herbert := person{"herbert", 20}
	harald2 := person{"harald", 10}

	m := map[interface{}]int{
		&harald: 100,
		&herbert: 200,
		&harald2: 500,
	}

	fmt.Printf("%+v: %d\n", harald, m[&harald])
	fmt.Printf("%+v: %d\n", harald2, m[&harald2])

Add line function

Use DDA for line function that works like rect:

for pos in line(10;10, 100;200) {
  @pos = #FF0000
}

Add significant new-lines

only new-lines after these tokens (that cannot close a statement) are ignored:

{
[
(
=
:=
,
;

significant new-lines close statements and break scanlines in kernel definitions. this enables kernel expressions with non-quadratic number of values like

[1 0 1
 2 0 2]

new-lines can be escaped with `:

if x < 0`
or x > max {
    ...

requires #16.

Support for Closures

In the following snippet,

fn(x) {
  y := x * x
  doit(fn() -> x + y)
}

the lambda function passed to doit should capture x and y.

Add math functions

re-do function system to provide a mechanism for registering built-in functions that are known at parse time.
then implement sin, cos, tan, asin, acos, atan, atan2, sqrt etc.

Support clip rect

new function clip(rc):
with rc = rect -> set clip rectangle to rc
with rc = nil -> remove clip rectangle
e.g.
after clip(Bounds) you can safely write anywhere without segfault

Bitwise operators

| - bitor
& - bitand
^ - bitxor
~ - bitnot
<< - leftshift
>> - rightshift

pop, push, enqueue, dequeue functions for lists

push adds last, pop removes last
enqueue adds last, dequeue removes first

ls := [1]
push(ls, 2) // ls = [1,2]
x := pop(ls) // x = 2, ls = [1]
enqueue(ls, 3) // ls = [1,3]
y := dequeue(ls) // y = 1, ls = [3]

Support Generic Iterations

rect, kernel, line should all support iteration over positions:

for pos in line(100;100, 20;200) {...}

requires #27
Add something like value.iterate(visit func(value) error)

Parallel for loop

The for x in rect loop can be parallelized (separate rect in 4/8 rects).
Should only be done when iterating over rects

Support list type

[1, 2, 3, true, "abc", line(0;0, 10;10)]

should create a list.

[1, 2] :: 100
1 :: 2

all build lists by concatenation

[1, 2, 3][0]
[1, 2, 3][1:2] // optional, like go
[1, 2, 3][1:] // optional, like go

index list elements

for x in [1,2,3] {
 ...
}

iterates over list

requires #38

Translation functions

translateLine(line, point) -> line
translateRect(rect, point) -> rect
translatePolygon(polygon, point) -> polygon
translateEllipse(ellipse, point) -> ellipse

Rename blt to commit

blt should copy all pixels in a region from source to target. it should always require a rect parameter.
for the current purpose of blt (copy last region from target to source), add the new commit statement with optional rect parameter.

HSV color space support

add an internal type colorHSV with properties h, s, v and functions to_hsv(color) and to_color(colorHSV)

Support Runtime-Types

all value implementations should have a property __type that returns a string containing the type name to enable type checks:

if val.__type == "point" {
    ...
}

Consolidate log output

log("a", "b") should print a b instead of "a""b"
all value implementations should generate sensible output, especially color

Add function overloads

math functions should be callable for numbers as well as colors.
therefore, add the possibility to define multiple functionDecls to one identifier, e.g.
"sqrt": []functionDecl{ functionDecl{ invokeSqrtNum, []reflect.Type{numberType}, }, functionDecl{ invokeSqrtCol, []reflect.Type{colorType}, }, }

Kernel element accessor

Kernel[i] should return the element at i and Kernel[x, y] should access the kernel like an image with kernel[kernel.radius, kernel.radius] as center.

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.