From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 17747 invoked from network); 1 Jan 2021 15:54:56 -0000 Received: from ewsd.inri.net (107.191.116.128) by inbox.vuxu.org with ESMTPUTF8; 1 Jan 2021 15:54:56 -0000 Received: from mail-wr1-f46.google.com ([209.85.221.46]) by ewsd; Fri Jan 1 10:53:42 -0500 2021 Received: by mail-wr1-f46.google.com with SMTP id r3so22230394wrt.2 for <9front@9front.org>; Fri, 01 Jan 2021 07:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:to:cc:subject:date:mime-version :content-transfer-encoding; bh=3K8/SH2r4gGVftwO/vqyvXXguN2th9CI9ddQI9OhA4s=; b=a3iuV+EUcfQXWn5srb8DM5rQHCXYCDBRQ8U6Nin0j99FwpvawdiDssyEkAg9V/TCKZ EGdCZumI8qsLsRVW4ekmBP77OxQBdLJ0hIMZFMJijZ2QP7UPFsBvLba6l0UGeC15PM+X Eo/dKeOu+/7WRzgdImCH8Zn3oWn6yy3+D/O83lBqMN1tuk7YpPPZEcKnsFLCkN1FNcQI PSkn4awOBTE641LxhjI2FnDsx31cCOpSB5Ih33jdo/Se28SsukYl9J5+XwdQIDqePyAO Ij2rhBLkodHSvRbGcO2J8i4hE8LKk4NMECE1xOql0TRNJONqIFP61W06EKCvFwDERzUT IBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:to:cc:subject:date:mime-version :content-transfer-encoding; bh=3K8/SH2r4gGVftwO/vqyvXXguN2th9CI9ddQI9OhA4s=; b=leW/I6qvcwrVlKv395saXZyOUIHgpzd/KOQM3Zn0mkvYuBF7EieOgOSy1q+w1olq4Z A1nG1ILA+7+NrOk7kGGl0cVYBpw7WHbQxksTzVNMVU9encYOFm+zyMXJw7wGefF6OHhF 4W6uY248gu2KQGne6412iNoCFe1rdT0E53w9QBfiHsvzM5oaSP+IQ/y1GcaiIWT6eI0W lkuobEos7IF/nBNolFcLiyLY9u3L4Apc7dBknVYa4VQuuL3UF6UKJrX3JzMSU1XdTZFQ kbK3tfZu4nQS+PB3UwPBamGefoY9iFrsiqyzSK3AYFWfQWrw69jzbcYglwwg13gDGyYp VyyA== X-Gm-Message-State: AOAM5318rZKkl6a4V5MMgtPkJDNHFpphkK+D+UMVs6G7zX/lDt77YDpH ucVuSyctEYCU0FIPjnmd1j8= X-Google-Smtp-Source: ABdhPJyiLUB9CREnDan9Lt0qN2xQSrA0ZKo0/wA6ijdE3NbydhMefmzaRSB0HYRFfyfv9Tb/QitibQ== X-Received: by 2002:adf:ab56:: with SMTP id r22mr58273301wrc.351.1609516413101; Fri, 01 Jan 2021 07:53:33 -0800 (PST) Return-Path: Received: from hades (lfbn-idf1-1-101-190.w82-124.abo.wanadoo.fr. [82.124.189.190]) by smtp.gmail.com with ESMTPSA id o124sm18106210wmb.5.2021.01.01.07.53.32 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jan 2021 07:53:32 -0800 (PST) From: telephil9@gmail.com X-Google-Original-From: pme@gmail.com Message-ID: <517CFBCF8E3172A9CDB922A8128A4AE8@gmail.com> To: 9front@9front.org CC: telephil9@gmail.com Date: Fri, 01 Jan 2021 16:53:31 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: open-source database base replication map/reduce-scale wrapper Subject: [9front] [PATCH] libdraw: add bezierpts Reply-To: 9front@9front.org Precedence: bulk Hi, Happy new year to everyone! This patch exposes a new bezierpts function similar to the current bezsplinepts. Note that this merely makes it visible as it was already present in libdraw. === diff -r f020e57da8d6 sys/include/draw.h --- a/sys/include/draw.h Thu Dec 17 20:26:38 2020 -0800 +++ b/sys/include/draw.h Fri Jan 01 16:48:33 2021 +0100 @@ -436,6 +436,7 @@ extern Point stringsubfont(Image*, Point, Image*, Subfont*, char*); extern int bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point); extern int bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop); +extern int bezierpts(Point, Point, Point, Point, Point**); extern int bezspline(Image*, Point*, int, int, int, int, Image*, Point); extern int bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop); extern int bezsplinepts(Point*, int, Point**); diff -r f020e57da8d6 sys/src/libdraw/bezier.c --- a/sys/src/libdraw/bezier.c Thu Dec 17 20:26:38 2020 -0800 +++ b/sys/src/libdraw/bezier.c Fri Jan 01 16:48:33 2021 +0100 @@ -98,12 +98,23 @@ } static void -bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3) +_bezierpts(Plist *l, Point p0, Point p1, Point p2, Point p3) { bpts(l, p0, p1, p2, p3); appendpt(l, p3); } +int +bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp) +{ + Plist l; + l.p = nil; + l.np = 0; + _bezierpts(&l, p0, p1, p2, p3); + *pp = l.p; + return l.np; +} + static void _bezsplinepts(Plist *l, Point *pt, int npt) { @@ -167,7 +178,7 @@ Plist l; l.np = 0; - bezierpts(&l, p0, p1, p2, p3); + _bezierpts(&l, p0, p1, p2, p3); if(l.np == -1) return 0; if(l.np != 0){ @@ -211,7 +222,7 @@ Plist l; l.np = 0; - bezierpts(&l, p0, p1, p2, p3); + _bezierpts(&l, p0, p1, p2, p3); if(l.np == -1) return 0; if(l.np != 0){ === Updated man page: === diff -r f020e57da8d6 sys/man/2/draw --- a/sys/man/2/draw Thu Dec 17 20:26:38 2020 -0800 +++ b/sys/man/2/draw Fri Jan 01 16:49:11 2021 +0100 @@ -103,6 +103,8 @@ int end0, int end1, int radius, Image *src, Point sp, Drawop op) .PB +int bezierpts(Point p0, Point p1, Point p2, Point p3, Point **pp) +.PB int bezspline(Image *dst, Point *pt, int npt, int end0, int end1, int radius, Image *src, Point sp) .PB @@ -603,6 +605,16 @@ in .IR dst . .TP +\f5bezierpts(\f2a\fP, \f2b\fP, \f2c\fP, \f2d\fP, \f2pp\fP) +.I Bezierpts +returns in +.I pp +a list of points making up the open polygon that +.I bezier +would draw. +The caller is responsible for freeing +.IR *pp . +.TP \f5bezspline(\f2dst\fP, \f2p\fP, \f2np\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP) .I Bezspline takes the same arguments as === --phil