Skip to content
프로젝트

소개

🔥 de Casteljau 알고리즘으로 1~7차 베지에 곡선을 그리고 애니메이션을 적용합니다

창작 및 미디어

이 수치를 측정하는 방법

What you can do

  • Add and remove control points
  • Bézier curves of order 1 to 7 (limited by screen size; order N is supported in theory)
  • Drag control points freely
  • Show the tangents while the curve is being formed

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

BezierMaker

English | 简体中文

JitPack CI API

Draws Bézier curves with the de Casteljau algorithm, computes their tangents, and animates how Bézier curves of order 1 to 7 are formed. The de Casteljau algorithm computes a point on a Bézier curve, from which the whole curve can be drawn. To learn more about it, see my Chinese translation De Casteljau's Algorithm: Finding a Point on a Bézier Curve.

Download the sample APK

Features

  • Add and remove control points
  • Bézier curves of order 1 to 7 (limited by screen size; order N is supported in theory)
  • Drag control points freely
  • Show the tangents while the curve is being formed
  • Loop the forming animation
  • Adjust the animation rate
  • Show control point coordinates
  • Set the order of the curve

ScreenShot




Usage

Gradle:
  1. Add the JitPack repository to settings.gradle:
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = 'https://jitpack.io' }
    }
}
  1. Add the dependency to your module's build.gradle:
implementation 'com.github.venshine:BezierMaker:2.0.1'
Gradle Kotlin DSL:
// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

// build.gradle.kts
implementation("com.github.venshine:BezierMaker:2.0.1")

Demo

The library is written in Java and can be called directly from both Java and Kotlin. It adds no Kotlin dependency to your project.

XML:
<com.wx.beziermaker.BezierView
    android:id="@+id/bezier"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
Kotlin:
class MainActivity : AppCompatActivity() {
    private lateinit var bezierView: BezierView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        bezierView = findViewById(R.id.bezier)
        bezierView.setRate(10) // animation rate
        bezierView.setTangent(true) // show tangents
        bezierView.setLoop(true) // loop the animation
    }

    fun start(view: View) = bezierView.start()

    fun stop(view: View) = bezierView.stop()

    fun add(view: View) {
        bezierView.addPoint() // add a control point; returns false when the maximum is reached
    }

    fun del(view: View) {
        bezierView.delPoint()
    }
}
Java:
public class MainActivity extends Activity {

    BezierView mBezierView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBezierView = findViewById(R.id.bezier);
    }

    public void start(View view) {
        mBezierView.start();
    }

    public void stop(View view) {
        mBezierView.stop();
    }

    public void add(View view) {
        mBezierView.addPoint();
    }

    public void del(View view) {
        mBezierView.delPoint();
    }

}
Methods:

| method | description | |:--- |:---| | void start() | Start the animation (required) | | void stop() | Stop the animation (optional) | | boolean addPoint() | Add a control point (optional) | | boolean delPoint() | Remove a control point (optional) | | int getOrder() | Get the order of the curve (optional) | | void setRate(int rate) | Set the animation rate (optional) | | void setTangent(boolean tangent) | Show or hide tangents (optional) | | void setLoop(boolean loop) | Loop the animation or not (optional) | | void setOrder(int order) | Set the order of the curve (optional) |

About

License

Copyright (C) 2016 [email protected]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

관련 프로젝트 살펴보기

불러오는 중…