Giter VIP home page Giter VIP logo

computablerectangle's Introduction

ComputableRectangle

ComputableRectangle is a library thah enables four arithmetic operations on CGRect, CGPoint, CGSize.

Install

Carthage can be used to install.

Add the following line to Cartfile:

github "galapagos/ComputableRectangle"

Usage

Calculating scalar value

It is possible to calculate scalar values CGRect, CGPoint, CGSize.

As a result, the calculation result is applied to all properties.

โ€ป A scalar value refers to a value that can be initialized with CGFloat and CGFloat value.

import ComputableRectangle

(CGRect(x: 1, y: 1, width: 1, height: 1) + 1) == CGRect(x: 2, y: 2, width: 2, height: 2)
(CGPoint(x: 1, y: 1) - 1) == CGPoint.zero
(CGSize(with: 1, height: 1) * 2) == CGSize(with: 2, height: 2)

Caluculating CGPoint value

It is possible to calculate CGPoint values CGRect, CGPoint.

As a result, the calculation result is applied to x and y properties.

import ComputableRectangle

(CGRect(x: 1, y: 1, width: 1, height: 1) + CGPoint(x: 1, y: 2)) == CGRect(x: 2, y: 2, width: 1, height: 1)
(CGPoint(x: 1, y: 1) - CGPoint(x: 1, y: 2)) == CGPoint(x: 0, y: -1)

Calculating CGSize value

It is possible to calculate CGSize values CGRect, CGSize.

As a result, the calculation result is applied to width and height properties.

import ComputableRectangle

(CGRect(x: 1, y: 1, width: 1, height: 1) + CGSize(width: 1, height: 2)) == CGRect(x: 1, y: 1, width: 2, height: 3)
(CGSize(with: 1, height: 1) * CGSize(width: 2, height: 3)) == CGSize(with: 2, height: 3)

Calculating on property

You can perform operations on specific properties.

The value for computation must be initialized with a dedicated type.

import ComputableRectangle

CGRect(x: 1, y: 1, widht: 1, height: 1)
    + OrignX(1)
    - OriginY(2)
    * SizeOfWidht(3)
    / SizeOfHeight(4) // CGRect(x: 2, y: 0, widht: 3, height: 0.25)

computablerectangle's People

Contributors

k-motoyan avatar

Stargazers

Takehito KOSHIMIZU avatar

Watchers

Keishi HOSOBA avatar Galapagos Inc. avatar James Cloos avatar Van Huy avatar  avatar

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.