Skip to content
View source

vectorGenerated

Category: Packages · Manifest: use "kernels/";

Drawings filled pixel by pixel.

Drawings filled pixel by pixel: the shapes entelechy import reads from SVG, their fill rules, paints and gradients, drawn whole or tiled.

Layer: Graphics. Uses: parallel.

use "vector.entpkg";
  • kernels/fill.ent — Drawing as Kernels. Kernels: vector.frame@1, vector.whole@1, vector.draw@1.
  • kernels/shape.ent — A drawing’s shapes as entelechy import writes them from an SVG.
  • kernels/tile.ent — The tiled form. Kernels: vector.reach@1, vector.shape_chunks@1, vector.tile_counts@1, vector.tile_fill@1, vector.placed@1, vector.segment_chunks@1, vector.units@1, vector.kept@1, vector.keep@1, vector.zeros@1, vector.backdrop@1, vector.draw_tiled@1.
  • graphs/draw.esn — A drawing through look at the window’s size, tiled.
  • graphs/drawing.esn — A drawing, whole and fitted to the window, over background.

tests/ holds scenes and their replays, run on every backend: many.replay, tiled.replay. Every Kernel of the package is reached by one of them.

Used by the vector example.

Kernel Mode Brief
vector.backdrop@1 scatter into input 12 with sum Each cell’s backdrop, a row of its tile to an element. Each of a unit’s segments wholly past the tile adds its turn to the rows it may cross, a pixel over its ends, each crossing tested at the row’s point in the drawing, read from the frame the drawing reads, as crossed tests it.
vector.draw@1 map The drawing over background, through frame, at the node’s domain: every pixel asks every shape and segment.
vector.draw_tiled@1 map The drawing, each pixel asking only its tile’s shapes and, of each, the cell’s own segments over its row’s backdrop: the same words vector.draw@1 draws.
vector.frame@1 map Where the look puts each pixel’s center in the drawing, and a pixel’s size there: the x of each of across’s columns, then the y of each of down’s rows, then the size; domain = count(across) + count(down) + 1. Every Kernel that asks where a pixel is reads it here, so they agree to the bit wherever each runs.
vector.keep@1 scatter into input 11 with max Each unit’s segments, in their order, into its part of the cells’ list: the walk vector.kept@1 counts.
vector.kept@1 map How many of its segments each unit gives its cell.
vector.placed@1 map Each segment on the canvas, as its shape’s box is.
vector.reach@1 map Each shape’s reach: the tiles its box, grown by two pixels, touches on the canvas.
vector.segment_chunks@1 map The box each chunk of segments spans on the canvas: least x and y, most x and y.
vector.shape_chunks@1 map What each chunk of shapes reaches together.
vector.tile_counts@1 map How many shapes reach each tile.
vector.tile_fill@1 scatter into input 5 with max Each tile’s shapes, in their order, into its part of the list: the walk vector.tile_counts@1 counts, stopped at its count.
vector.units@1 map How many units each cell is: its shape’s chunks.
vector.whole@1 map A look at the whole drawing: its middle, fitted to the picture.
vector.zeros@1 map A list of zeros, a row of each cell’s tile to each.
Function Brief
to_segment(p: Vec2, a: Vec2, b: Vec2) -> Float
spread_by(t: Float, spread: Int) -> Float
stops_at(stops: Rows<Stop>, first: Int, n: Int, t: Float) -> Vec4
paint_at(shape: Shape, stops: Rows<Stop>, p: Vec2) -> Vec4
crossed(w: Vec2, seg: Vec4, p: Vec2) -> Vec2
near(s: Shape, p: Vec2, pixel: Float) -> Bool
laid(below: Vec4, s: Shape, stops: Rows<Stop>, p: Vec2, pixel: Float, hit: Vec2) -> Vec4
seen(frame: Rows<Float>, wide: Int, pixel_at: Vec2) -> Vec3
fitted(size: Vec2, eye: Look, res: Vec2) -> Float
tile() -> Float
tile_columns(res: Vec2) -> Int
tile_rows(res: Vec2) -> Int
on_canvas(q: Vec2, view: Rows<Vec2>, look: Rows<Look>, res: Vec2) -> Vec2
reach_holds(r: Reach, tx: Int, ty: Int) -> Bool
chunk() -> Int
keeps(reach: Rows<Reach>, s: Int, tx: Int, ty: Int) -> Bool
in_rows(lo: Float, hi: Float, ty: Int) -> Bool
in_columns(lo: Float, hi: Float, tx: Int) -> Bool
past(lo: Float, tx: Int) -> Bool
own(on: Vec4, tx: Int, ty: Int) -> Bool
chunks_of(s: Shape) -> IVec2
part_of(s: Shape, c: Int) -> IVec2
work_unit_of(u: Int, units: Rows<Int>, unit_ends: Rows<Int>, tile_ends: Rows<Int>, tile_shapes: Rows<Int>, tiles: Grid<Int>, shapes: Rows<Shape>) -> Unit
Name Syntax
Shape struct Shape
FillRule type FillRule = enum { NonZero, EvenOdd };
Paint type Paint = enum { Color, Linear, Radial };
Spread type Spread = enum { Pad, Reflect, Repeat };
Stop struct Stop { offset: Float; color: Vec4; }
Look struct Look { center: Vec2; zoom: Float; }
Reach struct Reach { x0: Int; y0: Int; x1: Int; y1: Int; }
Slot struct Slot { at: Int; value: Int; }
Unit struct Unit { cell: Int; tx: Int; ty: Int; chunk: Int; first: Int; count: Int; }
Name Interface Description
draw input shapes: Rows<Shape>
input segments: Rows<Vec4>
input stops: Rows<Stop>
input view: Rows<Vec2>
input look: Rows<Look>
param background: Vec4 = vec4(1.0, 1.0, 1.0, 1.0)
output picture <- drawn.result
A drawing through look at the window’s size, tiled: the canvas is cut into tiles of 16 pixels, each keeps the shapes whose boxes reach it, each of those keeps the segments that reach the tile and the winding of those past it to the right, and each pixel asks only those. It draws the words vector.draw@1 draws, at the cost of a few passes over shapes and segments, so a large drawing (a map, a page of type) draws in time.
drawing input shapes: Rows<Shape>
input segments: Rows<Vec4>
input stops: Rows<Stop>
input view: Rows<Vec2>
param background: Vec4 = vec4(1.0, 1.0, 1.0, 1.0)
output picture <- drawn.picture
A drawing, whole and fitted to the window, over background. Its Fields are what entelechy import drawing.svg writes: node picture: graph “../../packages/vector.entpkg/graphs/drawing.esn” { shapes <- shapes; segments <- segments; stops <- stops; view <- view; }

