GithubHelp home page GithubHelp logo

Bindings requests about skija HOT 10 CLOSED

jetbrains avatar jetbrains commented on May 22, 2024
Bindings requests

from skija.

Comments (10)

tonsky avatar tonsky commented on May 22, 2024 1

Ok thanks, I’ll get back to it approx in two weeks, after some vacation time :)

from skija.

tonsky avatar tonsky commented on May 22, 2024 1

Right now we publish jar with native macOS dylib at https://bintray.com/beta/#/jetbrains/skija/skija?tab=overview. If you are on a mac, you can depend on those. Those are published per every commit. E.g. 0.4.35 contains your request on gradient points and saveLayer with Rect.

In the future we are going to split single jar into separate skija and skija-natives-mac and introduce other platforms.

from skija.

tonsky avatar tonsky commented on May 22, 2024 1

Re: drawOnPath. It seems that it was at one point in Skia, but has been removed since. The solution would be to reimplement it with the existing primitives.

from skija.

tonsky avatar tonsky commented on May 22, 2024 1

Ok, I have now pushed all the necessary primitives to implement text on path. Since it is no longer in Skia, I am not putting dedicated textOnPath method into Skija, but it is simple enough to implement. Please take a look:

public void drawRSXform(Canvas canvas) {
short[] glyphs = font.getStringGlyphIds("Circular Text");
float[] widths = font.getWidths(glyphs);
RSXform[] xforms = new RSXform[glyphs.length];
float radius = 50;
int period = 3000;
try (Path path = new Path().addCircle(0, 0, radius);
PathMeasure measure = new PathMeasure(path);
Paint fill = new Paint().setColor(0xffffba08);
Paint stroke = new Paint().setColor(0xff3a86ff).setMode(PaintMode.STROKE).setStrokeWidth(1f);)
{
float length = measure.getLength();
float relativeOffset = System.currentTimeMillis() % period / (float) period;
float distance = relativeOffset * length;
for (int i=0; i < xforms.length; ++i) {
float w = widths[i];
distance += w / 2;
while (distance > length)
distance -= length;
Point p = measure.getPosition(distance);
Point t = measure.getTangent(distance);
xforms[i] = new RSXform(t.getX(), t.getY(), p.getX() - w / 2f * t.getX(), p.getY() - w / 2f * t.getY());
distance += w / 2;
}
canvas.save();
canvas.translate(radius + gap, radius + gap);
canvas.drawPath(path, stroke);
canvas.drawTextBlob(TextBlob.makeFromRSXform(glyphs, xforms, font), 0, 0, font, fill);
canvas.restore();
}

This is what I am getting:

Screenshot 2020-09-16 at 17 04 51

from skija.

tonsky avatar tonsky commented on May 22, 2024 1

Oh, and the repo changed to. We now host it in JetBrains Space https://packages.jetbrains.team/maven/p/skija/maven instead of bintray.

from skija.

tonsky avatar tonsky commented on May 22, 2024

Hi @Solido, I have couple of questions:

Canvas drawTextOnPath

Canvas does not seem to have drawTextOnPath. Seems like it could be implemented with PathMeasure (which I just added) and TextBlob::MakeFromRSXform (which I will add soon) should be enough. Unless I am missing something?

color4f OK on gradient but UnsatisfiedLinkError on Paint

Seems to work in my example:

private void drawColors(Canvas canvas) {
canvas.save();
try (Paint fill = new Paint()) {
fill.setColor(0xFFFF0000);
canvas.drawRect(Rect.makeXYWH(0, 0, 60, 20), fill);
fill.setColor(0xFF00FF00);
canvas.drawRect(Rect.makeXYWH(0, 20, 60, 20), fill);
fill.setColor(0xFF0000FF);
canvas.drawRect(Rect.makeXYWH(0, 40, 60, 20), fill);
canvas.translate(70, 0);
fill.setColor4f(new Color4f(1, 0, 0, 1));
canvas.drawRect(Rect.makeXYWH(0, 0, 60, 20), fill);
fill.setColor4f(new Color4f(0, 1, 0, 1));
canvas.drawRect(Rect.makeXYWH(0, 20, 60, 20), fill);
fill.setColor4f(new Color4f(0, 0, 1, 1));
canvas.drawRect(Rect.makeXYWH(0, 40, 60, 20), fill);
canvas.translate(70, 0);
fill.setColor4f(new Color4f(1, 0, 0, 1), ColorSpace.getSRGB());
canvas.drawRect(Rect.makeXYWH(0, 0, 60, 20), fill);
fill.setColor4f(new Color4f(0, 1, 0, 1), ColorSpace.getSRGB());
canvas.drawRect(Rect.makeXYWH(0, 20, 60, 20), fill);
fill.setColor4f(new Color4f(0, 0, 1, 1), ColorSpace.getSRGB());
canvas.drawRect(Rect.makeXYWH(0, 40, 60, 20), fill);
canvas.translate(70, 0);
fill.setColor4f(new Color4f(1, 0, 0, 1), ColorSpace.getDisplayP3());
canvas.drawRect(Rect.makeXYWH(0, 0, 60, 20), fill);
fill.setColor4f(new Color4f(0, 1, 0, 1), ColorSpace.getDisplayP3());
canvas.drawRect(Rect.makeXYWH(0, 20, 60, 20), fill);
fill.setColor4f(new Color4f(0, 0, 1, 1), ColorSpace.getDisplayP3());
canvas.drawRect(Rect.makeXYWH(0, 40, 60, 20), fill);
canvas.translate(70, 0);
}
canvas.restore();
canvas.translate(0, 70);
}
. Can you still reproduce it? Can you share a code example?

from skija.

Solido avatar Solido commented on May 22, 2024

Hi @tonsky
Hope you had good holidays !

More info drawOnPath
https://skia.org/user/api/bmh_SkPath?cl=9919
mono/SkiaSharp#1183

If color4f works on your code then it's on my side !
Currently I compile libskija.dylib and put it in my resources folder.

For the lib I also to local maven then

api "org.jetbrains.skija:skija:0.0.0-local"
api "org.jetbrains.skija:skija:0.0.0-local-natives-mac-x64"

Done the full process but color4f is not even found while on the ide ...

How can I better follow your coming updates ?
Is it possible to have it linked by using a common maven repo ?

So far it's working great, Thanks

from skija.

Solido avatar Solido commented on May 22, 2024

That was fast ! :D

from skija.

tonsky avatar tonsky commented on May 22, 2024

JFYI @Solido artifacts coordinates changed a little. Published versions now look like this:

org.jetbrains.skija:skija-macos:0.4.48

And local ones (installed via ./script/install.sh) are:

org.jetbrains.skija:skija-platform:0.0.0-SNAPSHOT

See README for more details.

from skija.

Solido avatar Solido commented on May 22, 2024

Thanks @tonsky !
All updated with the new repo

from skija.

Related Issues (20)

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.