smackem / ylang Goto Github PK
View Code? Open in Web Editor NEWAn image manipulation language
License: MIT License
An image manipulation language
License: MIT License
map_*
functions to fetchR
, fetchG
etcput(pos, kernelR, kernelG, kernelB, kernelA)
method
replace []
with ||
for kernels:
|1 2 1
2 4 2
1 2 1|
[]
should be used for lists
polygonFromList([0;10, 100;10, 12;12])
Add function kernel(count) to create a non-quadratic kernel with count elements that can be used like an array
Add a real README with language description, sample code and images
All bindings written in uppercase (like IMAGE/BOUNDS, BLACK) - whether script-defined or pre-defined, should not be assignable.
k := list(10, 0)
k[1] = 1
intersect(line(0;0, 100;100), line(0;100, 100;0))
should return 50;50
returns nil
when there is no intersection
lang.Number should point to float32 instead of float64.
convert entire image when loading to lang.Number format, convert back on save
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
polygon(10;20, 40;23, 100;40)
creates a closed polygon, which can be iterated like a rect or a line
e := ellipse(10;10, 200) // center, radius
for p in e {
....
Foreach value type, create a unit test file that uses compileAndInterpret to test the value implementation.
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 bindings for pre-defined values IMAGE(rect), W, H, BLACK, WHITE
Use DDA for line function that works like rect
:
for pos in line(10;10, 100;200) {
@pos = #FF0000
}
add method log(string)
to BitmapContext and use it for generating output instead of just calling printf
def fun(x, y) {
return x + y
}
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.
In the following snippet,
fn(x) {
y := x * x
doit(fn() -> x + y)
}
the lambda function passed to doit
should capture x
and y
.
@((p1.x - 1);(p1.y - 1)) = #ffffff
is embarassing
should be
@(p1.x - 1; p1.y - 1) = #ffffff
polygon(10;20, 100;23, 33;403, 123;20, 32;32)
Add resize(w, h) statement
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.
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
h := { p1: 0;0, p2: 100;200 }
for p in line(h.p1, h.p2) {...
Implement a function that maps a kernel, returning a sub-image (kernel of colors)
|
- bitor
&
- bitand
^
- bitxor
~
- bitnot
<<
- leftshift
>>
- rightshift
Support "#112233", "#112233FF", "#123", "#123F"
for angle in 0 .. 15 .. 360
right now, indexing like k[0]
is handled by the interpreter, exclusively for kernels. it should be a feature of interface value. required for list types
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]
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)
The for x in rect
loop can be parallelized (separate rect in 4/8 rects).
Should only be done when iterating over rects
[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
Kernel must contain a quadratic number of elements. This is yet unchecked.
translateLine(line, point) -> line
translateRect(rect, point) -> rect
translatePolygon(polygon, point) -> polygon
translateEllipse(ellipse, point) -> ellipse
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.
add an internal type colorHSV with properties h, s, v and functions to_hsv(color) and to_color(colorHSV)
this increased performance and enables significant whitespace
all value implementations should have a property __type
that returns a string containing the type name to enable type checks:
if val.__type == "point" {
...
}
if x { ... } else if y { ... } else if z { ... } else { }
nil
should be used to define uninitialized variables and as default value
log("a", "b")
should print a b
instead of "a""b"
all value implementations should generate sensible output, especially color
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[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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.