Comments (4)
Also of note, at the top of the image there's a live framerate and mouse positioning tracker. I have the framerate set at 15, and it's reporting a rate of 12.29. That's due to inaccuracy of the framerate tracking, not an indication of how slow things are. The raw framerate can be much higher (blit to host at 120fps), and the drawing will consume some time per frame, but it's nowhere near saturation at this point.
Also, that spirograph thing isn't a static image, it's constantly updating animation, just like the framerate tracker.
The checkerbox pattern is the default background of my 'desktop'.
The 'windows' are the big translucent gray that has the getting started examples, and the smaller one to the right that houses the spirograph. Just testing the compositor. Windows can have any background they like, and can have any shape they like, just like with Win32, but all with Blend2d.
The setup for that screen looks like this in code:
local winman = require("WinMan")
local stopviews = require("STOP_views")
local spiroapp = require("STOP_spiroapp")
local framestatapp = require("STOP_framestat")
local function startup()
spawn(framestatapp, {x=0, y=0, width=1920, height=20})
spawn(stopviews,{x=100, y=100, width=1024, height=768})
spawn(spiroapp,{x=800, y=300, width=640, height=480})
end
winman {width = 1920, height=1080, startup = startup}
And the spiroapp looks like
local SpiroGraphic = require("SpiroGraphic")
local function app(params)
local win1 = WMCreateWindow(params.x,params.y, params.width, params.height)
local spg = SpiroGraphic:new({width = params.width, height=params.height})
win1:add(spg)
win1:show()
while true do
win1:draw()
yield();
end
end
return app
And the spirographic itself looks like
local Graphic = require("Graphic")
local floor = math.floor
local random = math.random
local sin = math.sin;
local cos = math.cos
local SpiroGraphic = Graphic:new()
function SpiroGraphic.new(self, obj)
obj = obj or {}
obj.N = 36;
obj.theta = 3.14159 * 2 / obj.N;
obj.centerX = obj.centerX or obj.width/2;
obj.centerY = obj.centerY or obj.height/2;
setmetatable(obj, self)
self.__index = self;
return obj;
end
function SpiroGraphic:draw(ctxt)
ctxt:stroke(255, 0,0)
ctxt:setStrokeWidth(1)
local x = 0;
local y = 0;
local Radius = (self.height / 2) - 5;
for p = 0, self.N-1 do
local num = floor((p / self.N) * 254.0);
local r = random(0, num);
local g = random(0, num);
local b = random(0, num);
ctxt:stroke(r, g, b)
for q = 0, p-1 do
ctxt:line(floor(self.centerX + Radius * sin(p * self.theta)), floor(self.centerY + Radius * cos(p * self.theta)),
floor(self.centerX + Radius * sin(q * self.theta)), floor(self.centerY + Radius * cos(q * self.theta)));
end
end
end
return SpiroGraphic
The environment these things live in already contains a little user mode scheduler "scheduler.lua" if you look at the source code. That gives things like 'spawn', 'periodic', 'on', 'whenever', etc. That makes it real easy to stitch together task like things. Interweave with graphics, and there you have it.
from blend2d.
And, I guess it would be nice if the rest of the examples on the home page were available in code. I can roughly figure out how to replicate them, but it would be nice to have access to the officials used.
from blend2d.
Nice thank you for sharing :)
from blend2d.
Closed as commentary
from blend2d.
Related Issues (20)
- UBSAN SIGSEGV when calling a JIT compiled pipeline (Clang 17+) HOT 10
- Have problems building the library HOT 20
- writeToFile should be const HOT 1
- Rectangles with zero sizes are drawn incorrectly HOT 5
- crash when saving/restoring strokeOptions HOT 2
- crash: blitImage + setTransform HOT 4
- img.getData 0.9.0 to 0.10.5 version HOT 4
- Wish: implement an API to rendering text along/by a path HOT 1
- composition operator not work on macOS MPB with Apple m1 HOT 2
- [Portable Pipeline] Composition operators not working (only SrcCopy and SrcOver) HOT 11
- Rendering bug with BLContext for certain image sizes HOT 2
- Wish: Android support HOT 2
- Raspberry Pi 2B rev1.1 compilation failed HOT 3
- about BLFont question HOT 12
- strokedPath error HOT 1
- Can bled2d be easily ported to rtos? HOT 3
- Rendering of fonts in various national languages HOT 2
- Build failure simdx86_test_avx512.cpp, MingGW-w64, static, cmake/ninja, no tests HOT 4
- clipToRect not correctly applied to fillGlyphRun within rotated context HOT 4
- crash with gcc (Debian 12.2.0-14) 12.2.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blend2d.