承接 nessworthy/decasteljau 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nessworthy/decasteljau

Composer 安装命令:

composer require nessworthy/decasteljau

包简介

A stupid way of using De Casteljau's algorithm to calculate control points of a segment in a cubic bezier curve.

README 文档

README

A stupid way of using De Casteljau's algorithm to calculate control points of a segment in a cubic bezier curve in PHP.

I used this a fair amount when trying to work out segments for SVG paths.

Requirements

  • PHP 7

Installation

composer require nessworthy/decasteljau

Usage

The algorithm requires 6 pieces of information - the original 4 control points of your bezier curve, where you want to cut your segment, and how long you want your segment to be.

Example:

<?php

use Nessworthy\DeCasteljau\CubicBezierCurve;
use Nessworthy\DeCasteljau\Point;

$curve = new CubicBezierCurve(
    new Point(0, 0),    // Your start point.
    new Point(75, 0),   // The first curve point.
    new Point(150, 75), // The second curve point.
    new Point(150, 150) // Your finishing point.
);

// Calculate control points for the third quarter of the original curve.
$curveSegment = $curve->getSegment(0.5, 0.75); // Instance of CubicBezierCurve 

// Useful for calculating SVG bezier paths!
echo 'M' . $curveSegment->getControlPoint1()->x() . ' ' . $curveSegment->getControlPoint1()->y();
echo ' C' . $curveSegment->getControlPoint2()->x() . ' ' . $curveSegment->getControlPoint2()->y();
echo ', ' . $curveSegment->getControlPoint3()->x() . ' ' . $curveSegment->getControlPoint3()->y();
echo ', ' . $curveSegment->getControlPoint4()->x() . ' ' . $curveSegment->getControlPoint4()->y();

License

WTFPL - See LICENSE.md

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2018-07-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固