Each cell’s backdrop, a row of its tile to an element. Each of a unit’s segments wholly past the tile adds its turn to the rows it may cross, a pixel over its ends, each crossing tested at the row’s point in the drawing, read from the frame the drawing reads, as crossed tests it.

Mode scatter into input 12 with sum
Requires field.read, field.write
Inputs total: Rows<Int>, units: Rows<Int>, unit_ends: Rows<Int>, tile_ends: Rows<Int>, tile_shapes: Rows<Int>, tiles: Grid<Int>, shapes: Rows<Shape>, placed: Rows<Vec4>, chunks: Rows<Vec4>, segments: Rows<Vec4>, frame: Rows<Float>, canvas: Grid<Int>, zeros: Rows<Int>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

The drawing over background, through frame, at the node’s domain: every pixel asks every shape and segment.

Mode map
Requires field.read, field.write
Inputs shapes: Rows<Shape>, segments: Rows<Vec4>, stops: Rows<Stop>, frame: Rows<Float>
Params background: Vec4 = [1.0, 1.0, 1.0, 1.0]
Outputs result: Image
Source packages/vector.entpkg/kernels/fill.ent

The drawing, each pixel asking only its tile’s shapes and, of each, the cell’s own segments over its row’s backdrop: the same words vector.draw@1 draws.

Mode map
Requires field.read, field.write
Inputs shapes: Rows<Shape>, segments: Rows<Vec4>, stops: Rows<Stop>, frame: Rows<Float>, tile_counts: Rows<Int>, tile_ends: Rows<Int>, tile_shapes: Rows<Int>, units: Rows<Int>, unit_ends: Rows<Int>, kept: Rows<Int>, kept_ends: Rows<Int>, cell_segments: Rows<Int>, backdrop: Rows<Int>
Params background: Vec4 = [1.0, 1.0, 1.0, 1.0]
Outputs result: Image
Source packages/vector.entpkg/kernels/tile.ent

