├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── Doxyfile
├── LICENSE
├── README.md
├── RmlabConfig.cmake.in
├── include
└── rmlab
│ ├── Layer.hpp
│ ├── Line.hpp
│ ├── Notebook.cpp
│ ├── Notebook.hpp
│ ├── Page.hpp
│ ├── Point.hpp
│ ├── auxiliary
│ ├── Filesystem.cpp
│ └── Filesystem.hpp
│ ├── renderer
│ ├── lines2png.cpp
│ └── lines2svg.cpp
│ ├── rmlab.hpp
│ ├── tool
│ └── dump.cpp
│ └── writer
│ └── lineDemo.cpp
└── share
└── rmlab
└── examples
├── aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.content
├── aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.metadata
├── aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.pagedata
├── aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails
├── 0.jpg
├── 1.jpg
├── 2.jpg
├── 3.jpg
└── 4.jpg
└── aa90b0e7-5c1a-42fe-930f-dad9cf3363cc
├── 0.rm
├── 1.rm
├── 2.rm
├── 3.rm
└── 4.rm
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 | *.pyc
10 |
11 | # Precompiled Headers
12 | *.gch
13 | *.pch
14 |
15 | # Compiled Dynamic libraries
16 | *.so
17 | *.dylib
18 | *.dll
19 |
20 | # Compiled Static libraries
21 | *.lai
22 | *.la
23 | *.a
24 | *.lib
25 |
26 | # Executables
27 | *.exe
28 | *.out
29 | *.app
30 | bin/*
31 |
32 | # build dir
33 | build/
34 |
35 | # docs dir
36 | docs/
37 |
38 | # temporary files
39 | *~
40 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | sudo: false
4 | dist: trusty
5 |
6 | compiler:
7 | - gcc
8 | - clang
9 |
10 | cache:
11 | apt: true
12 | pip: true
13 |
14 | env:
15 | matrix:
16 | - WITH_PNG=0
17 | - WITH_PNG=1
18 | global:
19 | - CXXFLAGS="-std=c++11 -Wall -Wextra -Wshadow -Werror"
20 |
21 | install:
22 | - if [ $WITH_PNG -eq 1 ]; then
23 | git clone --depth 50 https://github.com/pngwriter/pngwriter.git &&
24 | mkdir pngwriter/build &&
25 | cd pngwriter/build &&
26 | cmake -DCMAKE_INSTALL_PREFIX=/usr .. &&
27 | make &&
28 | sudo make install;
29 | fi
30 |
31 | script:
32 | - mkdir $TRAVIS_BUILD_DIR/build
33 | - cd $TRAVIS_BUILD_DIR/build
34 | - cmake ..
35 | - make
36 | - CTEST_OUTPUT_ON_FAILURE=1 make test
37 | - sudo make install
38 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2017-2019 Axel Huebl
2 | #
3 | # This file is part of lines-are-beautiful.
4 | #
5 | # lines-are-beautiful is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # lines-are-beautiful is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with lines-are-beautiful.
17 | # If not, see .
18 |
19 | # Preamble ####################################################################
20 | #
21 |
22 | cmake_minimum_required(VERSION 3.7)
23 |
24 | project(Rmlab VERSION 0.1.0 LANGUAGES CXX)
25 |
26 |
27 | ################################################################################
28 | # CMake policies
29 | #
30 | # Search in _ROOT:
31 | # https://cmake.org/cmake/help/v3.12/policy/CMP0074.html
32 |
33 | if(POLICY CMP0074)
34 | cmake_policy(SET CMP0074 NEW)
35 | endif()
36 |
37 |
38 | # Options and Variants ########################################################
39 | #
40 | function(rmlab_option name description default)
41 | set(Rmlab_USE_${name} ${default} CACHE STRING "${description}")
42 | set_property(CACHE Rmlab_USE_${name} PROPERTY
43 | STRINGS "ON;TRUE;AUTO;OFF;FALSE"
44 | )
45 | if(Rmlab_HAVE_${name})
46 | set(Rmlab_HAVE_${name} TRUE)
47 | else()
48 | set(Rmlab_HAVE_${name})
49 | endif()
50 | set(Rmlab_CONFIG_OPTIONS ${Rmlab_CONFIG_OPTIONS} ${name} PARENT_SCOPE)
51 | endfunction()
52 |
53 | rmlab_option(PNG "Enable support for PNG conversion" AUTO)
54 |
55 | # TODO: add defines via configure to installed header files
56 |
57 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
58 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING
59 | "Choose the build type, e.g. Debug." FORCE)
60 | endif()
61 |
62 |
63 | # Dependencies ################################################################
64 | #
65 | if(Rmlab_USE_PNG STREQUAL AUTO)
66 | find_package(PNGwriter 0.7.0 CONFIG)
67 | elseif(Rmlab_USE_PNG)
68 | find_package(PNGwriter 0.7.0 REQUIRED CONFIG)
69 | endif()
70 |
71 | if(PNGwriter_FOUND)
72 | set(Rmlab_HAVE_PNG TRUE)
73 | endif()
74 |
75 |
76 | # Targets #####################################################################
77 | #
78 |
79 | # libraries
80 | add_library(Rmlab
81 | include/rmlab/Notebook.cpp
82 | include/rmlab/auxiliary/Filesystem.cpp
83 | )
84 | add_library(Rmlab::Rmlab ALIAS Rmlab)
85 |
86 | if(NOT WIN32)
87 | target_link_libraries(Rmlab PRIVATE m)
88 | endif()
89 | target_include_directories(Rmlab PUBLIC
90 | $
91 | $
92 | $
93 | )
94 | target_compile_features(Rmlab PUBLIC cxx_std_11)
95 |
96 | # CLI tools / executables
97 | add_executable(lineDemo
98 | include/rmlab/writer/lineDemo.cpp
99 | )
100 | target_compile_features(lineDemo PUBLIC cxx_std_11)
101 | target_link_libraries(lineDemo PRIVATE
102 | Rmlab
103 | )
104 | set(Rmlab_EXTRA_TARGETS lineDemo)
105 | if(Rmlab_HAVE_PNG)
106 | add_executable(lines2png
107 | include/rmlab/renderer/lines2png.cpp
108 | )
109 |
110 | target_compile_features(lines2png PUBLIC cxx_std_11)
111 | target_link_libraries(lines2png PRIVATE
112 | Rmlab
113 | PNGwriter::PNGwriter
114 | )
115 |
116 | set(Rmlab_EXTRA_TARGETS lines2png)
117 | else()
118 | message(STATUS "PNGwriter NOT found! lines2png will not be build!")
119 | endif()
120 |
121 | add_executable(lines2svg
122 | include/rmlab/renderer/lines2svg.cpp
123 | )
124 |
125 | target_compile_features(lines2svg PUBLIC cxx_std_11)
126 | target_link_libraries(lines2svg PRIVATE Rmlab)
127 | list(APPEND Rmlab_EXTRA_TARGETS lines2svg)
128 |
129 | add_executable(dump
130 | include/rmlab/tool/dump.cpp
131 | )
132 | target_compile_features(dump PUBLIC cxx_std_11)
133 | target_link_libraries(dump PRIVATE Rmlab)
134 | list(APPEND Rmlab_EXTRA_TARGETS dump)
135 |
136 | # Generate Files with Configuration Options ###################################
137 | #
138 | configure_file(
139 | ${Rmlab_SOURCE_DIR}/RmlabConfig.cmake.in
140 | ${Rmlab_BINARY_DIR}/RmlabConfig.cmake
141 | @ONLY
142 | )
143 |
144 | include(CMakePackageConfigHelpers)
145 | write_basic_package_version_file("RmlabConfigVersion.cmake"
146 | VERSION ${Rmlab_VERSION}
147 | COMPATIBILITY SameMajorVersion
148 | )
149 |
150 |
151 | # Installs ####################################################################
152 | #
153 | # headers, libraries and exectuables
154 | install(TARGETS Rmlab ${Rmlab_EXTRA_TARGETS} EXPORT RmlabTargets
155 | LIBRARY DESTINATION lib
156 | ARCHIVE DESTINATION lib
157 | RUNTIME DESTINATION bin
158 | INCLUDES DESTINATION include
159 | )
160 | install(
161 | DIRECTORY include/
162 | DESTINATION include
163 | )
164 | # CMake package file for find_package(Rmlab::Rmlab) in depending projects
165 | install(EXPORT RmlabTargets
166 | FILE RmlabTargets.cmake
167 | NAMESPACE Rmlab::
168 | DESTINATION lib/cmake/Rmlab
169 | )
170 | install(
171 | FILES
172 | ${Rmlab_BINARY_DIR}/RmlabConfig.cmake
173 | ${Rmlab_BINARY_DIR}/RmlabConfigVersion.cmake
174 | DESTINATION lib/cmake/Rmlab
175 | )
176 |
177 |
178 | # Packages ####################################################################
179 | #
180 | # TODO (in separate file that is included)
181 |
182 |
183 | # Tests #######################################################################
184 | #
185 | enable_testing()
186 | if(Rmlab_HAVE_PNG)
187 | add_test(NAME Convert.PNG
188 | COMMAND lines2png
189 | ${Rmlab_SOURCE_DIR}/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc
190 | )
191 | endif()
192 | add_test(NAME Convert.SVG
193 | COMMAND lines2svg
194 | ${Rmlab_SOURCE_DIR}/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc
195 | )
196 | add_test(NAME Convert.Dump
197 | COMMAND dump
198 | ${Rmlab_SOURCE_DIR}/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc
199 | )
200 |
201 | # Status Message for Build Options ############################################
202 | #
203 | message("")
204 | message("Rmlab build configuration:")
205 | message(" Rmlab Version: ${Rmlab_VERSION}")
206 | message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
207 | "${CMAKE_CXX_COMPILER_VERSION} "
208 | "${CMAKE_CXX_COMPILER_WRAPPER}")
209 | message(" ${CMAKE_CXX_COMPILER}")
210 | message("")
211 | message(" Installation prefix: ${CMAKE_INSTALL_PREFIX}")
212 | message("")
213 | message(" Build Type: ${CMAKE_BUILD_TYPE}")
214 | message(" Build Options:")
215 |
216 | foreach(opt IN LISTS Rmlab_CONFIG_OPTIONS)
217 | if(${Rmlab_HAVE_${opt}})
218 | message(" ${opt}: ON")
219 | else()
220 | message(" ${opt}: OFF")
221 | endif()
222 | endforeach()
223 | message("")
224 |
--------------------------------------------------------------------------------
/Doxyfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = lines-are-beautiful
2 | PROJECT_NUMBER = 0.0
3 | PROJECT_BRIEF = "A C++ file API for the reMarkable e-ink tablet"
4 |
5 | INPUT = include/rmlab
6 |
7 | OUTPUT_DIRECTORY = docs
8 | RECURSIVE = YES
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Lines Are Beautiful
2 |
3 | [](https://travis-ci.org/ax3l/lines-are-beautiful/branches)
4 | [](https://ax3l.github.io/lines-are-beautiful/)
5 | [](http://rmlab.readthedocs.io)
6 | [](https://isocpp.org)
7 | [](https://www.gnu.org/licenses/gpl-3.0.html)
8 |
9 | A C++ file API for the [reMarkable e-ink tablet](https://remarkable.com).
10 |
11 | **Warning:** The libraries and tools in this project are not (yet) hardened for malicious input.
12 | Only process files that you can trust with it!
13 |
14 | ## Dependencies
15 |
16 | - A C++11 capable compiler such as
17 | - GCC 4.8+ (tested)
18 | - Clang 3.9+ (tested)
19 | - CMake 3.7+
20 | - [PNGwriter 0.7.0+](https://github.com/pngwriter/pngwriter)
21 | (optional for png converts; extend environment variable `CMAKE_PREFIX_PATH` with its install location)
22 |
23 | ## Install
24 |
25 | [](https://spack.io)
26 | [](https://conan.io)
27 | [](https://conda.io)
28 | [](https://docker.io)
29 |
30 | ### Spack
31 |
32 | ```bash
33 | spack install rmlab
34 | spack load rmlab
35 | ```
36 |
37 | ### From Source
38 |
39 | If one of the popular user-level package managers above is not already satisfying your needs, install from source via:
40 |
41 | ```bash
42 | git clone https://github.com/ax3l/lines-are-beautiful.git
43 |
44 | mkdir lines-are-beautiful/build
45 | cd lines-are-beautiful/build
46 |
47 | # for own install prefix append: -DCMAKE_INSTALL_PREFIX=$HOME/somepath
48 | cmake ..
49 |
50 | make -j
51 |
52 | # optional
53 | make test
54 |
55 | # sudo is only required for system paths
56 | sudo make install
57 | ```
58 |
59 | ## Usage CLI
60 |
61 | _Lines Are Beautiful_ comes with several tools to handle files produced by the tablet.
62 | Try them on your own files inside `$HOME/.local/share/remarkable/xochitl/` :-)
63 |
64 | ### PNG renderer
65 |
66 | This is a small example implementing a renderer for PNG while changing the brush type.
67 |
68 | ```bash
69 | # path to the directory containing the notebook
70 | lines2png share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc
71 | # creates files "test-0.png", "test-1.png", ... per page in the current directory
72 | ```
73 |
74 | Note: this tool depends on an installed [PNGwriter](https://github.com/pngwriter/pngwriter) dependency.
75 |
76 | ### SVG renderer
77 |
78 | This notebook renderer creates a set of SVG files, one for each page. Implementation status:
79 |
80 | * [x] Basic strokes.
81 | * [x] Initial brush size.
82 | * [x] Brush color.
83 | * [x] Highlighter.
84 | * [x] Normal eraser.
85 | * [x] Region eraser.
86 | * [x] Layers.
87 | * [ ] Brush size variation based on pressure/tilt.
88 | * [ ] Brush texture.
89 |
90 | ```bash
91 | # path to the directory containing the notebook
92 | lines2svg share/rmlab/examples/e09e6bd4-3647-41e7-98be-b9c3b53d80c8
93 | # creates files "test-0.svg", "test-1.svg", ... per page in the current directory
94 | ```
95 |
96 | ## Usage API
97 |
98 | Set environment hints:
99 | ```bash
100 | # optional: only needed if installed outside of system paths
101 | export CMAKE_PREFIX_PATH=/your/path/to/installed/path:$CMAKE_PREFIX_PATH
102 | ```
103 |
104 | Add to your `CMakeLists.txt`:
105 | ```cmake
106 | # supports: COMPONENTS PNG
107 | find_package(Rmlab 0.1.0 CONFIG)
108 |
109 | target_link_libraries(YourTarget PRIVATE Rmlab::Rmlab)
110 | ```
111 |
112 | *Alternatively*, add whole repository directly to your project and add it via:
113 | ```cmake
114 | add_subdirectory("path/to/source/of/lines-are-beautiful")
115 |
116 | target_link_libraries(YourTarget PRIVATE Rmlab::Rmlab)
117 | ```
118 |
119 | In your C++ files (see [Doxygen](https://ax3l.github.io/lines-are-beautiful/)):
120 | ```C++
121 | #include
122 | #include
123 |
124 | // ...
125 |
126 | rmlab::Notebook myNotebook("share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc");
127 |
128 | for( auto & page : myNotebook.pages )
129 | for( auto & layer : page.layers )
130 | for( auto & line : layer.lines )
131 | for( auto & point : line.points )
132 | std::cout << point.x << " " << point.y << std::endl;
133 | ```
134 |
135 | ## Resources
136 |
137 | ### Blog Articles, Talks
138 |
139 | - [general](https://plasma.ninja/blog/devices/remarkable/2017/12/18/reMarkable-exporation.html)
140 | - [file format](https://plasma.ninja/blog/devices/remarkable/binary/format/2017/12/26/reMarkable-lines-file-format.html)
141 | - 5' talk at *34C3* [en]:
142 | - [slides](https://plasma.ninja/34c3/reMarkable_binary_format.pdf)
143 | - [video](https://media.ccc.de/v/34c3-9257-lightning_talks_day_3#t=1405) (around minute 23+)
144 | - talk at *Datenspuren 2018* [de]:
145 | - [slides](https://plasma.ninja/ds18/reMarkable_binary_format_ds18.pdf)
146 | - [video](https://media.ccc.de/v/DS2018-9324-freeing_the_binary_format_of_the_remarkable_e-ink_tablet)
147 |
148 | ### Experimental Implementation in Rust
149 |
150 | - every C++ programmer likes to learn Rust: [lines-are-rusty](https://github.com/ax3l/lines-are-rusty)
151 |
152 | ## Disclaimer
153 |
154 | This is a hobby project.
155 |
156 | The author(s) and contributor(s) are not associated with reMarkable AS, Norway.
157 | **reMarkable** is a registered trademark of *reMarkable AS* in some countries.
158 | Please see https://remarkable.com for their product.
159 |
--------------------------------------------------------------------------------
/RmlabConfig.cmake.in:
--------------------------------------------------------------------------------
1 | # only add PUBLIC dependencies as well
2 | # https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-a-package-configuration-file
3 | include(CMakeFindDependencyMacro)
4 |
5 | # Search in _ROOT:
6 | # https://cmake.org/cmake/help/v3.12/policy/CMP0074.html
7 | if(POLICY CMP0074)
8 | cmake_policy(SET CMP0074 NEW)
9 | endif()
10 |
11 | set(Rmlab_HAVE_PNG @Rmlab_HAVE_PNG@)
12 | if(Rmlab_HAVE_PNG)
13 | find_dependency(PNGwriter)
14 | endif()
15 | set(Rmlab_PNG_FOUND ${Rmlab_HAVE_PNG})
16 |
17 | include("${CMAKE_CURRENT_LIST_DIR}/RmlabTargets.cmake")
18 |
19 | # check if components are fulfilled and set Rmlab__FOUND vars
20 | foreach(comp ${Rmlab_FIND_COMPONENTS})
21 | if(NOT Rmlab_${comp}_FOUND)
22 | if(Rmlab_FIND_REQUIRED_${comp})
23 | set(Rmlab_FOUND FALSE)
24 | endif()
25 | endif()
26 | endforeach()
27 |
--------------------------------------------------------------------------------
/include/rmlab/Layer.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @file
22 | * Definition of layers.
23 | */
24 |
25 | #pragma once
26 |
27 | #include "Line.hpp"
28 |
29 | #include // int8_t - int64_t
30 | #include
31 |
32 |
33 | namespace rmlab
34 | {
35 | /**
36 | * Element of a page, containing a set of lines.
37 | *
38 | * When inside the same layer, a line A is rendered above another line B
39 | * if and only if it A comes after B in the layer order.
40 | *
41 | * @see rmlab::Page
42 | * @see rmlab::Line
43 | */
44 | struct Layer
45 | {
46 | /**
47 | * Number of lines in this layer.
48 | */
49 | int32_t nlines;
50 |
51 | /**
52 | * All lines contained in this layer, in the order they were drawn.
53 | */
54 | std::list< Line > lines;
55 | };
56 |
57 | inline Layer make_layer( std::list< Line > lines = std::list< Line >{} )
58 | {
59 | Layer newLayer;
60 | newLayer.nlines = lines.size();
61 | newLayer.lines = lines;
62 |
63 | return newLayer;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/include/rmlab/Line.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @file
22 | * Definition of lines and of the magic numbers that encode their attributes.
23 | */
24 |
25 | #pragma once
26 |
27 | #include "Point.hpp"
28 |
29 | #include // int8_t - int64_t
30 | #include
31 |
32 |
33 | namespace rmlab
34 | {
35 | /**
36 | * Types of brushes.
37 | *
38 | * Each brush defines the texture and sensitivity of strokes that are applied
39 | * to the canvas when the pen is used. Brush type can be selected using the
40 | * GUI. There is exactly one brush type associated with each line.
41 | *
42 | * | Brush Type | Pressure | Speed | Tilt |
43 | * | ------------- |:---------:|:---------:|:---------:|
44 | * | Ballpoint pen | X | | |
45 | * | Marker pen | X | | X |
46 | * | Fineliner pen | | | |
47 | * | Sharp pencil | | | |
48 | * | Tilt pencil | X | | X |
49 | * | Brush | X | X | X |
50 | *
51 | * Refer to for a visual overview
52 | * of the differences between the brush types.
53 | */
54 | namespace Brushes
55 | {
56 | enum Brushes
57 | {
58 | /**
59 | * Ballpoint pen.
60 | *
61 | * GUI: 1-1
62 | */
63 | pen1 = 2u,
64 |
65 | /**
66 | * Marker pen.
67 | *
68 | * GUI: 1-2
69 | */
70 | pen2 = 3u,
71 |
72 | /**
73 | * Fineliner pen.
74 | *
75 | * GUI: 1-3
76 | */
77 | fineliner = 4u,
78 |
79 | /**
80 | * Sharp pencil.
81 | *
82 | * GUI: 2-1
83 | */
84 | pencil_sharp = 7u,
85 |
86 | /**
87 | * Tilt pencil.
88 | *
89 | * GUI: 2-2
90 | */
91 | pencil_tilt = 1u,
92 |
93 | /**
94 | * Paintbrush.
95 | *
96 | * GUI: 3
97 | */
98 | brush = 0u,
99 |
100 | /**
101 | * Highlighter.
102 | *
103 | * GUI: 4
104 | * (always color 0)
105 | */
106 | highlighter = 5u,
107 |
108 | /**
109 | * Eraser.
110 | *
111 | * GUI: 5-1
112 | */
113 | rubber = 6u,
114 |
115 | /**
116 | * not in GUI
117 | */
118 | unknown_brush = 7u,
119 |
120 | /**
121 | * Erase selection.
122 | *
123 | * GUI: 5-2
124 | */
125 | rubber_area = 8u,
126 |
127 | /**
128 | * Erase page.
129 | *
130 | * GUI: 5-3
131 | */
132 | erase_all = 9u,
133 |
134 | /**
135 | * Selection brush
136 | *
137 | * not in GUI
138 | */
139 | selection_brush1 = 10u,
140 |
141 | /**
142 | * Selection brush
143 | *
144 | * not in GUI
145 | */
146 | selection_brush2 = 11u,
147 |
148 | /**
149 | * Fine line
150 | *
151 | * not in GUI
152 | */
153 | fine_line1 = 12u,
154 | fine_line2 = 13u,
155 | fine_line3 = 14u
156 | };
157 | }
158 |
159 | /**
160 | * Shades of grey.
161 | *
162 | * Defines the color of the brush used for a line. As the reMarkable uses a
163 | * E Ink display, it only handles shades of grey (no colors). There is
164 | * exactly one color selected for each line.
165 | */
166 | namespace Colors
167 | {
168 | enum Colors
169 | {
170 | /**
171 | * Black color.
172 | */
173 | black = 0u,
174 |
175 | /**
176 | * Grey color.
177 | */
178 | grey = 1u,
179 |
180 | /**
181 | * White color.
182 | */
183 | white = 2u
184 | };
185 | }
186 |
187 | /**
188 | * Base brush sizes.
189 | *
190 | * Defines the base width of the brush used for a line, in pixel units. This
191 | * size can be further affected by the pressure and tilt parameters, for
192 | * brushes that support it.
193 | */
194 | namespace BaseSizes
195 | {
196 | /**
197 | * Small size.
198 | */
199 | constexpr float small = 1.875;
200 |
201 | /**
202 | * Medium size.
203 | */
204 | constexpr float mid = 2.0;
205 |
206 | /**
207 | * Large size.
208 | */
209 | constexpr float large = 2.125;
210 | }
211 |
212 | /**
213 | * Element of a layer, containing a set of points resulting from
214 | * a single brush stroke.
215 | *
216 | * @see rmlab::Layer
217 | * @see rmlab::Point
218 | */
219 | struct Line
220 | {
221 | /**
222 | * Kind of brush that was selected while drawing the line.
223 | * @see rmlab::Brushes
224 | */
225 | int32_t brush_type;
226 |
227 | /**
228 | * Color of the brush as selected while drawing the line.
229 | * @see rmlab::Colors
230 | */
231 | int32_t color;
232 |
233 | /**
234 | * Attribute whose purpose is still unknown.
235 | */
236 | int32_t unknown_line_attribute;
237 |
238 | /**
239 | * Base size of the brush as selected while drawing the line.
240 | * @see rmlab::BaseSizes
241 | */
242 | float brush_base_size;
243 |
244 | /**
245 | * Number of points in this line.
246 | */
247 | int32_t npoints;
248 |
249 | /**
250 | * All points contained in this line, in the order they were drawn.
251 | */
252 | std::list< Point > points;
253 | };
254 |
255 | inline Line make_line(
256 | int32_t brush_type = 1,
257 | int32_t color = 0,
258 | int32_t unknown_line_attribute = 0,
259 | float brush_base_size = 2.125,
260 | std::list< Point > points = std::list< Point >{}
261 | )
262 | {
263 | Line newLine;
264 | newLine.brush_type = brush_type;
265 | newLine.color = color;
266 | newLine.unknown_line_attribute = unknown_line_attribute;
267 | newLine.brush_base_size = brush_base_size;
268 | newLine.npoints = points.size();
269 | newLine.points = points;
270 |
271 | return newLine;
272 | }
273 | }
274 |
--------------------------------------------------------------------------------
/include/rmlab/Notebook.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | #include "Notebook.hpp"
21 | #include "Page.hpp"
22 | #include "Layer.hpp"
23 | #include "Line.hpp"
24 | #include "Point.hpp"
25 | #include "rmlab/auxiliary/Filesystem.hpp"
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 |
33 | namespace rmlab
34 | {
35 | namespace detail
36 | {
37 | void
38 | readPoint(
39 | std::ifstream& fstream,
40 | Line& curLine
41 | )
42 | {
43 | Point curPoint;
44 |
45 | fstream.read( (char*)&curPoint.x, sizeof(float) );
46 | fstream.read( (char*)&curPoint.y, sizeof(float) );
47 |
48 | fstream.read( (char*)&curPoint.speed, sizeof(float) );
49 | fstream.read( (char*)&curPoint.direction, sizeof(float) );
50 | fstream.read( (char*)&curPoint.width, sizeof(float) );
51 |
52 | // pressure and rotation of the pen to page normal
53 | // rotation: for centrially symmetric brushes as now, one attribute
54 | // would be sufficient,
55 | // let's add a flat nib, calligraphic pen as conversion target! :)
56 | // range [0.0:1.0]
57 | fstream.read( (char*)&curPoint.pressure, sizeof(float) );
58 |
59 | curLine.points.emplace_back( curPoint );
60 | }
61 |
62 | void
63 | readLine(
64 | std::ifstream& fstream,
65 | Layer& curLayer
66 | )
67 | {
68 | Line curLine;
69 |
70 | // select 1-1: 2 (pen)
71 | // select 1-2: 3 (pen)
72 | // select 1-3: 4 (fine liner)
73 | // select 2-1: 7 (pencil sharp)
74 | // select 2-2: 1 (pencil wide)
75 | // select 3: 0 (brush)
76 | // select 4: 5 (marker/highlighter: always color 0)
77 | // what is/was 6? :-)
78 | fstream.read( (char*)&curLine.brush_type, sizeof(int32_t) );
79 |
80 | // color (0: black, 1: grey, 2: white)
81 | fstream.read( (char*)&curLine.color, sizeof(int32_t) );
82 |
83 | // unknown 4 Byte (int32_t?), always zero?
84 | // non-stored information about "selected" lines?
85 | fstream.read( (char*)&curLine.unknown_line_attribute, sizeof(int32_t) );
86 |
87 | // brush base size: 1.875, 2.0, 2.125
88 | fstream.read( (char*)&curLine.brush_base_size, sizeof(float) );
89 | fstream.read( (char*)&curLine.npoints, sizeof(int32_t) );
90 |
91 | for( int n = 0; n < curLine.npoints; ++n )
92 | {
93 | readPoint( fstream, curLine );
94 | }
95 |
96 | curLayer.lines.emplace_back( curLine );
97 | }
98 |
99 | void
100 | readLayer(
101 | std::ifstream& fstream,
102 | Page& curPage
103 | )
104 | {
105 | Layer curLayer;
106 | fstream.read( (char*)&curLayer.nlines, sizeof(int32_t) );
107 |
108 | for( int nl = 0; nl < curLayer.nlines; ++nl )
109 | {
110 | readLine( fstream, curLayer );
111 | }
112 |
113 | curPage.layers.emplace_back( curLayer );
114 | }
115 | }
116 |
117 | Notebook::Notebook( std::string const openPathUUID ) :
118 | version(3), npages( 0 ), pathUUID( openPathUUID )
119 | {
120 | // append directory_separator if missing
121 | std::string const sep( &auxiliary::directory_separator, 1 );
122 | if( pathUUID.compare( pathUUID.size() - 1u, 1, sep) != 0 )
123 | pathUUID.append(sep);
124 |
125 | if( ! auxiliary::directory_exists( pathUUID ) )
126 | {
127 | std::cerr << "Path '" << pathUUID
128 | << "' not found or not accessible!\n";
129 | return;
130 | }
131 |
132 | auto lsPath = auxiliary::list_directory( pathUUID );
133 | for( auto& lsEntry: lsPath )
134 | {
135 | if( lsEntry.compare( lsEntry.size() - 3u, 3u, ".rm") != 0 )
136 | continue;
137 |
138 | npages += 1;
139 | }
140 |
141 | if( npages == 0 )
142 | {
143 | std::cerr << "No pages found in '" << openPathUUID
144 | << "'!\n";
145 | return;
146 | }
147 |
148 | for( int p = 0; p < npages; ++p )
149 | {
150 | std::string fullname = pathUUID + std::to_string(p) + std::string(".rm");
151 | std::ifstream fstream( fullname, std::ios::binary | std::ifstream::in );
152 | if( !fstream.good() )
153 | {
154 | std::cerr << "File '" << fullname
155 | << "' not found or not accessible!\n";
156 | return;
157 | }
158 |
159 | // skip header
160 | fstream.seekg( 32, fstream.beg );
161 |
162 | // version
163 | char str_version;
164 | fstream.read( &str_version, sizeof(char) );
165 | version = std::atoi( &str_version );
166 | if( version != 3 )
167 | std::cerr << "WARNING: Unknown version!\n";
168 |
169 | // skip 10x space padding
170 | fstream.seekg( 10, fstream.cur );
171 |
172 | // layers
173 | Page curPage;
174 | fstream.read( (char*)&curPage.nlayers, sizeof(int32_t) );
175 |
176 | for( int nlay = 0; nlay < curPage.nlayers; ++nlay )
177 | {
178 | detail::readLayer( fstream, curPage );
179 | }
180 |
181 | fstream.close();
182 |
183 | pages.emplace_back( curPage );
184 | }
185 |
186 | }
187 |
188 | Notebook::Notebook() :
189 | npages( 0 )
190 | {
191 | }
192 |
193 | Notebook::~Notebook()
194 | {
195 | }
196 |
197 | void Notebook::save( std::string const path )
198 | {
199 | // append directory_separator if missing
200 | std::string rmPath = path;
201 | std::string const sep( &auxiliary::directory_separator, 1 );
202 | if( rmPath.compare( rmPath.size() - 1u, 1, sep) != 0 )
203 | rmPath.append(sep);
204 |
205 | bool pathReady = true;
206 | if( ! auxiliary::directory_exists( rmPath ) )
207 | pathReady = auxiliary::create_directories( rmPath );
208 |
209 | if( !pathReady )
210 | {
211 | std::cerr << "Path '" << path
212 | << "' not accessible!\n";
213 | return;
214 | }
215 |
216 | int p = 0;
217 | for( auto & page : pages )
218 | {
219 | std::string fullname = rmPath + std::to_string(p) + std::string(".rm");
220 | std::ofstream fstream(
221 | fullname,
222 | std::fstream::out | std::ios::binary
223 | );
224 |
225 | if( !fstream.good() )
226 | {
227 | std::cerr << "File '" << fullname
228 | << "' not accessible!\n";
229 | return;
230 | }
231 |
232 | // write header (33 bytes)
233 | fstream.write( "reMarkable .lines file, version=3", 33 );
234 |
235 | // write space padding
236 | fstream.write( " ", 10 );
237 |
238 | // layers
239 | int32_t nlayers = page.layers.size();
240 | fstream.write( (char*)&nlayers, sizeof(int32_t) );
241 | for( auto & layer : page.layers )
242 | {
243 | // lines
244 | int32_t nlines = layer.lines.size();
245 | fstream.write( (char*)&nlines, sizeof(int32_t) );
246 | for( auto & line : layer.lines )
247 | {
248 | int32_t brush_type = line.brush_type;
249 | fstream.write( (char*)&brush_type, sizeof(int32_t) );
250 |
251 | int32_t color = line.color;
252 | fstream.write( (char*)&color, sizeof(int32_t) );
253 |
254 | int32_t unknown_line_attribute = line.unknown_line_attribute;
255 | fstream.write( (char*)&unknown_line_attribute, sizeof(int32_t) );
256 |
257 | float brush_base_size = line.brush_base_size;
258 | fstream.write( (char*)&brush_base_size, sizeof(float) );
259 |
260 | // points
261 | int32_t npoints = line.points.size();
262 | fstream.write( (char*)&npoints, sizeof(int32_t) );
263 | for( auto & point : line.points )
264 | {
265 | fstream.write( (char*)&point.x, sizeof(float) );
266 | fstream.write( (char*)&point.y, sizeof(float) );
267 |
268 | fstream.write( (char*)&point.speed, sizeof(float) );
269 | fstream.write( (char*)&point.direction, sizeof(float) );
270 | fstream.write( (char*)&point.width, sizeof(float) );
271 | fstream.write( (char*)&point.pressure, sizeof(float) );
272 | }
273 | }
274 | }
275 |
276 | fstream.close();
277 | p++;
278 | }
279 | }
280 | }
281 |
282 |
--------------------------------------------------------------------------------
/include/rmlab/Notebook.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @file
22 | * Definition of notebooks.
23 | */
24 |
25 | #pragma once
26 |
27 | #include // int8_t - int64_t
28 | #include
29 | #include
30 |
31 | #include "Page.hpp"
32 |
33 |
34 | namespace rmlab
35 | {
36 | /**
37 | * Base unit of the reMarkable note-taking system, used similarly
38 | * to a real-world notebook. It is made up of a set of pages.
39 | *
40 | * @see rmlab::Page
41 | */
42 | struct Notebook
43 | {
44 | /**
45 | * Version of the file format in this notebook.
46 | */
47 | int32_t version;
48 |
49 | /**
50 | * Number of pages in this notebook.
51 | */
52 | int32_t npages;
53 |
54 | /**
55 | * Path ending in a uuid directory containing the notebook
56 | */
57 | std::string pathUUID;
58 |
59 | /**
60 | * All the pages of this notebook.
61 | */
62 | std::list< Page > pages;
63 |
64 | /**
65 | * Open a new, empty notebook.
66 | */
67 | Notebook();
68 |
69 | /**
70 | * Open a notebook.
71 | *
72 | * @param openPathUUID path to the UUID-named directory containing the notebook.
73 | */
74 | Notebook( std::string const openPathUUID );
75 | ~Notebook();
76 |
77 | void save( std::string const path );
78 | };
79 | }
80 |
--------------------------------------------------------------------------------
/include/rmlab/Page.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @file
22 | * Definition of pages.
23 | */
24 |
25 | #pragma once
26 |
27 | #include "Layer.hpp"
28 |
29 | #include // int8_t - int64_t
30 | #include
31 |
32 |
33 | namespace rmlab
34 | {
35 | /**
36 | * Element of a notebook, containing a stack of layers.
37 | *
38 | * The layers at the top of the stack (or at the end of the list) are
39 | * rendered last, meaning that they will appear above others.
40 | *
41 | * @see rmlab::Notebook
42 | * @see rmlab::Layer
43 | */
44 | struct Page
45 | {
46 | /**
47 | * Number of layers in this page.
48 | */
49 | int32_t nlayers;
50 |
51 | /**
52 | * All the layers of this page, from the bottom to the top of the
53 | * layer stack.
54 | */
55 | std::list< Layer > layers;
56 | };
57 |
58 | inline Page make_page( std::list< Layer > layers = std::list< Layer >{} )
59 | {
60 | Page newPage;
61 | newPage.nlayers = layers.size();
62 | newPage.layers = layers;
63 |
64 | return newPage;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/include/rmlab/Point.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @file
22 | * Definition of points and of the magic numbers that encode their attributes.
23 | */
24 |
25 | #pragma once
26 |
27 | #include
28 |
29 |
30 | namespace rmlab
31 | {
32 | namespace ranges
33 | {
34 | /**
35 | * Rectangle in which the points are located.
36 | */
37 | enum Coords
38 | {
39 | /**
40 | * Minimum value of the X coordinate, or X coordinate
41 | * of the left-side of the bounding rectangle.
42 | */
43 | minX = 0u,
44 |
45 | /**
46 | * Maximum value of the X coordinate, or X coordinate
47 | * of the right-side of the bounding rectangle.
48 | */
49 | maxX = 1404u,
50 |
51 | /**
52 | * Minimum value of the Y coordinate, or Y coordinate
53 | * of the upper-side of the bounding rectangle.
54 | */
55 | minY = 0u,
56 |
57 | /**
58 | * Maximum value of the Y coordinate, or Y coordinate
59 | * of the bottom-side of the bounding rectangle.
60 | */
61 | maxY = 1872u,
62 | };
63 |
64 | /**
65 | * Minimum pressure value.
66 | */
67 | constexpr float minP = 0.0;
68 |
69 | /**
70 | * Maximum pressure value.
71 | */
72 | constexpr float maxP = 1.0;
73 |
74 | /**
75 | * Minimum direction value of the pen, in radians.
76 | */
77 | constexpr float minDir = 0.0;
78 |
79 | /**
80 | * Maximum rotation value of the pen, in radians.
81 | */
82 | constexpr float maxDir = M_PI * 2.0;
83 | }
84 |
85 | /**
86 | * Element of a line. A line is made up of a sequence of points
87 | * sampled at a constant interval.
88 | */
89 | struct Point
90 | {
91 | /**
92 | * Position on the X-axis, relative to the upper-left corner
93 | * of the device’s screen. This value is expressed in pixels
94 | * and is comprised between rmlab::ranges::Coords::minX and
95 | * rmlab::ranges::Coords::maxX.
96 | */
97 | float x;
98 |
99 | /**
100 | * Position on the Y-axis, relative to the upper-left corner
101 | * of the device’s screen. This value is expressed in pixels
102 | * and is comprised between rmlab::ranges::Coords::minY and
103 | * rmlab::ranges::Coords::maxY.
104 | */
105 | float y;
106 |
107 | /**
108 | * Speed
109 | */
110 | float speed;
111 |
112 | /**
113 | * Direction
114 | * Range likely between rmlab::ranges::Coords::minDir and
115 | * rmlab::ranges::Coords::maxDir.
116 | */
117 | float direction;
118 |
119 | /**
120 | * Width
121 | */
122 | float width;
123 |
124 | /**
125 | * Pressure that was being applied on the screen with the pen when
126 | * this point was sampled. This value is comprised between
127 | * rmlab::ranges::minP and rmlab::ranges::maxP.
128 | */
129 | float pressure;
130 | };
131 |
132 | inline Point make_point(
133 | float x,
134 | float y,
135 | float speed,
136 | float direction,
137 | float width,
138 | float pressure
139 | )
140 | {
141 | Point newPoint;
142 | newPoint.x = x;
143 | newPoint.y = y;
144 | newPoint.speed = speed;
145 | newPoint.direction = direction;
146 | newPoint.width = width;
147 | newPoint.pressure = pressure;
148 | return newPoint;
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/include/rmlab/auxiliary/Filesystem.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2018-2019 Fabian Koller
2 | *
3 | * This file is part of openPMD-api.
4 | *
5 | * openPMD-api is free software: you can redistribute it and/or modify
6 | * it under the terms of of either the GNU General Public License or
7 | * the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * openPMD-api is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License and the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * and the GNU Lesser General Public License along with openPMD-api.
19 | * If not, see .
20 | */
21 | #include "rmlab/auxiliary/Filesystem.hpp"
22 |
23 | #ifdef _WIN32
24 | # include
25 | #else
26 | # include
27 | # include
28 | # include
29 | # include
30 | #endif
31 |
32 | #include
33 | #include
34 | #include
35 |
36 |
37 | namespace rmlab
38 | {
39 | namespace auxiliary
40 | {
41 | bool
42 | directory_exists(std::string const& path)
43 | {
44 | #ifdef _WIN32
45 | DWORD attributes = GetFileAttributes(path.c_str());
46 |
47 | return (attributes != INVALID_FILE_ATTRIBUTES &&
48 | (attributes & FILE_ATTRIBUTE_DIRECTORY));
49 | #else
50 | struct stat s;
51 | return (0 == stat(path.c_str(), &s)) && S_ISDIR(s.st_mode);
52 | #endif
53 | }
54 |
55 | bool
56 | file_exists( std::string const& path )
57 | {
58 | #ifdef _WIN32
59 | DWORD attributes = GetFileAttributes(path.c_str());
60 |
61 | return (attributes != INVALID_FILE_ATTRIBUTES &&
62 | !(attributes & FILE_ATTRIBUTE_DIRECTORY));
63 | #else
64 | struct stat s;
65 | return (0 == stat(path.c_str(), &s)) && S_ISREG(s.st_mode);
66 | #endif
67 | }
68 |
69 | std::vector< std::string >
70 | list_directory(std::string const& path )
71 | {
72 | std::vector< std::string > ret;
73 | #ifdef _WIN32
74 | std::string pattern(path);
75 | pattern.append("\\*");
76 | WIN32_FIND_DATA data;
77 | HANDLE hFind = FindFirstFile(pattern.c_str(), &data);
78 | if( hFind == INVALID_HANDLE_VALUE )
79 | throw std::system_error(std::error_code(errno, std::system_category()));
80 | do {
81 | if( strcmp(data.cFileName, ".") && strcmp(data.cFileName, "..") )
82 | ret.emplace_back(data.cFileName);
83 | } while (FindNextFile(hFind, &data) != 0);
84 | FindClose(hFind);
85 | #else
86 | auto directory = opendir(path.c_str());
87 | if( !directory )
88 | throw std::system_error(std::error_code(errno, std::system_category()));
89 | dirent* entry;
90 | while ((entry = readdir(directory)) != nullptr)
91 | if( strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..") )
92 | ret.emplace_back(entry->d_name);
93 | closedir(directory);
94 | #endif
95 | return ret;
96 | }
97 |
98 | bool
99 | create_directories( std::string const& path )
100 | {
101 | if( directory_exists(path) )
102 | return true;
103 |
104 | #ifdef _WIN32
105 | auto mk = [](std::string const& p) -> bool { return CreateDirectory(p.c_str(), nullptr); };
106 | #else
107 | mode_t mask = umask(0);
108 | umask(mask);
109 | auto mk = [mask](std::string const& p) -> bool { return (0 == mkdir(p.c_str(), 0777 & ~mask));};
110 | #endif
111 | std::istringstream ss(path);
112 | std::string token;
113 |
114 | std::string partialPath;
115 | // path starts with directory separator? keep also in partialPath
116 | if( path.compare(0, 1, &directory_separator) == 0)
117 | partialPath += directory_separator;
118 | bool success = true;
119 | while( std::getline( ss, token, directory_separator ) )
120 | {
121 | if( !token.empty() )
122 | partialPath += token + directory_separator;
123 | if( !directory_exists( partialPath ) )
124 | {
125 | bool partial_success = mk(partialPath);
126 | if( !partial_success )
127 | // did someone else just race us to create this dir?
128 | if( !directory_exists( partialPath ) )
129 | success = success && partial_success;
130 | }
131 | }
132 | return success;
133 | }
134 |
135 | bool
136 | remove_directory( std::string const& path )
137 | {
138 | if( !directory_exists(path) )
139 | return false;
140 |
141 | bool success = true;
142 | #ifdef _WIN32
143 | auto del = [](std::string const& p) -> bool { return RemoveDirectory(p.c_str()); };
144 | #else
145 | auto del = [](std::string const& p) -> bool { return (0 == remove(p.c_str()));};
146 | #endif
147 | for( auto const& entry : list_directory(path) )
148 | {
149 | std::string partialPath = path + directory_separator + entry;
150 | if( directory_exists(partialPath) )
151 | success &= remove_directory(partialPath);
152 | else if( file_exists(partialPath) )
153 | success &= remove_file(partialPath);
154 | }
155 | success &= del(path);
156 | return success;
157 | }
158 |
159 | bool
160 | remove_file( std::string const& path )
161 | {
162 | if( !file_exists(path) )
163 | return false;
164 |
165 | #ifdef _WIN32
166 | return DeleteFile(path.c_str());
167 | #else
168 | return (0 == remove(path.c_str()));
169 | #endif
170 | }
171 |
172 | } // auxiliary
173 | } // rmlab
174 |
175 |
--------------------------------------------------------------------------------
/include/rmlab/auxiliary/Filesystem.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2018-2019 Fabian Koller
2 | *
3 | * This file is part of openPMD-api.
4 | *
5 | * openPMD-api is free software: you can redistribute it and/or modify
6 | * it under the terms of of either the GNU General Public License or
7 | * the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * openPMD-api is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License and the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * and the GNU Lesser General Public License along with openPMD-api.
19 | * If not, see .
20 | */
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 |
27 | namespace rmlab
28 | {
29 | namespace auxiliary
30 | {
31 | #ifdef _WIN32
32 | constexpr static char const directory_separator = '\\';
33 | #else
34 | constexpr static char const directory_separator = '/';
35 | #endif
36 |
37 | /** Check if a directory exists at a give absolute or relative path.
38 | *
39 | * @param path Absolute or relative path to examine.
40 | * @return true if the given path or file status corresponds to an existing directory, false otherwise.
41 | */
42 | bool
43 | directory_exists(std::string const& path);
44 |
45 | /** Check if a file exists at a given absolute or relative path.
46 | *
47 | * @param path Absolute or relative path to examine.
48 | * @return true if the given path or file status corresponds to an existing file, false otherwise.
49 | */
50 | bool
51 | file_exists(std::string const& path);
52 |
53 | /** List all contents of a directory at a given absolute or relative path.
54 | *
55 | * @note The equivalent of `ls path`
56 | * @note Both contained files and directories are listed.
57 | * `.` and `..` are not returned.
58 | * @throw std::system_error when the given path is not a valid directory.
59 | * @param path Absolute or relative path of directory to examine.
60 | * @return Vector of all contained files and directories.
61 | */
62 | std::vector< std::string >
63 | list_directory(std::string const& path );
64 |
65 | /** Create all required directories to have a reachable given absolute or relative path.
66 | *
67 | * @note The equivalent of `mkdir -p path`
68 | * @param path Absolute or relative path to the new directory to create.
69 | * @return true if a directory was created for the directory p resolves to, false otherwise.
70 | */
71 | bool
72 | create_directories(std::string const& path);
73 |
74 | /** Remove the directory identified by the given path.
75 | *
76 | * @note The equivalent of `rm -r path`.
77 | * @param path Absolute or relative path to the directory to delete.
78 | * @return true if the directory was deleted, false otherwise and if it did not exist.
79 | */
80 | bool
81 | remove_directory(std::string const& path);
82 |
83 | /** Remove the file identified by the given path.
84 | *
85 | * @note The equivalent of `rm path`.
86 | * @param path Absolute or relative path to the file to delete.
87 | * @return true if the file was deleted, false otherwise and if it did not exist.
88 | */
89 | bool
90 | remove_file(std::string const& path);
91 | } // auxiliary
92 | } // rmlab
93 |
94 |
--------------------------------------------------------------------------------
/include/rmlab/renderer/lines2png.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | #include
25 | #include
26 |
27 |
28 | int
29 | main(
30 | int argc,
31 | char * argv[]
32 | )
33 | {
34 | if( argc != 2 )
35 | {
36 | std::cerr << "Usage: " << argv[0] << " path/to/filePrefix" << std::endl;
37 | return 1;
38 | }
39 |
40 | rmlab::Notebook myNotebook( argv[1] );
41 |
42 | if( myNotebook.pages.size() == 0 )
43 | {
44 | std::cerr << "File opening failed!" << std::endl;
45 | return 2;
46 | }
47 |
48 | // draw png
49 |
50 | pngwriter png(
51 | 1404,
52 | 1872,
53 | 65535,
54 | "test.png"
55 | );
56 |
57 | for( auto & page : myNotebook.pages )
58 | {
59 | for( auto & layer : page.layers )
60 | {
61 | for( auto & line : layer.lines )
62 | {
63 | // float lx( 0. );
64 | // float ly( 0. );
65 | for( auto & point : line.points )
66 | {
67 | // float dx = point.x - lx;
68 | // float dy = point.y - ly;
69 |
70 | for( int x = int(point.x); x < int(point.x) + 20; ++x )
71 | {
72 | for( int y = int(point.y); y < int(point.y) + 50; ++y )
73 | {
74 | if( y - point.y > 6 and y - point.y < 30 )
75 | continue;
76 |
77 | png.plot(
78 | x,
79 | 1872 - y,
80 | // color
81 | 0.0, 0.0, 0.0
82 | //dx / 2., dy / 2., 0.5
83 | );
84 | }
85 | }
86 | // lx = point.x;
87 | // ly = point.y;
88 | }
89 | }
90 | }
91 | }
92 |
93 | png.close();
94 |
95 | return 0;
96 | }
97 |
--------------------------------------------------------------------------------
/include/rmlab/renderer/lines2svg.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl, Matteo Delabre
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 |
31 | /**
32 | * Generate a SVG path data representation of a list of points.
33 | *
34 | * @param points Sequence of points to link together.
35 | * @param out Stream into which data should be outputted.
36 | */
37 | void render_path_data(
38 | const std::list< rmlab::Point > & points,
39 | std::ostream & out
40 | )
41 | {
42 | bool is_first = true;
43 |
44 | for( const auto & point : points )
45 | {
46 | out << (is_first ? "M" : "L");
47 | out << point.x << "," << point.y;
48 |
49 | is_first = false;
50 | }
51 | }
52 |
53 | /**
54 | * Generate a SVG path representation of an erased area resulting
55 | * from the use of the rubber area tool. Note that this representation
56 | * is intended to be used as a mask; because of that, it will appear
57 | * black if rendered outside a mask.
58 | *
59 | * @param line Line enclosing the area.
60 | * @param out Stream into which data should be outputted.
61 | */
62 | void render_rubber_area( const rmlab::Line & line, std::ostream & out )
63 | {
64 | out << "";
70 | }
71 |
72 | /**
73 | * Generate a SVG path representation of a line drawn using one of
74 | * the tools that produce lines. Lines drawn using the rubber tool
75 | * are rendered black because they are intended to be used inside
76 | * a mask.
77 | *
78 | * @param line Line to be rendered.
79 | * @param out Stream into which data should be outputted.
80 | */
81 | void render_normal_line( const rmlab::Line & line, std::ostream & out )
82 | {
83 | // TODO: apply brush texture, pressure and tilt parameters
84 |
85 | out << "";
133 | }
134 |
135 | /**
136 | * Generate a SVG path representation of any line.
137 | *
138 | * @param line Line to be rendered.
139 | * @param out Stream into which data should be outputted.
140 | */
141 | void render_line( const rmlab::Line & line, std::ostream & out )
142 | {
143 | switch( line.brush_type )
144 | {
145 | case rmlab::Brushes::rubber_area:
146 | render_rubber_area( line, out );
147 | break;
148 |
149 | default:
150 | render_normal_line( line, out );
151 | break;
152 | }
153 | }
154 |
155 | /**
156 | * Generate a SVG group containing the representation of a layer.
157 | *
158 | * @param id Numeric unique identifier for this layer.
159 | * @param layer Layer to be rendered.
160 | * @param out Stream into which data should be outputted.
161 | */
162 | void render_layer(
163 | std::size_t layer_id,
164 | const rmlab::Layer & layer,
165 | std::ostream & out )
166 | {
167 | auto layer_id_str = "layer-" + std::to_string( layer_id );
168 |
169 | // The most difficult things to render in SVG are erasures:
170 | // we must ensure that they only apply to lines that were drawn
171 | // before them, and that they do not leak on other layers.
172 |
173 | // Given the following sample list of lines:
174 | //
175 | // * normal stroke #1
176 | // * normal stroke #2
177 | // * erasure #1
178 | // * normal stroke #3
179 | // * erasure #2
180 | // * normal stroke #4
181 | //
182 | // We aim at constructing the following group structure:
183 | //
184 | // Layer group
185 | // +- Subgroup masked by erasure #2
186 | // | +- Subgroup masked by erasure #1
187 | // | | +- normal stroke #1
188 | // | | +- normal stroke #2
189 | // | +- normal stroke #3
190 | // +- normal stroke #4
191 |
192 | struct RenderGroup
193 | {
194 | std::vector< rmlab::Line > strokes;
195 | std::vector< rmlab::Line > erasures;
196 | };
197 |
198 | // (First pass.) Cluster the list of lines and erasures into a
199 | // stack of groups so that a given group is only affected by
200 | // the erasures it contains and the ones above it.
201 | std::stack< RenderGroup > open_groups;
202 | RenderGroup current;
203 |
204 | for( const auto & line : layer.lines )
205 | {
206 | switch( line.brush_type )
207 | {
208 | case rmlab::Brushes::rubber:
209 | case rmlab::Brushes::rubber_area:
210 | if( !current.strokes.empty() )
211 | {
212 | // Register an erasure only if there exists previous
213 | // strokes to erase (otherwise, there is nothing to
214 | // erase and it can be safely ignored).
215 | current.erasures.push_back( line );
216 | }
217 | break;
218 |
219 | default:
220 | if( !current.erasures.empty() )
221 | {
222 | // We cannot add a new stroke to a group that already contains
223 | // some erasures, because this new stroke should not be
224 | // affected by the previous erasures; so, we create a new group.
225 | open_groups.push( std::move( current ) );
226 | current = RenderGroup();
227 | }
228 |
229 | current.strokes.push_back( line );
230 | break;
231 | }
232 | }
233 |
234 | open_groups.push( std::move( current ) );
235 |
236 | // (Second pass.) Pop out groups from the stack, thereby creating
237 | // masks and opening the SVG groups. Prepare a reversed stack to
238 | // later close the groups.
239 | std::stack< RenderGroup > close_groups;
240 | std::size_t mask_id = 0u;
241 |
242 | while( !open_groups.empty() )
243 | {
244 | // Create a mask group for all erasures of the group, if any
245 | if( !open_groups.top().erasures.empty() )
246 | {
247 | auto mask_id_str = layer_id_str + "-mask-"
248 | + std::to_string(mask_id);
249 |
250 | out << "";
251 | out << "";
252 |
253 | for( const auto & erasure : open_groups.top().erasures )
254 | {
255 | render_line( erasure, out );
256 | }
257 |
258 | out << "";
259 | out << "";
272 |
273 | close_groups.push( std::move( open_groups.top() ) );
274 | open_groups.pop();
275 |
276 | ++mask_id;
277 | }
278 |
279 | // (Third pass.) Generate paths for each stroke of each group and
280 | // then close the groups.
281 | while( !close_groups.empty() )
282 | {
283 | for( const auto & stroke : close_groups.top().strokes )
284 | {
285 | render_line( stroke, out );
286 | }
287 |
288 | out << "";
289 | close_groups.pop();
290 | }
291 | }
292 |
293 | void render_page( const rmlab::Page& page, std::ostream& out )
294 | {
295 | // SVG header
296 | out << "";
297 | out << "";
311 | }
312 |
313 | int
314 | main(
315 | int argc,
316 | char * argv[]
317 | )
318 | {
319 | if( argc != 2 )
320 | {
321 | std::cerr << "Usage: " << argv[0] << " path/to/filePrefix" << std::endl;
322 | return 1;
323 | }
324 |
325 | rmlab::Notebook myNotebook( argv[1] );
326 |
327 | if( myNotebook.pages.size() == 0 )
328 | {
329 | std::cerr << "File opening failed!" << std::endl;
330 | return 2;
331 | }
332 |
333 | std::size_t page_id = 0u;
334 | for( const auto & page : myNotebook.pages )
335 | {
336 | std::ostringstream page_filename;
337 | page_filename << "test-" << page_id << ".svg";
338 | std::ofstream page_file{ page_filename.str() };
339 |
340 | render_page( page, page_file );
341 | ++page_id;
342 | }
343 |
344 | return 0;
345 | }
346 |
--------------------------------------------------------------------------------
/include/rmlab/rmlab.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | /**
21 | * @mainpage lines-are-beautiful
22 | *
23 | * A C++ file API for the [reMarkable e-ink tablet](https://remarkable.com).
24 | *
25 | * **Warning:** The libraries and tools in this project are not (yet) hardened
26 | * for malicious input. Only process files that you can trust with it!
27 | *
28 | * \section Overview
29 | *
30 | * The [reMarkable tablet](https://remarkable.com/) is a E Ink device that can
31 | * be written on. It can be used as a note-taking device, for annotating or
32 | * reading digital books. User notes are stored in so-called “notebooks” that
33 | * behave just like real-life notebooks.
34 | *
35 | * This library implements reading the `.lines` binary file format, used by
36 | * the device to store notebooks. The data structures are modeled after the
37 | * ones found into this format, namely:
38 | *
39 | * | Structure | Role |
40 | * | --------------- | ----------------------------------------------------- |
41 | * | rmlab::Notebook | Entry point. |
42 | * | rmlab::Page | Each notebook is made up of several pages. |
43 | * | rmlab::Layer | Each page contains a stack of layers. |
44 | * | rmlab::Line | A line is a stroke of the pen, stored inside a layer. |
45 | * | rmlab::Point | A line contains a sequence of sampled points. |
46 | *
47 | * For a complete overview of the file format, see
48 | * [this blog post by Axel Hübl.](https://plasma.ninja/blog/devices/remarkable/binary/format/2017/12/26/reMarkable-lines-file-format.html)
49 | *
50 | * \section Disclaimer
51 | *
52 | * This is a hobby project.
53 | *
54 | * The author(s) and contributor(s) are not associated with reMarkable AS,
55 | * Norway. **reMarkable** is a registered trademark of *reMarkable AS* in
56 | * some countries. Please see for their product.
57 | */
58 |
59 | #pragma once
60 |
61 | // objects for file hierarchy
62 | #include "Notebook.hpp"
63 | #include "Page.hpp"
64 | #include "Layer.hpp"
65 | #include "Line.hpp"
66 | #include "Point.hpp"
67 |
68 |
69 | namespace rmlab
70 | {
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/include/rmlab/tool/dump.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl, Matteo Delabre
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 |
27 | int
28 | main(
29 | int argc,
30 | char * argv[]
31 | )
32 | {
33 | if( argc != 2 )
34 | {
35 | std::cerr << "Usage: " << argv[0] << " path/to/filePrefix" << std::endl;
36 | return 1;
37 | }
38 |
39 | rmlab::Notebook notebook( argv[1] );
40 |
41 | if( notebook.pages.size() == 0 )
42 | {
43 | std::cerr << "File opening failed!" << std::endl;
44 | return 2;
45 | }
46 |
47 | std::cout << "no. of pages: " << notebook.pages.size() << '\n';
48 | std::size_t page_id = 0u;
49 |
50 | for( const auto & page : notebook.pages )
51 | {
52 | std::cout << "page " << page_id
53 | << " -------------------------\n"
54 | << " no. of layers: " << page.layers.size() << '\n';
55 |
56 | std::size_t layer_id = 0u;
57 |
58 | for( const auto & layer : page.layers )
59 | {
60 | std::cout << " layer " << layer_id
61 | << " ----------------------\n"
62 | << " no. of lines: " << layer.lines.size() << '\n';
63 |
64 | std::size_t line_id = 0u;
65 |
66 | for( const auto & line : layer.lines )
67 | {
68 | std::cout << " line " << line_id
69 | << " ---------------------\n"
70 | << " brush type: " << line.brush_type << '\n'
71 | << " color int32: " << line.color << '\n'
72 | << " magic 4byte: "
73 | << line.unknown_line_attribute << '\n'
74 | << " brush size: "
75 | << line.brush_base_size << '\n'
76 | << " no. points: " << line.points.size() << '\n';
77 |
78 | std::size_t point_id = 0u;
79 |
80 | for( const auto & point : line.points )
81 | {
82 | std::cout << " point " << point_id
83 | << " --------------------\n"
84 | << " coords: "
85 | << point.x << ", " << point.y << '\n'
86 | << " speed: " << point.speed << '\n'
87 | << " direction: " << point.direction << '\n'
88 | << " width: " << point.width << '\n'
89 | << " pressure: " << point.pressure << '\n';
90 |
91 | ++point_id;
92 | }
93 |
94 | ++line_id;
95 | }
96 |
97 | ++layer_id;
98 | }
99 |
100 | ++page_id;
101 | }
102 |
103 | return 0;
104 | }
105 |
--------------------------------------------------------------------------------
/include/rmlab/writer/lineDemo.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017-2018 Axel Huebl
2 | *
3 | * This file is part of lines-are-beautiful.
4 | *
5 | * lines-are-beautiful is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * lines-are-beautiful is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with lines-are-beautiful.
17 | * If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 |
27 | int
28 | main(
29 | int argc,
30 | char * argv[]
31 | )
32 | {
33 | if( argc != 2 )
34 | {
35 | std::cerr << "Usage: " << argv[0]
36 | << " path/to/outputFilePrefix"
37 | << std::endl;
38 | return 1;
39 | }
40 |
41 | // rmlab::Notebook myNotebook( argv[1] );
42 | rmlab::Notebook myNotebook{};
43 |
44 | // page 1
45 | auto page1 = rmlab::make_page( { rmlab::make_layer( ) } );
46 | // add lines with one point
47 | auto line1 = rmlab::make_line( rmlab::Brushes::pencil_tilt,
48 | rmlab::Colors::black, 0, 2.125 );
49 | auto line2 = rmlab::make_line( rmlab::Brushes::pencil_tilt,
50 | rmlab::Colors::black, 0, 2.125 );
51 | auto line3 = rmlab::make_line( rmlab::Brushes::pencil_tilt,
52 | rmlab::Colors::black, 0, 2.125 );
53 | // note: spacing of 500 and above is not drawn
54 | for( int x = 200; x < 1200; x+=100 )
55 | {
56 | auto point = rmlab::make_point(
57 | float(x), // 0:1404
58 | 200.f, // 0:1872
59 | 0.5f, // speed
60 | 0.5f, // direction
61 | 0.5f, // width
62 | 1.0f // pressure, range [0.0:1.0]
63 | );
64 | line1.points.emplace_back( point );
65 | }
66 | for( int x = 200; x < 1200; x+=200 )
67 | {
68 | auto point2 = rmlab::make_point(
69 | float(x), // 0:1404
70 | 300.f, // 0:1872
71 | 0.5f, // speed
72 | 0.5f, // direction
73 | 0.5f, // width
74 | 1.0f // pressure, range [0.0:1.0]
75 | );
76 | line2.points.emplace_back( point2 );
77 | }
78 | for( int x = 200; x < 1200; x+=400 )
79 | {
80 | auto point3 = rmlab::make_point(
81 | float(x), // 0:1404
82 | 400.f, // 0:1872
83 | 0.5f, // speed
84 | 0.5f, // direction
85 | 0.5f, // width
86 | 1.0f // pressure, range [0.0:1.0]
87 | );
88 | line3.points.emplace_back( point3 );
89 | }
90 | page1.layers.front().lines.emplace_back( line1 );
91 | page1.layers.front().lines.emplace_back( line2 );
92 | page1.layers.front().lines.emplace_back( line3 );
93 | myNotebook.pages.emplace_back( page1 );
94 |
95 | // save
96 | myNotebook.save( argv[1] );
97 |
98 | return 0;
99 | }
100 |
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.content:
--------------------------------------------------------------------------------
1 | {
2 | "extraMetadata": {
3 | "LastColor": "Gray",
4 | "LastTool": "Ballpoint",
5 | "ThicknessScale": "2"
6 | },
7 | "fileType": "",
8 | "fontName": "",
9 | "lastOpenedPage": 0,
10 | "lineHeight": -1,
11 | "margins": 100,
12 | "orientation": "portrait",
13 | "pageCount": 5,
14 | "textScale": 1,
15 | "transform": {
16 | "m11": 1,
17 | "m12": 0,
18 | "m13": 0,
19 | "m21": 0,
20 | "m22": 1,
21 | "m23": 0,
22 | "m31": 0,
23 | "m32": 0,
24 | "m33": 1
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.metadata:
--------------------------------------------------------------------------------
1 | {
2 | "deleted": false,
3 | "lastModified": "1540978943000",
4 | "metadatamodified": false,
5 | "modified": false,
6 | "parent": "13c61499-94ec-4986-98b0-618b1b3b8286",
7 | "pinned": false,
8 | "synced": true,
9 | "type": "DocumentType",
10 | "version": 97,
11 | "visibleName": "Test line"
12 | }
13 |
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.pagedata:
--------------------------------------------------------------------------------
1 | Blank
2 | Blank
3 | Blank
4 | Blank
5 | Blank
6 |
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/0.jpg
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/1.jpg
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/2.jpg
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/3.jpg
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc.thumbnails/4.jpg
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/0.rm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/0.rm
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/1.rm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/1.rm
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/2.rm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/2.rm
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/3.rm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/3.rm
--------------------------------------------------------------------------------
/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/4.rm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ax3l/lines-are-beautiful/55696bc76a6d162f96eb650df400aec3bd1b1b1e/share/rmlab/examples/aa90b0e7-5c1a-42fe-930f-dad9cf3363cc/4.rm
--------------------------------------------------------------------------------