Where the look puts each pixel’s center in the drawing, and a pixel’s size there: the x of each of across’s columns, then the y of each of down’s rows, then the size; domain = count(across) + count(down) + 1. Every Kernel that asks where a pixel is reads it here, so they agree to the bit wherever each runs.

Mode map
Requires field.read, field.write
Inputs across: Grid<Int>, down: Grid<Int>, view: Rows<Vec2>, look: Rows<Look>
Params —
Outputs result: Rows<Float>
Source packages/vector.entpkg/kernels/fill.ent

Each unit’s segments, in their order, into its part of the cells’ list: the walk vector.kept@1 counts.

Mode scatter into input 11 with max
Requires field.read, field.write
Inputs total: Rows<Int>, kept: Rows<Int>, kept_ends: Rows<Int>, units: Rows<Int>, unit_ends: Rows<Int>, tile_ends: Rows<Int>, tile_shapes: Rows<Int>, tiles: Grid<Int>, shapes: Rows<Shape>, placed: Rows<Vec4>, chunks: Rows<Vec4>, slots: Rows<Int>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

How many of its segments each unit gives its cell.

Mode map
Requires field.read, field.write
Inputs total: Rows<Int>, units: Rows<Int>, unit_ends: Rows<Int>, tile_ends: Rows<Int>, tile_shapes: Rows<Int>, tiles: Grid<Int>, shapes: Rows<Shape>, placed: Rows<Vec4>, chunks: Rows<Vec4>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

Each segment on the canvas, as its shape’s box is.

Mode map
Requires field.read, field.write
Inputs segments: Rows<Vec4>, view: Rows<Vec2>, look: Rows<Look>, canvas: Grid<Int>
Params —
Outputs result: Rows<Vec4>
Source packages/vector.entpkg/kernels/tile.ent

Each shape’s reach: the tiles its box, grown by two pixels, touches on the canvas.

Mode map
Requires field.read, field.write
Inputs shapes: Rows<Shape>, view: Rows<Vec2>, look: Rows<Look>, canvas: Grid<Int>
Params —
Outputs result: Rows<Reach>
Source packages/vector.entpkg/kernels/tile.ent

The box each chunk of segments spans on the canvas: least x and y, most x and y.

Mode map
Requires field.read, field.write
Inputs placed: Rows<Vec4>
Params —
Outputs result: Rows<Vec4>
Source packages/vector.entpkg/kernels/tile.ent

What each chunk of shapes reaches together.

Mode map
Requires field.read, field.write
Inputs reach: Rows<Reach>
Params —
Outputs result: Rows<Reach>
Source packages/vector.entpkg/kernels/tile.ent

How many shapes reach each tile.

Mode map
Requires field.read, field.write
Inputs reach: Rows<Reach>, chunks: Rows<Reach>, tiles: Grid<Int>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

Each tile’s shapes, in their order, into its part of the list: the walk vector.tile_counts@1 counts, stopped at its count.

Mode scatter into input 5 with max
Requires field.read, field.write
Inputs reach: Rows<Reach>, chunks: Rows<Reach>, counts: Rows<Int>, ends: Rows<Int>, tiles: Grid<Int>, slots: Rows<Int>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

How many units each cell is: its shape’s chunks.

Mode map
Requires field.read, field.write
Inputs total: Rows<Int>, tile_shapes: Rows<Int>, shapes: Rows<Shape>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

A look at the whole drawing: its middle, fitted to the picture.

Mode map
Requires field.read, field.write
Inputs view: Rows<Vec2>
Params —
Outputs result: Rows<Look>
Source packages/vector.entpkg/kernels/fill.ent

A list of zeros, a row of each cell’s tile to each.

Mode map
Requires field.read, field.write
Inputs total: Rows<Int>
Params —
Outputs result: Rows<Int>
Source packages/vector.entpkg/kernels/tile.ent

many.replay, tiled.replay